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 #125

Closed
wants to merge 1 commit into from
Closed

Schema update #125

wants to merge 1 commit into from

Conversation

ariga-bot
Copy link
Collaborator

Renamed the column 'user_name' to 'username' in the 'users' table to demonstrate a backward-incompatible change.

…demonstrate a backward-incompatible change.
Copy link
Contributor

github-actions bot commented Dec 5, 2024

atlas migrate lint on dirs/ecommerce/migrations

Status Step Result
1 new migration file detected 20241205131431.sql
ERD and visual diff generated View Visualization
Analyze 20241205131431.sql
2 reports were found in analysis
Destructive changes detected
Dropping non-virtual column "user_name" (DS103)
Data dependent changes detected
Adding a non-nullable "varchar" column "username" 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 COLUMN `user_name`, ADD COLUMN `username` varchar(255) NOT NULL COMMENT "The username of the user, must be unique", ADD UNIQUE INDEX `username` (`username`);
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 "user_name" DS103

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

Suggested change
-- Modify "users" table
ALTER TABLE `users` DROP COLUMN `user_name`, ADD COLUMN `username` varchar(255) NOT NULL COMMENT "The username of the user, must be unique", ADD UNIQUE INDEX `username` (`username`);
-- atlas:txtar
-- checks/destructive.sql --
-- atlas:assert DS103
SELECT NOT EXISTS (SELECT 1 FROM `users` WHERE `user_name` IS NOT NULL) AS `is_empty`;
-- migration.sql --
-- Modify "users" table
ALTER TABLE `users` DROP COLUMN `user_name`, ADD COLUMN `username` varchar(255) NOT NULL COMMENT "The username of the user, must be unique", ADD UNIQUE INDEX `username` (`username`);

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

@giautm giautm closed this Dec 22, 2024
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