ariga / atlas-provider-gorm

GORM Provider for https://atlasgo.io
Apache License 2.0
55 stars 14 forks source link

gormschema: support customize JoinTable #40

Closed luantranminh closed 6 months ago

luantranminh commented 7 months ago

Fix #39

luantranminh commented 7 months ago

@ronenlu 👀 Could you have a look? Happy to discuss more

ronenlu commented 7 months ago

@ronenlu 👀 Could you have a look? Happy to discuss more

@luantranminh Thank you for your contribution! I will review the PR soon

luantranminh commented 7 months ago

Looking at the unit test at the moment, the CREATE CONSTRAINT is not in the desired order, and it's also different when I run the test on my machine. 🏃‍♂️

luantranminh commented 7 months ago

I found interesting stuff here. GORM stores table relationships inside a Map. Looping through a Map is not guaranteed to produce the same order all the time.

https://github.com/go-gorm/gorm/blob/8c18714462de07fa3392b99eda089f2f9e3b6042/schema/schema.go#L186 image

We're looping through it here: https://github.com/ariga/atlas-provider-gorm/blob/e5d6dbfb61aaf99a784b5f8641a8bcace527f1e7/gormschema/gorm.go#L147

Resulting SQL statements output could be different each time the CI runs It hurts our tests, but the migration files are fine. I'll submit another commit to sort the Relations out before looping.

luantranminh commented 7 months ago

Ronen said the forked project is missing Secrets to run the integration tests image

giautm commented 7 months ago

Ronen said the forked project is missing Secrets to run the integration tests image

Yes, because the repo's secret doesn't share with the forked repository.