Unable to run `mix event_store.init` with existing database
ser1us opened this issue · 3 comments
Hello there!
I have a database ready with a couple of tables already in use. Now I am trying to introduce eventstore to the project and according to the docs it should be possible to reuse an existing database by simply running mix event_store.init
.
That's when I run into this error message:
** (Postgrex.Error) ERROR 42P07 (duplicate_table) relation "schema_migrations" already exists
Adding schema
to the config works for obvious reasons, but that's not what I was looking for :)
Cheers,
Christoph
This is due to a clash between the table used by Ecto and EventStore to manage their database migrations. Both use the same schema_migrations
table name.
You will need to either:
- Rename the existing Ecto
schema_migrations
table to prevent the conflict. See #73 for details. - Use a separate Postgres schema or database for the event store.
- Submit a PR to allow the EventStore migrations table to be configured (😉)
Thanks for the info!
I tried to make the table configurable. Please have a look at the diff here: develop...ser1us:feature/configure-migration-source
- Not sure if there is a better way to interpolate the database name into the create and insert script
- I would need some help with some tests :) The tests are working fine, which means the method returns the previous name as the fallback. But I guess it would be good to have some explicit tests in place.
- Last but not least, there is no documentation yet 😂
I would love to get some early feedback before I finish the work and submit a PR.
I was able to execute event_source.init
in my project with this change and adjusted config. The table is created and everything is set up.
Cheers!
@ser1us The changes you've made look good so far.