1

Following the post: How to migrate from SQLite to PostgreSQL (Rails)

I am running sqlite3 development.sqlite3 .dump | psql mypgdb mypguser in my Rails app and I'm getting this error (same for all models/tables in my app):

ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  syntax error at or near "AUTOINCREMENT"
LINE 1: ...E TABLE "projects" ("id" INTEGER PRIMARY KEY AUTOINCREM...

Would appreciate some suggestions/fixed. Thanks!

Community
  • 1
  • 1
mo5470
  • 937
  • 3
  • 10
  • 26

2 Answers2

2

That's not valid SQL for PostgreSQL - you probably want a SERIAL instead of INTEGER AUTOINCREMENT. You may want to manually set the nextval of thesequence to max(id)+1 too.

Then you'll want to deal with all the other differences between a mostly-typeless sqlite and a strict PostgreSQL.

Then you'll want to stop using different systems on your development setup and in deployment. It's just causing yourself pain.

Richard Huxton
  • 21,516
  • 3
  • 39
  • 51
0

I recommand you to use gem "yaml_db", it's purpose is to move tables from one database to another. https://github.com/ludicast/yaml_db#readme

You can get everything done simply by this gem with a nice documentation. It has 2 basic commands so nothing difficult about it.

Bogdan M.
  • 2,161
  • 6
  • 31
  • 53