Skip to content

Instantly share code, notes, and snippets.

@azizshamim
Created August 15, 2012 19:19
Show Gist options
  • Select an option

  • Save azizshamim/3362779 to your computer and use it in GitHub Desktop.

Select an option

Save azizshamim/3362779 to your computer and use it in GitHub Desktop.

Revisions

  1. Jeremy Stephens revised this gist Aug 10, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Rakefile
    Original 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 = FFXIV::Database[:schema_info].first) ? row[:version] : nil
    Sequel::Migrator.apply(FFXIV::Database, "db/migrate", version - 1)
    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)"
  2. Jeremy Stephens revised this gist Aug 10, 2011. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions Rakefile
    Original 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"
  3. Jeremy Stephens revised this gist Aug 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Rakefile
    Original 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/#{LIB_NAME}"
    require "./lib/foo"
    end

    namespace :db do
  4. Jeremy Stephens created this gist Aug 9, 2011.
    37 changes: 37 additions & 0 deletions Rakefile
    Original 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