Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cmendla opened this issue Jun 13, 2016 · 1 comment

Comments

@cmendla
Copy link

cmendla commented Jun 13, 2016

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
Copy link
Author

cmendla commented Jun 13, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant