Open aq1018 opened 4 months ago
Yeah, I expected that I would run into this sooner or later. The quick solution would probably be to support adding schema names as a prefix to model names, but I think few people would like that. The more correct solution would be that it intelligently detects the name clash and does something like
import type { ProductId as TermLifeProductId } from '../term_life/Product';
import type { ProductId as IncomeProtectionProductId } from '../income_protection/Product';
This should be possible but it's obviously not completely trivial. I will ponder this :-)
I'm currently using multiple schemas as namespaces.
For example, I have the following database design:
term_life
schema, I have aproduct
table.income_protection
schema, I have aproduct
table as well, but with different columns.public
schema, I have ainsurance_application
table that contains foreign keys referencing both products.term_life_product_id
referencingterm_life.product.id
.income_protection_product_id
referencingincome_protection.prodcut.id
The generated code looked like this:
I made a
preRenderHook
to fix this, but it's a bit hacky:I'm not sure what the best solution entails, but the generated code should not create conflicting imports.