I have one database in postgres with many schemas and I would like uses gorm.
do you think it'd be possible to change gorm so that it takes the schemes postgres ?
You should be able to use gorm with this already. You just need to declare your models. You can test by using the db.HasTable(&ModelName{})
@dlundergreen Can you provide an example of this? What if there are two tables in separate schemas that share the same name? I'm not sure how to apply your answer.
I didn't understand his solution, but I use the method TableName() now.
Example:
type Address struct {
Id uint64 gorm:"primary_key"
CustomerId uint64 sql:"index:idx_addres_customerid""
Street string
}
func (Address) TableName() string {
return "customer.Address"
}
yes, the table name method should works.
Most helpful comment
I didn't understand his solution, but I use the method TableName() now.
Example:
type Address struct {
Id uint64
gorm:"primary_key"CustomerId uint64
sql:"index:idx_addres_customerid""Street string
}
func (Address) TableName() string {
return "customer.Address"
}