I tried following through the source code and the docs, but after a lost morning I give up: at the same time it's as if not enough assumptions are made in the SchemaDumper
and at the same time there's no SchemaLoader
and following through the sequel
command source code it seems that it clobbers migration information to-date (since it has no "migrations to date" kind of information in the resulting file).
The motivation to do this is a failed migration in tests (Sequel thinks the tables are not there, yet they are so it breaks both on migrating to new versions and the check pending migrations check fails) - and a previous experience that running all migrations from start of history to today is generally a bad way to put up a database.
I've got this thus far:
namespace :schema do
task :dump => :migrations_environment do
schema = without_sequel_logging{ DB.dump_schema_migration }
File.open("db/schema.rb", 'w') {|f| f.write(schema) }
end
task :load => :migrations_environment do
Sequel::Migrator.run(DB, "db/schema.rb")
end
end
normally the load
fails since the Migrator
makes a load of assumptions ranging starting from that it will be given a folder full of files in a specific order, yet this is apparently exactly what sequel -m
and sequel -d
should do according to current source code - and sequel -m
and sequel -d
combo are apparently what you should use when you want to do schema dump & schema load.
Any ideas?