我有一个项目,其中的数据库是redshift,我在phoenix项目中使用Postgrex适配器,在本地我使用postgresql,一切工作正常,但当我部署并尝试运行迁移时,我收到了这个错误。
15:39:27.201 [error] Could not create schema migrations table. This error usually happens due to the following:
* The database does not exist
* The "schema_migrations" table, which Ecto uses for managing
migrations, was defined by another library
* There is a deadlock while migrating (such as using concurrent
indexes with a migration_lock)
To fix the first issue, run "mix ecto.create".
To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create". Alternatively you may configure Ecto to use
another table for managing migrations:
config :my_service, MyService.Repo,
migration_source: "some_other_table_for_schema_migrations"
The full error report is shown below.
▸ Given the following expression: Elixir.MyService.StartupTasks.init()
▸ The remote call failed with:
▸ ** (exit) %Postgrex.Error{connection_id: 5598, message: nil, postgres: %{code: :feature_not_supported, file: "/home/ec2-user/padb/src/pg/src/backend/commands/tablecmds.c", line: "3690", message: "timestamp or timestamp with time zone column do not support precision.", pg_code: "0A000", routine: "xen_type_size_from_attr", severity: "ERROR"}, query: nil}
▸ (ecto_sql) lib/ecto/adapters/sql.ex:629: Ecto.Adapters.SQL.raise_sql_call_error/1
▸ (elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
▸ (ecto_sql) lib/ecto/adapters/sql.ex:716: Ecto.Adapters.SQL.execute_ddl/4
▸ (ecto_sql) lib/ecto/migrator.ex:633: Ecto.Migrator.verbose_schema_migration/3
▸ (ecto_sql) lib/ecto/migrator.ex:477: Ecto.Migrator.lock_for_migrations/4
▸ (ecto_sql) lib/ecto/migrator.ex:401: Ecto.Migrator.run/4
▸ (my_service) lib/my_service/startup_tasks.ex:11: MyService.StartupTasks.migrate/0
▸ (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6看起来redshift不支持postgres支持的一些数据类型,所以有没有更好的方法来做这件事,或者我可以用另一个时间戳创建我自己的模式迁移表?
发布于 2019-09-24 16:33:57
由于postgres数据库与postgres数据库的工作原理不同,因此存在驱动程序无法产生的限制,here是ecto适配器的文档。
在文档中声明:
我们强烈建议阅读AWS Redshift文档中的Designing Tables部分。
如果你想继续在本地使用postgres,那么你需要创建两个独立的repos和相应的迁移。Here是可用于迁移单独存储库的命令。
但是,我建议获取一个redshift的dev实例并将其用于开发,因为使用诸如redshift这样的数据库的方法是不同的,您很容易犯错误。
https://stackoverflow.com/questions/58075925
复制相似问题