Best way to load seed data? I have an Author table that is tightly coupled with a Users table. I also have migrations to alter both of these tables. I want to add a default admin user but I want to make sure that both tables are created and all migrations have run for these tables before my CreateDefaultAdmin (or whatever) migration runs. Is there a best practices for doing this? Sorry if this was already asked.
You can append as many column name/type pairs as you want. By default, the generated migration will include t. timestamps (which creates the updated_at and created_at columns that are automatically populated by Active Record).
When you run db:migrate, rails will check a special table in the database which contains the timestamp of the last migration applied to the database. It will then apply all of the migrations with timestamps after that date and update the database table with the timestamp of the last migration.
The schema. rb serves mainly two purposes: It documents the final current state of the database schema. Often, especially when you have more than a couple of migrations, it's hard to deduce the schema just from the migrations alone. With a present schema.
Your options:
Personally I use a modified yaml-db. I like to build up all my seed data into my dev environment, and keep it backed up in my repository, when I go live I can load it with a rake task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With