>
> Note the first one says "CreateSessions: never migrated, skipping"
>
> When I then go to run the migrations, most go through fine, but then I get
> the following error when it tries to run the CreateSessions migration:
>
> ~/projects/rails/sillymeters(master) $ rake db:migrate
> (in /Users/rick/projects/rails/sillymeters)
> == CreateSessions: migrating
> =================================================
> -- create_table(:sessions)-
> rake aborted!
> An error has occurred, this and all later migrations canceled:
>
> SQLite3::SQLException: table "sessions" already exists: CREATE TABLE
> "sessions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "session_id"
> varchar(255) NOT NULL, "data" text, "created_at" datetime, "updated_at"
> datetime)
>
> I'm assuming that each application has its own instance of SQLLite so I'm
> curious how this error is occurring or what I need to do to fix it. I
> 'think' I might be getting this because it's possible I did at one point
> have a similar migration that created the Session table, but then I deleted
> that migration and created it as a new one with a new name. The table name
> was the same though "sessions" so I don't get what is going on.
>
Rails tracks migrations that have be run with the schema_migrations
(which contains the numerical identifier for each migration). If you
created a new migration then that migration won't be recorded as
having being run (which is why migrate VERSION=0 doesn't do anything)
but the table is of course still there, so trying to create it again
raises an error
Fred
> The migration in question looks like:
>
> class CreateSessions < ActiveRecord::Migration
> def self.up
> create_table :sessions do |t|
> t.string :session_id, :null => false
> t.text :data
> t.timestamps
> end
>
> add_index :sessions, :session_id
> add_index :sessions, :updated_at
> end
>
> def self.down
> drop_table :sessions
> end
> end
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment