发布帖子:How to migrate from SQLite to PostgreSQL (Rails)
我在我的Rails应用中运行sqlite3 development.sqlite3 .dump | psql mypgdb mypguser
并且我收到此错误(对于我的应用中的所有模型/表格都相同):
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...
会欣赏一些建议/修复。谢谢!
答案 0 :(得分:2)
这对于PostgreSQL来说不是有效的SQL - 您可能需要SERIAL而不是INTEGER AUTOINCREMENT。您可能希望这些序列的manually set the nextval也达到max(id)+1。
然后你会想要处理一个无类型的sqlite和一个严格的PostgreSQL之间的所有其他差异。
然后,您将要在开发设置和部署中停止使用不同的系统。这只是让自己痛苦。
答案 1 :(得分:0)
我建议您使用gem "yaml_db"
,其目的是将表从一个数据库移动到另一个数据库。
https://github.com/ludicast/yaml_db#readme
你可以通过这个宝石简单地完成所有工作。它有2个基本命令,所以没什么难的。