dbmigrate

command module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

DB Migrate

This is command line utility to manage database migrations. This is developed for specific need where we have manage seprate migrations for diffrent schemas.

Basic Rules for writing migration files

  • Folders in which sql files exsists is treated as schema name. If the schema does not exist it is created so the user should have permission to create the schema and also table.
  • Only one level deep folders are checked.
  • Every migration should have up and down scripts.
  • The file name of the migration should be like < VersionNumber >-< Purpose >.{up/down}.sql Version Number should be integer, Purpose is a String without "-" or white spaces. It is recommended not to use any special chararecters in the file names. Sample: 05-AddUser.up.sql,05-AddUser.down.sql

To Test

  • checkout this project
  • run go install in the project.
  • Keep the Database URL handy.
  • create a directory with names as specified above.(A sample folder is found in this repo)
  • Go the sample folder
  • Run the following command to Upgrade the database.
DB_URL=postgres://postgres:postgres@localhost:5432/test DB_MIGRATION_DIR=./migrations dbmigrate up

To Release

You need to have goreleaser installed on your machine export GITHUB_TOKEN=YOUR_GH_TOKEN git tag -a v0.1.5 -m "DB SSL Setup" git push origin v0.1.5 goreleaser

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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