Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Migrations (Even with GORM) #23

Open
jacobconley opened this issue Jun 13, 2021 · 2 comments
Open

DB Migrations (Even with GORM) #23

jacobconley opened this issue Jun 13, 2021 · 2 comments
Labels
deferred Specific use cases that will be implemented once someone needs them question Further information is requested

Comments

@jacobconley
Copy link
Owner

jacobconley commented Jun 13, 2021

Gorm's approach

Gorm has the auto migrator, which is quite different from the traditional solution.

Pros:

  • Doesn't really need anything other than the model
  • The user deals with it themselves - we really don't have to do anything. Though that calls into question whether we should even make the ORM a part of this project at all. Having an existential crisis here

Foreign key constraints can be made explicit manually - it's a lil clunky but par for the course

Cons:

  • No rollbacks or schema output out of the box
  • User has to configure migrations in code instead of being able to use the existing configurations and just run a simple cli command
  • Kinda scary I think!

Alternatives

I could do some sketchy reflection nonsense to make some sort of configurable automigrate command. Gotta look more into what I can configure as strings via reflection

Traditional migrations

  • gormigrate - golang migrations, but admits it's not quite as ready to scale
  • golang-migrate - SQL migrations in another implementation
  • But at this point why not stick with Soda? Already implemented, supports the SQL migrations ^ plus Fizz if you want it. All we would have to do is implement the migrations table

Fizz

Pros

  • less of a pain in the arse than defining them in golang

Cons

  • kinda niche thing. but it's wholly optional anyways AND supports embedded SQL
  • not as beautiful as it could be! but maybe we can make our own some day
@jacobconley jacobconley added the question Further information is requested label Jun 13, 2021
@jacobconley
Copy link
Owner Author

jacobconley commented Jun 13, 2021

Doesn't seem to be a way to get a reflection type from a name as string. Probably for the better. We could do some wacky codegen from the TOML config nonetheless? Gets more and more suspect the more I think about it.

More or less three options right now:

  • Ignore altogether, perhaps dropping the ORM feature from the project entirely
    • I reckon for GORM auto-migrate, the user just writes a migrate.go for themselves
  • Keep our current wrapper around Soda, maybe expand on it
  • Making our own automigrate with the above nonsense

I suppose we can keep going with Soda, bearing in mind we may scrap it altogether - though probably unlikely. We can just build onto the codegen replacing Genny, and perhaps we end up going more into that third option

@jacobconley
Copy link
Owner Author

How will it work for middleware type things, like a CMS that needs to update? Probably want defined SQL-ish migrations instead of automatic migrations right? I mean how would you even trigger automatic ones

@jacobconley jacobconley added the deferred Specific use cases that will be implemented once someone needs them label Jun 19, 2021
@jacobconley jacobconley changed the title Migrations DB Migrations (Even with GORM) Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deferred Specific use cases that will be implemented once someone needs them question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant