Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.76 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.76 KB
a_cool_futuristic_hd_mascot_for_the

*Mascot Generated by MetaAI

MigrateX

A Database Migration Tool

A command-line tool for applying SQL migrations to a PostgreSQL database using Go and Cobra.

Features

  • Applies SQL migration files in order
  • Tracks applied migrations to ensure each is run only once
  • Configurable via command-line flags

Usage

Running Locally

Clone the repository, build the project, and run it:

go build -o migrate
./migrate --dbHost="localhost" --dbPort="5432" --dbUser="postgres" --dbPassword="password" --dbName="mydb" --migrationDir="./migrations" --sslMode="disable"

Command-Line Flags:

Flag Default Description
--dbHost localhost PostgreSQL host
--dbPort 5432 PostgreSQL port
--dbUser postgres PostgreSQL user
--dbPassword password PostgreSQL password
--dbName postgres PostgreSQL database name
--migrationDir migrations Path to the migration files directory
--sslMode disable SSL Mode

Running with Docker

Build the Docker image and run the container:

docker build -t db-migration-tool .
docker run --rm \
  -e DB_HOST="localhost" \
  -e DB_PORT="5432" \
  -e DB_USER="postgres" \
  -e DB_PASSWORD="password" \
  -e DB_NAME="mydb" \
  -v /path/to/migrations:/migrations \
  db-migration-tool