Created
August 15, 2012 19:19
-
-
Save azizshamim/3362779 to your computer and use it in GitHub Desktop.
Revisions
-
Jeremy Stephens revised this gist
Aug 10, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,8 +29,8 @@ namespace :db do Rake::Task['environment'].invoke(env) require 'sequel/extensions/migration' version = (row = Foo::Database[:schema_info].first) ? row[:version] : nil Sequel::Migrator.apply(Foo::Database, "db/migrate", version - 1) end desc "Nuke the database (drop all tables)" -
Jeremy Stephens revised this gist
Aug 10, 2011 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,16 @@ namespace :db do Sequel::Migrator.apply(Foo::Database, "db/migrate") end desc "Rollback the database" task :rollback, :env do |cmd, args| env = args[:env] || "development" Rake::Task['environment'].invoke(env) require 'sequel/extensions/migration' version = (row = FFXIV::Database[:schema_info].first) ? row[:version] : nil Sequel::Migrator.apply(FFXIV::Database, "db/migrate", version - 1) end desc "Nuke the database (drop all tables)" task :nuke, :env do |cmd, args| env = args[:env] || "development" -
Jeremy Stephens revised this gist
Aug 9, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ end task :environment, [:env] => 'bundler:setup' do |cmd, args| ENV["RACK_ENV"] = args[:env] || "development" require "./lib/foo" end namespace :db do -
Jeremy Stephens created this gist
Aug 9, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ # change foo to your library name # change Foo::Database to your Sequel database namespace :bundler do task :setup do require 'rubygems' require 'bundler/setup' end end task :environment, [:env] => 'bundler:setup' do |cmd, args| ENV["RACK_ENV"] = args[:env] || "development" require "./lib/#{LIB_NAME}" end namespace :db do desc "Run database migrations" task :migrate, :env do |cmd, args| env = args[:env] || "development" Rake::Task['environment'].invoke(env) require 'sequel/extensions/migration' Sequel::Migrator.apply(Foo::Database, "db/migrate") end desc "Nuke the database (drop all tables)" task :nuke, :env do |cmd, args| env = args[:env] || "development" Rake::Task['environment'].invoke(env) Foo::Database.tables.each do |table| Foo::Database.run("DROP TABLE #{table}") end end desc "Reset the database" task :reset, [:env] => [:nuke, :migrate] end