Skip to main content

How to Keep Constraint Names While Running Migrate Diff

How to keep constraints name while running migrate diff?

Answer

By default, when you run atlas migrate diff, constraint names may be automatically generated or changed. If you want to keep the original names of your database constraints, you can instruct Atlas to skip renaming them during the diff stage.

To do so, create a diff.skip block in your Atlas HCL configuration and add the attribute rename_constraint = true. This tells Atlas to skip renaming constraints during the diff operation and preserve your existing constraint names.

Here's an example of how you might configure it:

env "local" {
diff {
skip {
rename_constraint = true
}
}
}

For more details on the diff.skip configuration and its available attributes, please refer to the Atlas documentation on diff.skip.