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

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.