Repository navigation
Export models to a different package #835
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Activity
We just tried this out at our company, for context we are using go-migrate so we have a single folder with all of our database migrations. Without a feature like this the, otherwise excellent sqlc, isn't a viable option for us.
As it stands (unless I've missed some configuration?) each generated package has a
models.gofile containing all models from our entire database.Having an option to decide where to generate the models file, and read from it on the subsequent generated packages OR being able to remove unused models would be a much needed feature.
I see this has been left untouched since 2020, is there anything I can do to help speed this along?
Reacted by afi, Marek Mierzwa, Leo Palmer Sunmo and Olkhovyk MykytaReacted by Alefew Yimam, Leo Palmer Sunmo and Olkhovyk Mykyta+1
Still waiting for this at the end of 2024 😊
Reacted by Leo Palmer Sunmo, Esequiel Albornoz, Tales M Godois, Gerard, Dmitry Vashchilov, Dmitry Chumak, Tomochika Hara, Tord, Olkhovyk Mykyta, Berk Karaal and 5 moreUp
- added a commit that references this issue
on Apr 30, 2026 What do people think of this?
- added a commit that references this issue
on May 5, 2026 Fixed here #4421
Reacted by Crows
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fields🛳 Shipped
Hi! Great work on this project!
I was wondering if it's currently possible to export Go model structs to a different folder package.
I think this could be a good feature for anyone who would like to make their code independent of the database backend but still use the automatically generated models.
For example:
This way you could e.g. also have a mongodb provider that uses these models, but without depending on the
postgrespackage. I'm sure you'd agree that it would be odd for mongo to usepostgres.Useras a type.Is this something that's possible to do? If not, would you possibly accept a PR that adds support for it? Or it it something you're not planning on supporting for now?
Thanks