I'm trying to run db:migrate. This fails however because one of the tables that one of the migrations is trying to update does not exist. I searched the codebase and this table is created in db/schema.rb.
How can I run schema.rb before db:migrate??
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.
If you run a rake -T it will list all possible rake tasks for your Rails project. One of them is db:schema:dump which will recreate the schema.
You are doing only a big mistake that you can correct quickly: you should really commit the file db/schema. rb in your repository. This is standard for rails application.
Use the schema load task:
rake db:schema:load
From rake -T
(expurgated version):
rake db:schema:dump # Create db/schema.rb file usable with any AR-supported DB
rake db:schema:load # Load schema.rb file into DB
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