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

add ecto schema prefix config support #184

Closed

Conversation

diogomrts
Copy link

@diogomrts diogomrts commented Nov 18, 2024

In some cases our public schema is managed by another team/project so would be nice to have this config.

This is just a quick PR that i tested with PostgreSQL and worked for fetching/enabling/disabling a simple boolean flag.

I'm not too familiar with the other DB engines so I'm not sure if these changes would work for all.

@tompave
Copy link
Owner

tompave commented Nov 20, 2024

Hi, thank you for using the library and for the PR.

I'm not too familiar with the other DB engines so I'm not sure if these changes would work for all.

I don't think this will work as it is with DBs other than Postgres. I've allowed CI to run on the PR, and I can see the tests fail with both MySQL and SQLite. You can also verify this locally with mix test.all.

In general, this sort of customization can be achieved with a custom persistence adapter. Would that solve your problem?

@tompave
Copy link
Owner

tompave commented Nov 20, 2024

Further question: shouldn't the postgres schema be defined in the Ecto Repo, at the connection level? I've done some googling and it looks like that's how people usually solve this. In that case, you should simply pass to FunWithFlags a properly configured Ecto Repo.

@diogomrts
Copy link
Author

In our case we have a single Ecto Repo and we specify the @schema_prefix or :prefix opt when working with different ones. But the custom persistence adapter works for our use case thank you very much 🙏

@diogomrts diogomrts closed this Nov 21, 2024
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

Successfully merging this pull request may close these issues.

2 participants