Closed karolis-arbaciauskas closed 12 months ago
Hi @karolis-arbaciauskas
Thanks for working on this. I think the solution will be more robust and support more usecases if the gormschema constructor just accepts a
gorm.Config{}
. This will enable users to use this tool with any possible GORM configuration.To make the API more aesthetic, we can use something similar to https://golang.cafe/blog/golang-functional-options-pattern.html
Thanks @rotemtam for the suggestions. I have updated the PR according to your recommendations.
@rotemtam @a8m 👋 Would it be possible for you to review the pull request sometime soon?
Issue
The proposed changes allow passing configuration to gorschema as a second argument. Currently, it is only possible to set one argument, DisableMigrationForeignKeyConstraint, as a boolean. This will disable foreign key constraints when creating migrations. Platforms like The PlanetScale, which uses Vitess behind the scenes, does not support foreign key constraints. For more information on this topic, please refer to the following link: https://planetscale.com/docs/learn/operating-without-foreign-key-constraints.
To disable foreign key constraints in the migrations, you can configure Atlas config or code.
When used as a Go file, use the following code: