Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run mix event_store.init with existing database #221

Closed
ser1us opened this issue Oct 15, 2020 · 3 comments
Closed

Unable to run mix event_store.init with existing database #221

ser1us opened this issue Oct 15, 2020 · 3 comments

Comments

@ser1us
Copy link

ser1us commented Oct 15, 2020

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

@slashdotdash
Copy link
Member

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:

@ser1us
Copy link
Author

ser1us commented Oct 17, 2020

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

  1. Not sure if there is a better way to interpolate the database name into the create and insert script
  2. 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.
  3. 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!

@slashdotdash
Copy link
Member

@ser1us The changes you've made look good so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants