Export to GitHub

cakephp-migrations - issue #1

On SQLite, id PRIMARY KEY is dropped when add_field


Posted on Feb 8, 2008 by Happy Ox

I want to use migration on SQLite. Only replace from "schema_info" to "schema_info", this seems good. But I have problem.

001_create_users_table.yml UP: create_table: users: mail: string pass: string DOWN: drop_table: users

after migrate 1, users table statement is: CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY, mail VARCHAR(255) DEFAULT NULL, pass VARCHAR(255) DEFAULT NULL, created DATETIME DEFAULT NULL NOT NULL, modified DATETIME DEFAULT NULL NOT NULL)

As I expected. But next is not.

002_add_cols_to_users.yml UP: add_field: users: is_active: boolean DOWN: drop_field: users: is_active

after migrate 2, my expected users table statement is: CREATE TABLE users (id INTEGER NOT NULL PRIMARY KEY, mail VARCHAR(255) DEFAULT NULL, pass VARCHAR(255) DEFAULT NULL, created DATETIME DEFAULT NULL NOT NULL, modified DATETIME DEFAULT NULL NOT NULL, is_active BOOLEAN DEFAULT NULL)

but I see instead: CREATE TABLE users (id INTEGER NOT NULL, mail VARCHAR(255) DEFAULT NULL, pass VARCHAR(255) DEFAULT NULL, created DATETIME DEFAULT '1970-01-01 00:00:00' NOT NULL, modified DATETIME DEFAULT '1970-01-01 00:00:00' NOT NULL, is_active BOOLEAN DEFAULT NULL)

id PRIMARY KEY is dropped. Using SQLite is this cause?

CakePHP nightly/1.2.x.x_24.01.2008 Migrate.php v 3.6

thanks

Comment #1

Posted on Feb 8, 2008 by Swift Ox

Comment deleted

Comment #2

Posted on Feb 8, 2008 by Grumpy Ox

This appears to be a bug with MDB2 and not my migrations script. As migrations is passing the correct data and in the correct format.

I will try to submit a ticket to MDB2 for a fix.

Status: Invalid

Labels:
Type-Defect Priority-Medium