Apply or revert migrations for PostgreSQL.
npx pgmcli -h
npm i -g pgmcli
yarn global add pgmcli
Usage: pgmcli install [options]
creates a migrations table, a directory and a config file
Options:
--host <string> postgres host (default: "localhost")
--port <number> postgers port (default: 5432)
-u, --user <string> postgres user (default: "postgres")
-p, --password <string> postgers password
--db <name> database name
--dir <name> migrations directory (default: "migrations")
--table <name> migrations table (default: "migrations")
--config <path> config path (default: ".pgmcli")
-h, --help display help for command
Usage: pgmcli uninstall [options]
drops a migrations table
Options:
--host <string> postgres host (default: "localhost")
--port <number> postgers port (default: 5432)
-u, --user <string> postgres user (default: "postgres")
-p, --password <string> postgers password
--db <name> database name
--dir <name> migrations directory (default: "migrations")
--table <name> migrations table (default: "migrations")
--config <path> config path (default: ".pgmcli")
-h, --help display help for command
Usage: pgmcli create [options]
creates a migration
Options:
--name <name> migration file name (.ts, .js, .cjs, .mjs, .mts, .sql)
--plan show plan
--dir <name> migrations directory (default: "migrations")
--tag <tag> tag where revert block begins (default: "REVERT BEGIN")
--config <path> config path
-h, --help display help for command
Usage: pgmcli status [options]
shows statuses of migrations
Options:
--host <string> postgres host (default: "localhost")
--port <number> postgers port (default: 5432)
-u, --user <string> postgres user (default: "postgres")
-p, --password <string> postgers password
--db <name> database name
--dir <name> migrations directory (default: "migrations")
--table <name> migrations table (default: "migrations")
--config <path> config path (default: ".pgmcli")
-h, --help display help for command
Usage: pgmcli apply [options]
applies migrations
Options:
--host <string> postgres host (default: "localhost")
--port <number> postgers port (default: 5432)
-u, --user <string> postgres user (default: "postgres")
-p, --password <string> postgers password
--db <name> database name
--dir <name> migrations directory (default: "migrations")
--table <name> migrations table (default: "migrations")
--config <path> config path (default: ".pgmcli")
-n <number> apply "n" pending migrations (default: null)
--plan show plan
--log-level <level> log level (choices: "DEBUG", "LOG", "INFO", "NOTICE", "WARNING", "ERROR", default: "log")
--meta <jsonb> extra meta associated with apply
--tag <name> tag where apply block ends (default: "REVERT BEGIN")
-h, --help display help for command
Usage: pgmcli revert [options]
reverts migrations
Options:
--host <string> postgres host (default: "localhost")
--port <number> postgers port (default: 5432)
-u, --user <string> postgres user (default: "postgres")
-p, --password <string> postgers password
--db <name> database name
--dir <name> migrations directory (default: "migrations")
--table <name> migrations table (default: "migrations")
--config <path> config path (default: ".pgmcli")
-n <number> revert "n" applied migrations (default: 1)
--plan show plan
--log-level <level> log level (choices: "DEBUG", "LOG", "INFO", "NOTICE", "WARNING", "ERROR", default: "log")
--tag <name> tag where revert block begins (default: "REVERT BEGIN")
-h, --help display help for command