Reputation: 13862
I keep getting error to rake db:migrate
everytime I seed. I don't want to migrate because it fails due to looking up tables in my database that don't exist yet. How can I ignore this and continue with seed?
mmahalwy @ ~/Desktop/Code/API [56] → rake db:seed
You have 4 pending migrations:
20141206123759 AddEsAnalyzerColumnToLanguageTable
20141213090426 CreateTextFontView
20141213090434 UpdateLemmaAndStem
20141230124205 ChangeTextFontView
Run `rake db:migrate` to update your database then try again.
Note: I have a structure.sql
file that has all the sql commands for creating the tables and seeding the data from yml. My migrations currently need to run AFTER the data/tables are in the database.
Upvotes: 4
Views: 4340
Reputation: 17834
How can you save values to the tables that don't exist? The job of rake db:migrate
is to create tables in the database.
rake db:create
creates database
rake db:migrate
creates tables in the database
rake db:seed
creates records in the tables based on seed data
Upvotes: 4
Reputation: 34774
You could bypass rake altogether and 'seed' directly. I'm not really advocating it but it would solve your immediate problem:
rails runner ActiveRecord::Tasks::DatabaseTasks.load_seed
You may want to look at the db:structure:load
task to load your structure.sql file if that is all your seeding is doing.
Upvotes: 6