sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

feat: default schema configuration for postgresql

Open prog8 opened this issue 1 year ago • 11 comments
trafficstars

related to https://github.com/sqlc-dev/sqlc/issues/3663

prog8 avatar Oct 21 '24 12:10 prog8

Thanks for taking the time to contribute a PR.

The tests are currently broken. Could you take a look at the failures and se what's up?

kyleconroy avatar Nov 25 '24 04:11 kyleconroy

@kyleconroy test pass. Thanks

prog8 avatar Dec 19 '24 16:12 prog8

@kyleconroy should I add something more here?

prog8 avatar Dec 27 '24 10:12 prog8

+1

ecasilla avatar Feb 14 '25 20:02 ecasilla

ping @kyleconroy

prog8 avatar Mar 11 '25 13:03 prog8

@kyleconroy any chance to merge it?

prog8 avatar Mar 31 '25 10:03 prog8

We're also using sqlc with a Posgres database with multiple schemas and would love to see this feature. +1

jakob-lilliemarck avatar Apr 16 '25 11:04 jakob-lilliemarck

Oh we so need this!

jmfederico avatar Apr 16 '25 14:04 jmfederico

@kyleconroy anything that is needed for this to happen? Happy to help if so.

jmfederico avatar Apr 16 '25 14:04 jmfederico

I'm depending on these fixes for my use case. I'm currently using the fork from @prog8, but since https://github.com/sqlc-dev/sqlc/issues/3916 my workflow is now broken. Is there any chance we can move this PR forward?

zaibon avatar May 07 '25 09:05 zaibon

@prog8 I'm currently experimenting with versioned schemas as maintained by pgroll. In this scenario, pgroll maintains a secret schema containing the columns used by multiple schema versions, and then exposes a schema called (for example) version_a containing only views, and another schema called version_b containing only views.

Now, I'd like to run sqlc generate specifically on the version_b schema. For this, it's necessary to pass it through sqlc in a way other than the config file. I think it makes sense to use environment variables for this, just like with the database URL - in fact, we could even take the schema_version parameter from the database URL. I think this might make more sense than putting the schema version in the config file (or perhaps we could support both). What do you think about this?

See https://github.com/sqlc-dev/sqlc/pull/3668 for a first, brute-force attempt at this, which does work.

sgielen avatar May 26 '25 22:05 sgielen