Sha256: 2b5080f9cdf21636b0dbb3e61e24cc1737d662a1df95de5ea458a33e06e42147

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

require "fileutils"

namespace :sequel do

  namespace :db do

    desc "Perform migration using migrations in schema/migrations"
    task :migrate => :merb_env do
      Sequel::Migrator.apply(Merb::Orms::Sequel.connect, "schema/migrations", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
    end

  end
  
  namespace :sessions do

    desc "Creates session migration"
    task :create => :merb_env do
      # TODO: this should not use '001' always...
      dest = File.join(MERB_ROOT, "schema", "migrations","001_add_sessions_table.rb")
      source = File.join(File.dirname(__FILE__), "merb", "session","001_add_sessions_table.rb")
      
      FileUtils.cp source, dest unless File.exists?(dest)
    end
    
    desc "Clears sessions"
    task :clear => :merb_env do
      table_name = (Merb::Plugins.config[:sequel][:session_table_name] || "sessions")
      
      Merb::Orms::Sequel.connect.execute("DELETE FROM #{table_name}")
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
merb_sequel-0.4.2 lib/merbtasks.rb
merb_sequel-0.4.3 lib/merbtasks.rb