Show HN: GoSMig – minimal, type-safe SQL migrations written in Go

github.com

7 points by padurean 14 hours ago

I built GoSMig for my own projects and open-sourced it in case it helps others. It’s a tiny generic library (no external deps except golang.org/x/term) for writing SQL migrations in Go with compile-time checks.

It supports transactional and non-transactional migrations, rollback, status, version, and a small CLI handler so you can ship your own migration binary.

Why another migrator?

- Minimal API, no DSL or file layout to learn

- Type-safe via Go generics

- Works with database/sql and sqlx out of the box

- Should work with any db library (or wrapper) that implements some generic interfaces (see the "Core Types" section here https://github.com/padurean/gosmig?tab=readme-ov-file#core-t...)

- Tested with PostgreSQL, should work with any SQL RDBMS (MySQL, SQLite, MS SQL Server, ...)

Repo: https://github.com/padurean/gosmig

Docs & examples: README + examples branch https://github.com/padurean/gosmig/tree/examples

Would love feedback: ergonomics, missing guardrails, API rough edges, and real-world gotchas, etc.