LinuxCommandLibrary

typeorm

TypeORM database migration and entity CLI

TLDR

Initialize project

$ typeorm init
copy
Generate migration
$ typeorm migration:generate -n [MigrationName]
copy
Run migrations
$ typeorm migration:run
copy
Revert migration
$ typeorm migration:revert
copy
Create entity
$ typeorm entity:create -n [EntityName]
copy
Sync schema
$ typeorm schema:sync
copy

SYNOPSIS

typeorm command [-n name] [options]

DESCRIPTION

typeorm is the command-line interface for TypeORM, a TypeScript and JavaScript ORM that supports PostgreSQL, MySQL, SQLite, and other databases. It provides tools for managing database migrations, generating entity scaffolds, and synchronizing schema changes.
Migrations track database schema changes as versioned files that can be applied and reverted. The migration:generate command automatically creates migration files by comparing the current entities to the database state. Schema sync provides a simpler alternative that directly updates the database to match entity definitions.
The CLI also supports initializing new projects with boilerplate configuration and entity files.

PARAMETERS

init

Initialize project.
migration:generate
Generate migration.
migration:run
Run migrations.
migration:revert
Revert last.
entity:create
Create entity.
schema:sync
Sync database.

CAVEATS

TypeScript/Node.js. Config file needed. Database connection required.

HISTORY

TypeORM is an ORM for TypeScript and JavaScript, with the CLI providing database management operations.

SEE ALSO

prisma(1), knex(1), sequelize(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community