stupidmigration

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 10 Imported by: 3

README

stupidmigration

a stupid migration tool for Go, aimed at postgresql. only up, no down

here's a handy bash script to generate a migration

#!/bin/bash

RELATIVE_PATH=$(dirname $0)

if [ -z $1 ]; then
    echo "usage: $0 description-of-migration"
    exit 1
fi

touch "$RELATIVE_PATH/$(date --utc '+%s')-$1.sql"

usage

func main() {
	db, err := sql.Open("postgres", "postgres:///database_name?sslmode=disable")
	if err != nil {
		log.Fatal(err)
	}

	err = stupidmigration.Migrate("../../migrations", db)
	if err != nil {
		log.Fatal("Error running migrations:", err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(migrationsPath string, db *sql.DB) error

Migrate attempts to load all migrations from migrationsPath and apply them to the given db

Types

This section is empty.

Jump to

Keyboard shortcuts

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