Reputation: 2583
I have a mariaDB database with a rails application.
I'm planning to setup the rails application normally first, then use its user interface to create the database data first, then export those data using mysqldump.
mysqldump -u username -p database_name > data-dump.sql
My question is, if I do migration later, can I still load the mysql dump without facing a problem?
For example, if my migration removes a column, should I create a new database backup using mysqldump again?
And is there anything I need to be careful about schema?
Upvotes: 0
Views: 618
Reputation: 820
When you do a mysqldump, by default the table create statements are included. They are only excluded if you pass in the --no-create-info flag. Since your migrations are just alterations to the tables, you can be assured that when you load your data later, it will have all of your migrations applied to it up to the point in time your database was dumped.
Furthermore, when you run migrations, rails keeps track of which have been run in the schema_migrations table. So if you roll back to a point in time where you had more migrations afterwards, you can re-run rake db:migrate and only those new ones will run, since that data was all part of your backup.
Upvotes: 3