This project is archived and is in readonly mode.
Sqlite, sqlite3 bug in add_column when column is primary key (Trac #9385)
-
Pratik
- State changed from new to duplicate
-
JasonKing
I suspect that Pratik meant to put the ticket #2080 sqlite missing ddl transactions and savepoints in his comment. I've included the fix for this in my patch for a related issue - just took your tests directly.
-
Nolan Eakins
- Assigned user set to Pratik
Wish I could reopen this bug, but w/ Rails 2.3 I am unable to add a primary key column using sqlite3. The following is the error I received while migrating:
== AddIdToEmployees: migrating =========================== -- add_column(:employees, :id, :primary_key) rake aborted! An error has occurred, all later migrations canceled: SQLite3::SQLException: Cannot add a PRIMARY KEY column: ALTER TABLE "employees" ADD "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
-
JasonKing
- Tag changed from 2.2.2, database, migrations, refactoring, sql, sqlite3 to 2.2.2, database, migrations, primary_key, refactoring, sql, sqlite3
Which version of rails are you using? In 2.3.2 the adapter doesn't even use the ALTER TABLE statement for adding primary key columns - so you're not using the final 2.3 release.
-
Nolan Eakins
I'll give 2.3 a try. This will be another reason to upgrade talk my client into upgrading to Rails 2.3.
-
JasonKing
- Assigned user cleared.
Your original comment said that you were using 2.3 :) I guess you're using 2.2 - so yeah, this bug was fixed in the 2.3 final release (v2.3.2).
Before this, in sqlite, there's no way to add a primary key column with a Rails migration because of the sqlite limitations in ALTER TABLE.