activerecord-session_store icon indicating copy to clipboard operation
activerecord-session_store copied to clipboard

errors when trying to migrate the sessions table that seem to relate to the schema prefix

Open cmendla opened this issue 9 years ago • 1 comments

I have an application that uses a schema prefix of eo.

When I installed the gem, ran the generator for session migrate and then tried to do a db:migrate, I got

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `sessions' for :eo:Symbol
C:/Users/cmendla/RubymineProjects/employee_observations/db/migrate/20160613152644_add_sessions_table.rb:3:in `change'
C:in `migrate'
-e:1:in `load'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
== 20160613152644 AddSessionsTable: migrating =================================

Since it seemed to be having trouble with the prefix, I changed the migration to eliminate the prefixes.

class AddSessionsTable < ActiveRecord::Migration
  def change
    create_table :sessions do |t|
      t.string :session_id, :null => false
      t.text :data
      t.timestamps
    end

    add_index :sessions, :session_id, :unique => true
    add_index :sessions, :updated_at
  end
end

However, I still am getting an error of

C:\Ruby200\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/cmendla/RubymineProjects/employee_observations/bin/rake db:migrate
== 20160613152644 AddSessionsTable: migrating =================================
-- create_table(:sessions)
   -> 0.0050s
   -> -1 rows
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `sessions' for :eo:Symbol
C:/Users/cmendla/RubymineProjects/employee_observations/db/migrate/20160613152644_add_sessions_table.rb:9:in `change'
C:in `migrate'
-e:1:in `load'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Process finished with exit code 1

I believe that this is related to the fact that I am using a schema prefix.

cmendla avatar Jun 13 '16 15:06 cmendla

I did get the migration to work by changing the index part to


    add_index :sessions, :session_id, :unique => true, :name => 'supervisor_id_ix'
    add_index :sessions, :updated_at, :name => 'index_ix'
  end

I'm not sure if that is correct or not. I've attached a screenshot from the sql manager

2016 06 13 capture

cmendla avatar Jun 13 '16 15:06 cmendla