GoLang - Working with databases

Migrations

Migrating tables, column names and any other changes related to the data model:

  1. https://github.com/golang-migrate/migrate
  2. Gorm Automigrate

Basic example without using GORM

  1. https://go.dev/doc/tutorial/database-access

Bob

https://github.com/stephenafamo/bob

GORM

  1. https://gorm.io/docs/
  2. https://gorm.io/docs/migration.html
  3. GORM Essentials: Preload vs. Join - When to Use Each? https://www.youtube.com/watch?v=DX8j0GioKjY
  4. https://gorm.io/docs/preload.html

Gorm Automigrate

  1. https://gorm.io/docs/migration.html

  2. 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

  1. https://www.reddit.com/r/golang/comments/176k9b7/best_query_builder_you_have_used_so_far/
  2. https://www.reddit.com/r/golang/comments/9p6dx2/how_does_everyone_do_database_migrations/
  3. https://www.reddit.com/r/golang/comments/eght6s/how_to_createmanagemigrateupgrade_databases_with/
  4. https://dev.to/techschoolguru/generate-crud-golang-code-from-sql-and-compare-db-sql-gorm-sqlx-sqlc-560j
  5. Do POCs with Bob and Gorm.