Skip to content

Schema update - #493

Open
ariga-bot wants to merge 1 commit into
masterfrom
f/385135
Open

Schema update#493
ariga-bot wants to merge 1 commit into
masterfrom
f/385135

Conversation

@ariga-bot

Copy link
Copy Markdown
Collaborator

Backward-incompatible change: renamed . to . (applications referencing will break; related unique index, functional index, and CHECK constraint updated to use the new column name).

…g will break; related unique index, functional index, and CHECK constraint updated to use the new column name).
@github-actions

Copy link
Copy Markdown
Contributor

atlas migrate lint on dirs/ecommerce/migrations

Status Step Result
1 new migration file detected 20260719133457.sql
ERD and visual diff generated View Visualization
Analyze 20260719133457.sql
2 reports were found in analysis
Destructive changes detected
Dropping non-virtual column "email_address" (DS103)
Data dependent changes detected
Adding a non-nullable "varchar" column "email" on table "users" without a default value implicitly sets existing rows with "" (MY101)
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`,_utf8mb4'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')), DROP COLUMN `email_address`, ADD COLUMN `email` varchar(255) NOT NULL COMMENT "Email address of the user, now stored case-insensitively" COLLATE utf8mb4_0900_as_ci AFTER `user_name`, DROP INDEX `user_name_email_address`, DROP INDEX `users_email_address_lower`, ADD UNIQUE INDEX `email` (`email`), ADD UNIQUE INDEX `user_name_email` (`user_name`, `email`), ADD INDEX `users_email_lower` ((lower(`email`)));

Copy link
Copy Markdown
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_address" DS103

Add a pre-migration check to ensure column "email_address" 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`,_utf8mb4'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')), DROP COLUMN `email_address`, ADD COLUMN `email` varchar(255) NOT NULL COMMENT "Email address of the user, now stored case-insensitively" COLLATE utf8mb4_0900_as_ci AFTER `user_name`, DROP INDEX `user_name_email_address`, DROP INDEX `users_email_address_lower`, ADD UNIQUE INDEX `email` (`email`), ADD UNIQUE INDEX `user_name_email` (`user_name`, `email`), ADD INDEX `users_email_lower` ((lower(`email`)));
-- atlas:txtar
-- checks/destructive.sql --
-- atlas:assert DS103
SELECT NOT EXISTS (SELECT 1 FROM `users` WHERE `email_address` 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`,_utf8mb4'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')), DROP COLUMN `email_address`, ADD COLUMN `email` varchar(255) NOT NULL COMMENT "Email address of the user, now stored case-insensitively" COLLATE utf8mb4_0900_as_ci AFTER `user_name`, DROP INDEX `user_name_email_address`, DROP INDEX `users_email_address_lower`, ADD UNIQUE INDEX `email` (`email`), ADD UNIQUE INDEX `user_name_email` (`user_name`, `email`), ADD INDEX `users_email_lower` ((lower(`email`)));

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

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.

1 participant