Core SQL
This package is used to wrap the SQL standard library to satisfy the health checking server in the LUSH core service library. We use golang-migrate/migrate version 4 for migrations and treats it as a direct dependency.
Examples
readysrv
Use in conjunction withdatabase := coresql.MustOpen("mysql", "tcp(localhost:3306)/mydb")
readysrv.New(readysrv.Checks{
"mysql": database,
})
Ensure database is migrated up
_, migrations := coresql.MustOpenWithMigrations("mysql", "tcp(localhost:3306)/mydb", "file://path/to/migrations")
coresql.MustMigrateUp(migrations)
Handle migration arguments
You can force your application to respect migration command line arguments:
migrate up
: attempt to migrate upmigrate down
: attempt to migrate down
_, migrations := coresql.MustOpenWithMigrations("mysql", "tcp(localhost:3306)/mydb", "file://path/to/migrations")
coresql.HandleMigrationArgs(migrations)