migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package migrations provides database migration support for Romancy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DriverType

type DriverType string

DriverType represents the database driver type.

const (
	// DriverSQLite represents SQLite database.
	DriverSQLite DriverType = "sqlite"
	// DriverPostgres represents PostgreSQL database.
	DriverPostgres DriverType = "postgres"
	// DriverMySQL represents MySQL database.
	DriverMySQL DriverType = "mysql"
)

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator handles database migrations.

func NewMigrator

func NewMigrator(db *sql.DB, driverType DriverType) *Migrator

NewMigrator creates a new Migrator instance.

func (*Migrator) Down

func (m *Migrator) Down() error

Down rolls back all migrations.

func (*Migrator) Force

func (m *Migrator) Force(version int) error

Force sets the migration version without running migrations. Use with caution - this is primarily for handling existing databases.

func (*Migrator) Steps

func (m *Migrator) Steps(n int) error

Steps runs n migrations (positive = up, negative = down).

func (*Migrator) Up

func (m *Migrator) Up() error

Up runs all pending migrations. Note: We intentionally don't call migrator.Close() here because it closes the underlying database connection, which we need to keep open.

func (*Migrator) Version

func (m *Migrator) Version() (version uint, dirty bool, err error)

Version returns the current migration version. Returns (version, dirty, error).

Directories

Path Synopsis
Package mysql provides embedded MySQL migrations.
Package mysql provides embedded MySQL migrations.
Package postgres provides embedded PostgreSQL migrations.
Package postgres provides embedded PostgreSQL migrations.
Package sqlite provides embedded SQLite migrations.
Package sqlite provides embedded SQLite migrations.

Jump to

Keyboard shortcuts

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