Commands and usage
In this section, we will consider all the commands that are implemented in ORM-CLI
ORM-CLI (Command Line Interface) provides a convenient interface for interacting with my ORM system through the command line. It allows you to quickly perform key database operations such as creating migrations, running migrations, and initializing the ORM.
This CLI is designed to work correctly with migrations. To ensure that your changes are saved properly, you need to run the command npm run start
(or another command to start your application) every time you make changes. After running this command, the changes you made in the ORM—such as tables, triggers, indexes, and so on—will be saved in the migrations
table. This enables effective automatic migration creation based on the modified code.
I will provide more details about working with migrations in the next section Міграції
Command Line Interface (CLI) for ORM:
Initialize ORM:
The --init
command initializes the ORM by creating the necessary configurations and structure for further database operations.
Create a Migration:
The --migration:create
command creates a new migration with the specified name. For example, orm-cli --migration:create init
will create a migration named init
.
Create an Empty Migration:
The --empty
flag creates an empty migration that can be manually filled in. For example, orm-cli --empty --migration:create initial_schema
will create an empty migration named initial_schema
.
Apply a Specific Migration:
The --migration:up
command applies a specific migration with the given name. For example, orm-cli --migration:up init
will apply the migration named init
.
Rollback a Specific Migration:
The --migration:down
command rolls back a specific migration with the given name. For example, orm-cli --migration:down init
will roll back the migration named init
.
Apply All Pending Migrations:
The --migrate:up
command applies all pending migrations to the database.
Rollback All Applied Migrations:
The --migrate:down
command rolls back all applied migrations, returning the database to its initial state.
Example Usage:
This command will create an empty migration named delete_is_active_column
.
The ORM-CLI provides a straightforward way to manage your migrations and database configuration through a command-line interface, simplifying the development and testing process.
Last updated