Manage postgresql cluster migration easly
-
Postgresql 9.5 or above
-
Go 1.16 or above
-
pg_dump
(optional) to support reverse migration
-
Support multiple connections and schemas
-
Reverse migration from existing database
-
Auto clean dirty migration
-
And many more
-
Install
go install github.com/ad3n/kmt/v2@latest
to installkmt
into$GOBIN
-
Check using
kmt help
-
Clone repository
git clone github.com/ad3n/kmt
-
Run
go build -o kmt
-
Check using
./kmt help
- Run
kmt upgrade
to upgrade to lastest version
-
kmt create <schema> <name>
to create new migration file -
kmt up <db> <schema>
to deploy migration(s) from database and schema -
kmt down <db> <schema>
to drop migration(s) from database and schema -
kmt generate <schema>
to reverse migration from yoursource
database -
kmt rollback <db> <schema> <step>
to rollback migration version from database and schema -
kmt run <db> <schema> <step>
to run migration version from database and schema -
kmt sync <cluster> <schema>
to sync migration in cluster for schema -
kmt set <db> <schema>
to set migration to specific version -
kmt clean <db> <schema>
to clean migration on database and schema -
kmt version <db> <schema>
to show migration version on database and schema -
kmt compare <db1> <db2>
to compare migration from databases -
kmt inspect <table> <schema> <db1> [<db2>]
to inspect table on specific schema -
kmt make <schema> <source> <destination>
to makeschema
ondestination
has same version with thesource
-
kmt test
to test configuration -
kmt upgrade
to upgrade cli -
kmt about
to show version
Run kmt help
for complete commands
-
Create new project folder
-
Copy Kmtfile.yml below
version: 1.0
migration:
pg_dump: /usr/bin/pg_dump
folder: migrations
source: default
clusters:
local: [local]
connections:
default:
host: default
port: 5432
name: database
user: user
password: s3cret
local:
host: localhost
port: 5432
name: database
user: user
password: s3cret
schemas:
public:
excludes:
- exclude_tables
with_data:
- data_included_tables
user:
excludes:
- exclude_tables
with_data:
- data_included_tables
- Create new migration or generate from
source
- Migrate tables
- Migrate enums (UDT)
- Migrate functions
- Migrate views
- Migrate materialized views
- Show migration version
- Show State/Compare
- Upgrade Command
- Refactor Codes
- Table level comparison
- Dump sql for table comparison