Class: Merb::CreateSessionMigration

Inherits:
Sequel::Migration
  • Object
show all
Defined in:
lib/merb/session/sequel_session.rb

Overview

Default session migration run if a sessions table does not yet exist.

Will create a table with a name of ‘sessions’ by default, or as set by Merb::Plugins.config[:session_table_name]

Instance Method Summary collapse

Instance Method Details

#upObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/merb/session/sequel_session.rb', line 15

def up
  table_name = Merb::Plugins.config[:merb_sequel][:session_table_name].to_sym
  unless table_exists?(table_name)
    puts "Warning: The database did not contain a '#{table_name}' table for sessions."
    
    create_table table_name do
      primary_key :id
      varchar :session_id
      text :data
      timestamp :created_at
    end
    
    puts "Created '#{table_name}' session table."
  end
end