Sha256: da465bdac293664b7a9073ff715ab42a911b488c3d506b24a76dc9d3359dae12

Contents?: true

Size: 895 Bytes

Versions: 3

Compression:

Stored size: 895 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
      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

3 entries across 3 versions & 1 rubygems

Version Path
merb_sequel-0.4.1 lib/merbtasks.rb
merb_sequel-0.4.0 lib/merbtasks.rb
merb_sequel-0.0.4 lib/merbtasks.rb