cardano-db-sync
cardano-db-sync copied to clipboard
How to customize database schema name?
Is there a way to make db-sync use another schema instead of 'public'?
Say like passing a POSTGRES_SCHEMA env var with a different name?
This is really needed to properly take control over the setup and to manage better security permissions and versions.
The schema looks to be hardcoded. I would support making this configurable
Thanks @sgillespie, we really need this. Also I'm about to suggest CF's Ledger Sync to take same approach earlier.
Yes it is harcoded all across the repo, on code, migration files and tests.
Example: https://github.com/IntersectMBO/cardano-db-sync/blob/045330da2352504f67f68a0b870cc5e08951810b/cardano-db/src/Cardano/Db/Migration.hs#L289
db-sync currently uses the default schema of the db. One solution is to change it before starting db-sync
alter database <db> set search_path to <schema>;
then db-sync will use the correct one.
Btw the "public" reference in the link that you sent is only used for testing and shouldn't be a problem.