Skip to content

Tools for connecting to, and working with an SQL database.

License

Notifications You must be signed in to change notification settings

LUSHDigital/core-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Go Report Card Build Status GoDoc

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

Use in conjunction with readysrv

database := 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 up
  • migrate down: attempt to migrate down
_, migrations := coresql.MustOpenWithMigrations("mysql", "tcp(localhost:3306)/mydb", "file://path/to/migrations")
coresql.HandleMigrationArgs(migrations)