simplemigrate

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 6 Imported by: 0

README ΒΆ

simple-migrate

Migrations in a couple of clicks. You will need a 'versions' table, a sample is given in the project directory.

Usage:

  // create db connection (*sql.DB)..
  // conn := ...

  handler := simplemigrate.NewMigrationHandler(simplemigrate.MigrationTask{
		ScriptsDir: "./migrations/",
		DBDriver:   conn,
		DBName:     "mydb",
	})
	err := handler.Run()
  if err != nil {
    // handle error
  }

The 'migrations' folder should contain the ".sql" files with the migrations. For example:

000_tables.sql
001_modify_users.sql
002_add_counter.sql

image

🌐 Telegram канал

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type MigrationHandler ΒΆ

type MigrationHandler struct {
	Data MigrationTask
}

MigrationHandler - migration handler

func NewMigrationHandler ΒΆ

func NewMigrationHandler(task MigrationTask) *MigrationHandler

NewMigrationHandler - create new migration handler. dir with slash. for example: ./migrations/

func (*MigrationHandler) Run ΒΆ

func (m *MigrationHandler) Run() error

Run migrations

type MigrationTask ΒΆ

type MigrationTask struct {
	ScriptsDir string
	DBDriver   *sql.DB
	DBName     string
}

MigrationTask - migration task data container

Jump to

Keyboard shortcuts

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