database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateVersionTableSQL = `` /* 173-byte string literal not displayed */

	CreateHistoryTableSQL = `` /* 191-byte string literal not displayed */

)

Constants for the SQL statements to create the migration tables

Variables

This section is empty.

Functions

func Connect

func Connect(cfg *config.Config) (*sql.DB, error)

Connect establishes a connection to the PostgreSQL database

func InitializeTables

func InitializeTables(db *sql.DB) error

InitializeTables creates the necessary migration tables if they don't exist

func RecordHistory

func RecordHistory(db *sql.DB, version string, sqlContent string, tx *sql.Tx) error

RecordHistory records an entry in the migration history with the SQL content

func RecordMigration

func RecordMigration(db *sql.DB, version string, tx *sql.Tx) error

RecordMigration records a successfully applied migration

Types

type MigrationVersion

type MigrationVersion struct {
	ID        int
	Version   string
	AppliedAt time.Time
}

MigrationVersion represents a record in the mig_versions table

func GetAppliedMigrations

func GetAppliedMigrations(db *sql.DB) ([]MigrationVersion, error)

GetAppliedMigrations retrieves all applied migrations

Jump to

Keyboard shortcuts

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