migrate

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package migrate embeds ulinzilib-go's "security"-schema goose migrations and applies them to a PostgreSQL database.

It is an OPTIONAL, standalone package. The core packages (ulinzi and its postgres adapter) import neither embed nor goose, so nothing on the request path links a migration tool. Import this package ONLY from your migrator entrypoint (a dedicated cmd/migrate binary, or a one-shot step at startup) — never from a request handler.

Schema ownership: this library OWNS the "security" schema (a faithful port of the .NET security library InitialSecuritySchema), so it ships the schema's migrations with the code that depends on them. Your application still owns its OWN (app) schema and decides WHEN these run relative to its own migrations.

In the shared-DB unified-SSO deployment the .NET service owns the schema instead — do NOT run these migrations there (goose and EF Core must not both own one schema).

The caller supplies a *sql.DB and is responsible for registering a driver, e.g. a blank import of github.com/jackc/pgx/v5/stdlib (driver name "pgx").

import (
    "database/sql"
    _ "github.com/jackc/pgx/v5/stdlib"
    "github.com/Cyrus-0101/ulinzilib-go/migrate"
)

db, _ := sql.Open("pgx", os.Getenv("DATABASE_URL"))
defer db.Close()
if err := migrate.Up(db); err != nil { log.Fatal(err) }

Index

Constants

This section is empty.

Variables

FS holds the embedded "security"-schema migration files (goose SQL). It is exported so callers who prefer their own tooling can read the .sql directly (e.g. via io/fs); the files live under the "migrations" directory.

Functions

func Down

func Down(db *sql.DB) error

Down rolls back the most recently applied migration.

func Reset

func Reset(db *sql.DB) error

Reset rolls back every applied migration. Intended for tests/dev only.

func Status

func Status(db *sql.DB) error

Status prints the migration status of the database to stdout.

func Up

func Up(db *sql.DB) error

Up applies all pending "security"-schema migrations.

func Version

func Version(db *sql.DB) error

Version prints the current migration version of the database to stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL