Closed harmon25 closed 7 years ago
looks familiar to this - https://github.com/elixir-ecto/postgrex/issues/248
figured it out - need to make sure to start and stop the repo before running the seed script that references enum types - the Repo module loads types on connection - so if not reconnecting after initial migration the oid reference to the custom type will be missing, as it was created after the connection.
This also happened to me during a data migration.
I tried to set an enum column value for all existing rows in a table in an ecto migration. Defaulting the column seemed like a bad idea because there is no sensible default going forward.
I found no way to safely stop and restart the repo during a migration.
Looks like https://github.com/elixir-ecto/postgrex/issues/243 is related
https://github.com/bitwalker/distillery/blob/master/docs/Running%20Migrations.md
I only have a single repo in my application - so by modifying the above to restart the Repo after migrations are complete will reload the newly generated OIDs.
It but does appear they may do something to fix this behaviour in newer postgrex release...
{:ok, pid} = App.Repo.start_link(pool_size: 1)
...Run Migration...
# stop repo
App.Repo.stop(pid)
# restart repo - only on repo start are OIDs loaded (currently)
App.Repo.start_link(pool_size: 1)
... Run seeds ...
Getting the following exception when running a migration via a distillery command.
Confirmed the
oid
referenced in the error message belongs to an enum type defined withecto_enum
residing in thepg_enum
pg_catalog tableAppears the enum is being created, but when referenced in a schema the exception is raised. Any idea how to fix?