Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema update #137

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Schema update #137

merged 1 commit into from
Jan 6, 2025

Conversation

ariga-bot
Copy link
Collaborator

Renamed column 'email' to 'email_address' in the 'users' table, which is a backward-incompatible change as it may break existing queries using the old column name.

… is a backward-incompatible change as it may break existing queries using the old column name.
Copy link
Contributor

github-actions bot commented Jan 5, 2025

atlas migrate lint on dirs/ecommerce/migrations

Status Step Result
1 new migration file detected 20250105130916.sql
ERD and visual diff generated View Visualization
Analyze 20250105130916.sql
2 reports were found in analysis
Destructive changes detected
Dropping non-virtual column "email" (DS103)
Data dependent changes detected
Adding a non-nullable "varchar" column "email_address" on table "users" without a default value implicitly sets existing rows with "" (MY101)
Adding a unique index "user_name_email_address" on table "users" might fail in case column "user_name" contains duplicate entries (MF101)
Read the full linting report on Atlas Cloud

Comment on lines +1 to +2
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, DROP INDEX `user_name_email`, ADD UNIQUE INDEX `email_address` (`email_address`), ADD UNIQUE INDEX `user_name_email_address` (`user_name`, `email_address`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

destructive changes detected
Dropping non-virtual column "email" DS103

Add a pre-migration check to ensure column "email" is NULL before dropping it

Suggested change
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, DROP INDEX `user_name_email`, ADD UNIQUE INDEX `email_address` (`email_address`), ADD UNIQUE INDEX `user_name_email_address` (`user_name`, `email_address`);
-- atlas:txtar
-- checks/destructive.sql --
-- atlas:assert DS103
SELECT NOT EXISTS (SELECT 1 FROM `users` WHERE `email` IS NOT NULL) AS `is_empty`;
-- migration.sql --
-- Modify "users" table
ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, DROP INDEX `user_name_email`, ADD UNIQUE INDEX `email_address` (`email_address`), ADD UNIQUE INDEX `user_name_email_address` (`user_name`, `email_address`);

Ensure to run atlas migrate hash --dir "file://dirs/ecommerce/migrations" after applying the suggested changes.

@a8m a8m merged commit 38754fa into master Jan 6, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants