Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake db:schema:load not populating schema_migrations table

I have a fresh database that I'm attempting to recreate, but running rake db:schema:load does not populate the schema_migrations table at all. The result of this is every migration is now pending. The schema version in schema.rb matches the latest migration, and this answer would indicate what I thought was happening (Rails populates the migrations table with all migration numbers prior to the current migration nubmer) is, in this particular instance, not happening. My coworkers have confirmed this is happening with their databases as well so it's definitely a project-wide problem. We're using SQLServer with a custom schema, though the db user is correctly creating all tables. I'm completely stumped. Any ideas?

like image 313
john_truckosaur Avatar asked Nov 20 '13 20:11

john_truckosaur


2 Answers

Per D. Patrick, answering my own question:

So the end result was that another developer had installed activerecord-nulldb-adapter, which monkey patches ActiveRecord::Schema.define and doesn't run initialize_schema_migrations_table() or assume_migrated_up_version(). I uninstalled the gem, ran my db:schema:load just fine.

like image 73
john_truckosaur Avatar answered Oct 11 '22 14:10

john_truckosaur


Try to run the command with the trace flag

rake db:schema:load --trace

By the end of the log you should see lines

-- initialize_schema_migrations_table()
   -> 0.0045s

Also, it worth to check does you test suit generate table from schema and the schema_migrations table correctly.

like image 30
kubum Avatar answered Oct 11 '22 13:10

kubum