migrant

package module
v0.0.0-...-72f8fe2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: GPL-3.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Migrant

Small database migration tool for PostgreSQL similar to Flyway for Java/Kotlin.

How to use

package main

import (
	"github.com/oberning/migrant"
)

func main() {
	db := migrant.Config{ // (1)
		Url:          "postgres://postgres:postgres@localhost:5432/migration_test", // (2)
		FileLocation: "./cmd/example/testdata", // (3)
	}
	db.Migrate() // (4)
}
  1. Define the Config struct
  2. Connection string for the PostgreSQL database. The library github.com/jackc/pgx/v4 is used.
  3. The folder that contains the migration files. Because the SQL files are read in the order as per naturally sorted filenames. See ./cmd/example/testdata for an example. The files in that folder are read in that order: v1_*, v2_*, v10_*, v11_*.
  4. That line finally executes the migration.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FileLocation string
	Url          string
	TableName    string
}

func (*Config) Migrate

func (conf *Config) Migrate()

type DbConnection

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

type File

type File struct {
	FileName string
	Checksum string
}

Directories

Path Synopsis
cmd
example command

Jump to

Keyboard shortcuts

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