External relationships #549
Replies: 2 comments 3 replies
-
If I understand correctly, you want to reference "externally generated models".
This is likely a bug. Can you raise an issue with a minimal reproduction?
At the moment, this may be the best thing to do. |
Beta Was this translation helpful? Give feedback.
-
It is likely possible to write a generator using Bob and goose. You can take |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm sorry for the influx of questions - I'm happy to add a PR to add what I've asked to the docs if it helps other people in the future 🙏
Currently, I have different 'domains' in a monolith, but many of the DB tables in each domain reference my apps's 'core' tables via. FK relationships.
I've split generation out so that each separate domain generates its own models, views, etc. by just running migrations for the tables I need. However, I noticed that the references back to the core tables wren't generated (because the core tables don't exist).
If I instead run all my 'core' migrations as well as the domain's migration, it instead generates new instances of my core tables's models, views, and all of the other helpers. I also tried excluding the tables with
except
but they are always generated (Which I can understand as they're referenced by another table/model).For example, if I have an
accounts
table in my core, and then reference this via. a FK relationship, each domain gets its own copy ofAccount
struct (and all of the other generated helpers).Instead, I wonder if it would be possible to declare an external relationship, similar to how the
types
section works inbobgen.yml
, so that we can choose an import path instead of generating new models. I believe this would still work as all of the child properties are provided by the child model/table/view, and missing models would be detected at compile-time.As an aside, I'm using the SQLite plugin directly because my migrations are using goose and due to the format of the SQL file, if I use the SQL files plugin, I end up with no tables, eg.
Beta Was this translation helpful? Give feedback.
All reactions