views:

41

answers:

1

I developed a ROR application using MySQL and now want it to use Postgres instead.

I've used Navicat to data transfer the MySQL database to Postgres, and updated the database.yml with the Postgres environment settings.

When I run the ROR application, and try and login or create a user, I get the following error:

RuntimeError: ERROR C23502 Mnull value in column "id" violates not-null constraint FexecMain.c L2229 RExecConstraints: INSERT INTO "users

Thank you

+2  A: 

Sounds like you had an AUTO_INCREMENT id column in your MySQL database. This is a non-ANSI-standard feature, so it won't necessarily work on other databases.

To do the same on Postgres you could use a SERIAL column type (or an equivalent explicit SEQUENCE).

bobince
How do I fix this, Is it something in the code I need to change or in the database, or both? Thank you
RewbieNewbie
This worked:ALTER TABLE users ALTER COLUMN id set DEFAULT NEXTVAL('users_id_seq')
RewbieNewbie