GoLang - Working with databases
Table of Contents
Migrations
Migrating tables, column names and any other changes related to the data model:
- https://github.com/golang-migrate/migrate
- Gorm Automigrate
Basic example without using GORM
Bob
https://github.com/stephenafamo/bob
GORM
- https://gorm.io/docs/
- https://gorm.io/docs/migration.html
- GORM Essentials: Preload vs. Join - When to Use Each? https://www.youtube.com/watch?v=DX8j0GioKjY
- https://gorm.io/docs/preload.html
Gorm Automigrate
-
When is right time to run Automigrate with GORM?
https://stackoverflow.com/questions/75000424/when-is-right-time-to-run-automigrate-with-gorm
It’d happen every time the application is started, so basically: connect to the DB in main, and run AutoMigrate there. Pass the connection as a dependency to your handlers/service packages/wherever you need them. The HTTP handler can just access it there.
TODO
- https://www.reddit.com/r/golang/comments/176k9b7/best_query_builder_you_have_used_so_far/
- https://www.reddit.com/r/golang/comments/9p6dx2/how_does_everyone_do_database_migrations/
- https://www.reddit.com/r/golang/comments/eght6s/how_to_createmanagemigrateupgrade_databases_with/
- https://dev.to/techschoolguru/generate-crud-golang-code-from-sql-and-compare-db-sql-gorm-sqlx-sqlc-560j
- Do POCs with Bob and Gorm.