Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make it compatible with Sequel 2.12.x and 3.x, tasks refactoring.

  • Loading branch information...
commit aee5c3be70be4f13a5fffbe3f85b91b52d045598 1 parent c8184f1
@pk authored
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/merb_sequel/merbtasks.rb
View
20 lib/merb_sequel/merbtasks.rb
@@ -11,13 +11,21 @@
desc "Perform migration using migrations in schema/migrations"
task :migrate => :sequel_env do
+ require 'sequel/extensions/migration' if /^(2.12|3)/ =~ Sequel.version
Sequel::Migrator.apply(Sequel::Model.db, "schema/migrations", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
+
+ desc "Drop all tables"
+ task :drop_tables => :sequel_env do
+ Sequel::Model.db.drop_table *Sequel::Model.db.tables
+ end
desc "Drop all tables and perform migrations"
- task :reset => :sequel_env do
- Sequel::Model.db.drop_table *Sequel::Model.db.tables
- Sequel::Migrator.apply(Sequel::Model.db, "schema/migrations", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
+ task :reset => [:sequel_env, :drop_tables, :migrate]
+
+ desc "Truncate all tables in database"
+ task :truncate => :sequel_env do
+ Sequel::Model.db << "TRUNCATE #{db.tables.join(', ')} CASCADE;"
end
desc "Create the database according to the config from the database.yaml. Use [username,password] if you need another user to connect to DB than in config."
@@ -50,12 +58,6 @@
raise "Adapter #{config[:adapter]} not supported for dropping databases yet."
end
end
-
- desc "Truncate all tables in database"
- task :truncate => :sequel_env do
- db = Sequel::Model.db
- db << "TRUNCATE #{db.tables.join(', ')} CASCADE;"
- end
end
namespace :sessions do
Please sign in to comment.
Something went wrong with that request. Please try again.