@ttoss/postgresdb-cli
v0.1.4
Published
A library to handle PostgreSQL database actions through the command line
Downloads
34
Readme
@ttoss/postgresdb-cli
This package provides a CLI to interact with a PostgreSQL database using the sequelize library.
Installation
pnpm add -D @ttoss/postgresdb-cli
Usage
First, you need to create define the db
object in your project using the @ttoss/postgresdb
package. Check @ttoss/postgresdb documentation for more information. The CLI will use this object to load the models and interact with the database.
Second, you need to define the following environment variables to connect to the database:
DB_NAME
: database nameDB_USERNAME
: database usernameDB_PASSWORD
: database passwordDB_HOST
: database hostDB_PORT
: database port. Default: 5432
Sync
To sync the database schema with the models, you can use the sync
command:
pnpm dlx @ttoss/postgresdb-cli sync
Options
--db-path
or-d
: Path to the file where thedb
object is defined. Default:./src/db.js
.--alter
: Alter the database schema to match the models. Default:false
.
ERD (Entity-Relationship Diagram)
To generate an ERD of the database, you can use the erd
command:
pnpm dlx @ttoss/postgresdb-cli erd
Options
--db-path
or-d
: Path to the file where thedb
object is defined. Default:./src/db.js
.