mirego/accent

Accent migrations cannot be applied on restart

MichiLego opened this issue · 1 comments

Hi,

restarting the existing software stack causes the following issues:

database logs:
2023-11-14 20:30:51.973 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-11-14 20:30:51.973 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-11-14 20:30:51.987 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-11-14 20:30:52.031 UTC [24] LOG: database system was shut down at 2023-11-14 20:28:39 UTC 2023-11-14 20:30:52.038 UTC [1] LOG: database system is ready to accept connections 2023-11-14 20:30:53.262 UTC [31] ERROR: extension "pg_trgm" already exists 2023-11-14 20:30:53.262 UTC [31] STATEMENT: CREATE EXTENSION pg_trgm 2023-11-14 20:30:54.930 UTC [33] ERROR: extension "pg_trgm" already exists 2023-11-14 20:30:54.930 UTC [33] STATEMENT: CREATE EXTENSION pg_trgm

application logs:
Running migrations for accent… 20:30:53.257 [info] == Running 20180426090527 Accent.Repo.Migrations.AddTrigramIndicesOnSearchableFields.change/0 forward 20:30:53.262 [info] execute "CREATE EXTENSION pg_trgm" ** (Postgrex.Error) ERROR 42710 (duplicate_object) extension "pg_trgm" already exists (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1 (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1154: Ecto.Adapters.SQL.execute_ddl/4 (ecto_sql 3.10.2) lib/ecto/migration/runner.ex:327: Ecto.Migration.Runner.log_and_execute_ddl/3 (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2 (ecto_sql 3.10.2) lib/ecto/migration/runner.ex:290: Ecto.Migration.Runner.perform_operation/3 (stdlib 5.1.1) timer.erl:270: :timer.tc/2

Thanks for the help!

I added IF NOT EXISTS in the latest version to make sure that the migration does not crash 😄