1

在帖子之后:如何从 SQLite 迁移到 PostgreSQL(Rails)

sqlite3 development.sqlite3 .dump | psql mypgdb mypguser在我的 Rails 应用程序中运行,我收到此错误(我的应用程序中的所有模型/表都相同):

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

将不胜感激一些建议/修复。谢谢!

4

2 回答 2

2

这对于 PostgreSQL 来说不是有效的 SQL——你可能想要一个SERIAL而不是 INTEGER AUTOINCREMENT。您可能还想手动将这些序列的 nextval 设置为 max(id)+1。

然后,您将需要处理大多数无类型的 sqlite 和严格的 PostgreSQL 之间的所有其他差异。

然后,您将希望停止在开发设置和部署中使用不同的系统。只会让自己痛苦。

于 2012-07-02T10:23:08.217 回答
0

我建议您使用gem "yaml_db",其目的是将表从一个数据库移动到另一个数据库。 https://github.com/ludicast/yaml_db#readme

你可以通过这个 gem 和一个很好的文档来完成所有的事情。它有 2 个基本命令,所以没什么难的。

于 2012-09-15T12:18:16.410 回答