migrations

command
v0.0.0-...-a6ef0dd Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: MIT Imports: 5 Imported by: 0

README

Migrations

Currently, this project's DB migration is using go-pg/migrations. You can take a look at its repo to learn more about it.

Running Migrations

List of main commands to run migrations, run it on this directory:

  • go run *.go up: runs all available migrations
  • go run *.go up [version-target]: runs available migrations up to the target one
  • go run *.go down: reverts last migration
  • go run *.go reset: reverts all migration
  • go run *.go version: checks current db version

For full commands check out the original library's guide here.

Writing Migrations

For 1 migration, you should create 2 SQL files for the migration-up and migration-down. Follow these filename formats:

  • [dbversion]_[migration_name].up.sql: for up migration (eg. 1_create_table_items.up.sqll)
  • [dbversion]_[migration_name].down.sql: for down migration (eg. 1_create_table.down.sql)

Reference

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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