Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunMigrations ¶
RunMigrations runs all pending database migrations using goose.
func TestLockAndReset ¶
TestLockAndReset acquires a PostgreSQL session-level advisory lock, resets the public schema, and runs migrations. The lock is held until release() is called. Use this in TestMain to serialize test packages that share a database:
func TestMain(m *testing.M) {
url := os.Getenv("DATABASE_URL")
if url == "" { os.Exit(m.Run()) }
release, err := db.TestLockAndReset(url)
if err != nil { log.Fatal(err) }
code := m.Run()
release()
os.Exit(code)
}
Types ¶
Click to show internal directories.
Click to hide internal directories.