Skip to content

Commit

Permalink
Make it compatible with Sequel 2.12.x and 3.x, tasks refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
pk committed May 4, 2009
1 parent c8184f1 commit aee5c3b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/merb_sequel/merbtasks.rb
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aee5c3b

Please sign in to comment.