New to database migration. Assuming I have:
- A new and empty database
- A new server with migration files that never being executed
Now, I start my server and new tables will be created because the server executed the migration operations. My questions are:
- Should the migration operations be executed again if the server is turned off and on?
- If there is no new migration files being added to the server, there shouldn't be any changes to the existing database, correct? From what I have tested, the database does not have anything done to it if there is no new migration files being added to the server.
CodePudding user response:
Your initial database creation scripts should be idempotent. They should be able to execute in an if not exists create table
fashion.
If your codebase defining the application changes at all, the framework you use to autogenerate your migration files should pick up on that and generate the deltas for you.