Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(sugar *zap.SugaredLogger, url string) *pgx.Conn
func RunMigrations ¶
func RunMigrations(conn *pgx.Conn, sugar *zap.SugaredLogger) error
RunMigrations ensures all the defined migrations have been run against the given pg connection - Creates the migrations table if needed - Finds any existing migrations - Runs any migrations which are missing, updating the migrations table
This function is idempotent, subsequent calls against the same connection are safe.
Types ¶
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
A migration represents a one-time SQL query that is run on application startup to alter the schema of the database. On application start, we check for un-executed migrations and run them one at a time. This ensures our database schema matches our code.
Once a migration has been defined, it should never be deleted to preserve compatiblity with any systems which have applied that migration. Instead, just append a new migration to the list.