diff --git a/README.md b/README.md index 94c3271..85dfe0d 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ It's effectively a successor of [klei-migrate](https://www.npmjs.com/package/kle Install the Emigrate CLI in your project: ```bash -npm install --save-dev @emigrate/cli +npm install @emigrate/cli # or -pnpm add --save-dev @emigrate/cli +pnpm add @emigrate/cli # or -yarn add --dev @emigrate/cli +yarn add @emigrate/cli # or -bun add --dev @emigrate/cli +bun add @emigrate/cli ``` ## Usage diff --git a/docs/src/content/docs/commands/list.mdx b/docs/src/content/docs/commands/list.mdx index cb05c16..7c79628 100644 --- a/docs/src/content/docs/commands/list.mdx +++ b/docs/src/content/docs/commands/list.mdx @@ -34,14 +34,21 @@ It then sorts the migrations by filename in ascending order and outputs them and bunx --bun emigrate list [options] ``` - - ```json {3} + + ```json title="package.json" {3,6} { "scripts": { - "emigrate": "emigrate list [options]" + "emigrate": "emigrate" + }, + "dependencies": { + "@emigrate/cli": "*" } } ``` + + ```bash + deno task emigrate list [options] + ``` diff --git a/docs/src/content/docs/commands/new.mdx b/docs/src/content/docs/commands/new.mdx index 18b97a8..a411b29 100644 --- a/docs/src/content/docs/commands/new.mdx +++ b/docs/src/content/docs/commands/new.mdx @@ -33,14 +33,21 @@ The migration file can be based on a template, generated by a - ```json {3} + + ```json title="package.json" {3,6} { "scripts": { - "emigrate": "emigrate new [options] " + "emigrate": "emigrate" + }, + "dependencies": { + "@emigrate/cli": "*" } } ``` + + ```bash + deno task emigrate new [options] + ``` diff --git a/docs/src/content/docs/commands/remove.mdx b/docs/src/content/docs/commands/remove.mdx index 600a1df..d1e8ebe 100644 --- a/docs/src/content/docs/commands/remove.mdx +++ b/docs/src/content/docs/commands/remove.mdx @@ -31,14 +31,21 @@ The `remove` command is used to remove a migration from the history. This is use bunx --bun emigrate remove [options] ``` - - ```json {3} + + ```json title="package.json" {3,6} { "scripts": { - "emigrate": "emigrate remove [options] " + "emigrate": "emigrate" + }, + "dependencies": { + "@emigrate/cli": "*" } } ``` + + ```bash + deno task emigrate remove [options] + ``` diff --git a/docs/src/content/docs/commands/up.mdx b/docs/src/content/docs/commands/up.mdx index 76d6683..3868217 100644 --- a/docs/src/content/docs/commands/up.mdx +++ b/docs/src/content/docs/commands/up.mdx @@ -36,14 +36,21 @@ If any of the migrations fail, the command will be aborted and the rest of the m bunx --bun emigrate up [options] ``` - - ```json {3} + + ```json title="package.json" {3,6} { "scripts": { - "emigrate": "emigrate up [options]" + "emigrate": "emigrate" + }, + "dependencies": { + "@emigrate/cli": "*" } } ``` + + ```bash + deno task emigrate up [options] + ``` diff --git a/docs/src/content/docs/intro/quick-start.mdx b/docs/src/content/docs/intro/quick-start.mdx index 77233c8..905e078 100644 --- a/docs/src/content/docs/intro/quick-start.mdx +++ b/docs/src/content/docs/intro/quick-start.mdx @@ -40,6 +40,18 @@ But for now, this is the way to go. bun add @emigrate/cli ``` + + ```json title="package.json" {3,6} + { + "scripts": { + "emigrate": "emigrate" + }, + "dependencies": { + "@emigrate/cli": "*" + } + } + ``` + ### Pick a storage plugin @@ -69,15 +81,57 @@ Install the plugin you want to use, for example the + ```json title="package.json" {4} + { + "dependencies": { + "@emigrate/cli": "*", + "@emigrate/postgres": "*" + } + } + ``` + ### Create your first migration Create a new migration file in your project using: -```bash title="Create a new migration file" -npx emigrate new --plugin postgres create users table -``` + + + ```bash title="Create a new migration file" + npx emigrate new --plugin postgres create users table + ``` + + + ```bash title="Create a new migration file" + pnpm emigrate new --plugin postgres create users table + ``` + + + ```bash title="Create a new migration file" + yarn emigrate new --plugin postgres create users table + ``` + + + ```bash title="Create a new migration file" + bunx --bun emigrate new --plugin postgres create users table + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash title="Create a new migration file" + deno task emigrate new --plugin postgres create users table + ``` + + ```txt title="Output" Emigrate new v0.10.0 /your/project/path @@ -119,9 +173,41 @@ There's no magic about the first line comment as when using Liquibase, it's just To show both pending and already applied migrations (or previously failed), use the `list` command: -```bash title="Show all migrations" -npx emigrate list --storage postgres -``` + + + ```bash title="Show all migrations" + npx emigrate list --storage postgres + ``` + + + ```bash title="Show all migrations" + pnpm emigrate list --storage postgres + ``` + + + ```bash title="Show all migrations" + yarn emigrate list --storage postgres + ``` + + + ```bash title="Show all migrations" + bunx --bun emigrate list --storage postgres + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash title="Show all migrations" + deno task emigrate list --storage postgres + ``` + + ```txt title="Example output" Emigrate list v0.10.0 /your/project/path @@ -137,9 +223,41 @@ Emigrate list v0.10.0 /your/project/path A good way to test your configuration is to run the migrations in dry mode: -```bash title="Show pending migrations" -npx emigrate up --storage postgres --plugin postgres --dry -``` + + + ```bash title="Show pending migrations" + npx emigrate up --storage postgres --plugin postgres --dry + ``` + + + ```bash title="Show pending migrations" + pnpm emigrate up --storage postgres --plugin postgres --dry + ``` + + + ```bash title="Show pending migrations" + yarn emigrate up --storage postgres --plugin postgres --dry + ``` + + + ```bash title="Show pending migrations" + bunx --bun emigrate up --storage postgres --plugin postgres --dry + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash title="Show pending migrations" + deno task emigrate up --storage postgres --plugin postgres --dry + ``` + + :::note This will connect to the database using some default values. For ways to configure the connection, see Configuration. diff --git a/docs/src/content/docs/intro/whats-emigrate.mdx b/docs/src/content/docs/intro/whats-emigrate.mdx index fc1a7bd..58ff0c5 100644 --- a/docs/src/content/docs/intro/whats-emigrate.mdx +++ b/docs/src/content/docs/intro/whats-emigrate.mdx @@ -8,7 +8,7 @@ import Link from '@components/Link.astro'; Emigrate is written in [TypeScript](https://www.typescriptlang.org) and is a migration tool for any database or data. * It's database agnostic - you can use it with any database, or even with non-database data. -* It can be run on multiple platforms - currently [NodeJS](https://nodejs.org) and [Bun](https://bun.sh) is supported, but more platforms is planned. +* It can be run on multiple platforms - currently [NodeJS](https://nodejs.org), [Bun](https://bun.sh) and [Deno](https://deno.com) is supported, but more platforms is planned. * It's the successor of [klei-migrate](https://github.com/klei/migrate) and is designed to be compatible with [Immigration](https://github.com/blakeembrey/node-immigration) and many of its storage plugins, as well as [Migrate](https://github.com/tj/node-migrate). * It supports migration files written using CommonJS or ES Modules out of the box, with any of the following extensions: `.js`, `.cjs` or `.mjs`, and supports [async functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function), [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or using the [NodeJS Callback Pattern](https://nodejs.org/en/learn/asynchronous-work/javascript-asynchronous-programming-and-callbacks#handling-errors-in-callbacks). * Other languages can be used by using a Loader Plugin. diff --git a/docs/src/content/docs/plugins/generators/js.mdx b/docs/src/content/docs/plugins/generators/js.mdx index 1e1fae2..b77c6be 100644 --- a/docs/src/content/docs/plugins/generators/js.mdx +++ b/docs/src/content/docs/plugins/generators/js.mdx @@ -30,12 +30,53 @@ A generator plugin for generating new m bun add @emigrate/plugin-generate-js ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/plugin-generate-js": "*" + } + } + ``` + ## Usage -```bash -emigrate new --plugin generate-js create some fancy table -``` + + + ```bash + npx emigrate new --plugin generate-js create some fancy table + ``` + + + ```bash + pnpm emigrate new --plugin generate-js create some fancy table + ``` + + + ```bash + yarn emigrate new --plugin generate-js create some fancy table + ``` + + + ```bash + bunx --bun emigrate new --plugin generate-js create some fancy table + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate new --plugin generate-js create some fancy table + ``` + + For more information see the `new` command's documentation. diff --git a/docs/src/content/docs/plugins/generators/mysql.mdx b/docs/src/content/docs/plugins/generators/mysql.mdx index 786fde0..d36e7d3 100644 --- a/docs/src/content/docs/plugins/generators/mysql.mdx +++ b/docs/src/content/docs/plugins/generators/mysql.mdx @@ -30,12 +30,53 @@ The MySQL generator creates new migration files with the `.sql` extension. In th bun add @emigrate/mysql ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/mysql": "*" + } + } + ``` + ## Usage -```bash -emigrate new --plugin mysql create some fancy table -``` + + + ```bash + npx emigrate new --plugin mysql create some fancy table + ``` + + + ```bash + pnpm emigrate new --plugin mysql create some fancy table + ``` + + + ```bash + yarn emigrate new --plugin mysql create some fancy table + ``` + + + ```bash + bunx --bun emigrate new --plugin mysql create some fancy table + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate new --plugin mysql create some fancy table + ``` + + For more information see the `new` command's documentation. diff --git a/docs/src/content/docs/plugins/generators/postgres.mdx b/docs/src/content/docs/plugins/generators/postgres.mdx index d6e670c..748c511 100644 --- a/docs/src/content/docs/plugins/generators/postgres.mdx +++ b/docs/src/content/docs/plugins/generators/postgres.mdx @@ -30,12 +30,53 @@ The PostgreSQL generator creates new migration files with the `.sql` extension. bun add @emigrate/postgres ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/postgres": "*" + } + } + ``` + ## Usage -```bash -emigrate new --plugin postgres create some fancy table -``` + + + ```bash + npx emigrate new --plugin postgres create some fancy table + ``` + + + ```bash + pnpm emigrate new --plugin postgres create some fancy table + ``` + + + ```bash + yarn emigrate new --plugin postgres create some fancy table + ``` + + + ```bash + bunx --bun emigrate new --plugin postgres create some fancy table + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate new --plugin postgres create some fancy table + ``` + + For more information see the `new` command's documentation. diff --git a/docs/src/content/docs/plugins/loaders/mysql.mdx b/docs/src/content/docs/plugins/loaders/mysql.mdx index 52249d0..47dc6f3 100644 --- a/docs/src/content/docs/plugins/loaders/mysql.mdx +++ b/docs/src/content/docs/plugins/loaders/mysql.mdx @@ -30,6 +30,15 @@ The MySQL loader plugin transforms `.sql` files into JavaScript functions that E bun add @emigrate/mysql ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/mysql": "*" + } + } + ``` + ## Configuration @@ -78,9 +87,41 @@ The `MYSQL_URL` environment variable takes precedence over the other environment The environment variables are used when the plugin is used using the `--plugin` command line option: -```bash -npx emigrate list --plugin mysql -``` + + + ```bash + npx emigrate list --plugin mysql + ``` + + + ```bash + pnpm emigrate list --plugin mysql + ``` + + + ```bash + yarn emigrate list --plugin mysql + ``` + + + ```bash + bunx --bun emigrate list --plugin mysql + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate list --plugin mysql + ``` + + Or when specifying the plugin in the `emigrate.config.js` file as a string: diff --git a/docs/src/content/docs/plugins/loaders/postgres.mdx b/docs/src/content/docs/plugins/loaders/postgres.mdx index 39a9f15..2c7d6d3 100644 --- a/docs/src/content/docs/plugins/loaders/postgres.mdx +++ b/docs/src/content/docs/plugins/loaders/postgres.mdx @@ -30,6 +30,15 @@ The PostgreSQL loader plugin transforms `.sql` files into JavaScript functions t bun add @emigrate/postgres ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/postgres": "*" + } + } + ``` + ## Configuration @@ -78,9 +87,41 @@ The `POSTGRES_URL` environment variable takes precedence over the other environm The environment variables are used when the plugin is used using the `--plugin` command line option: -```bash -npx emigrate list --plugin postgres -``` + + + ```bash + npx emigrate list --plugin postgres + ``` + + + ```bash + pnpm emigrate list --plugin postgres + ``` + + + ```bash + yarn emigrate list --plugin postgres + ``` + + + ```bash + bunx --bun emigrate list --plugin postgres + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate list --plugin postgres + ``` + + Or when specifying the plugin in the `emigrate.config.js` file as a string: diff --git a/docs/src/content/docs/plugins/reporters/pino.mdx b/docs/src/content/docs/plugins/reporters/pino.mdx index 5ff75be..2ee3c19 100644 --- a/docs/src/content/docs/plugins/reporters/pino.mdx +++ b/docs/src/content/docs/plugins/reporters/pino.mdx @@ -32,6 +32,15 @@ This is useful in production environments where you want all logs as JSON, which bun add @emigrate/reporter-pino ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/reporter-pino": "*" + } + } + ``` + ## Usage @@ -42,9 +51,41 @@ The `@emigrate/reporter-` prefix is optional when using this reporter. ### Via CLI -```bash -emigrate --reporter pino -``` + + + ```bash + npx emigrate --reporter pino + ``` + + + ```bash + pnpm emigrate --reporter pino + ``` + + + ```bash + yarn emigrate --reporter pino + ``` + + + ```bash + bunx --bun emigrate --reporter pino + ``` + + + ```json title="package.json" {3} + { + "scripts": { + "emigrate": "emigrate" + } + } + ``` + + ```bash + deno task emigrate --reporter pino + ``` + + See for instance the Reporter Option for the `up` command for more information. diff --git a/docs/src/content/docs/plugins/storage/file-system.mdx b/docs/src/content/docs/plugins/storage/file-system.mdx index f969129..0d865de 100644 --- a/docs/src/content/docs/plugins/storage/file-system.mdx +++ b/docs/src/content/docs/plugins/storage/file-system.mdx @@ -34,6 +34,15 @@ This is suitable for simple setups, but for more advanced setups for instance wh bun add @emigrate/storage-fs ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/storage-fs": "*" + } + } + ``` + ## Configuration diff --git a/docs/src/content/docs/plugins/storage/mysql.mdx b/docs/src/content/docs/plugins/storage/mysql.mdx index 1816179..62a49c7 100644 --- a/docs/src/content/docs/plugins/storage/mysql.mdx +++ b/docs/src/content/docs/plugins/storage/mysql.mdx @@ -30,6 +30,15 @@ The MySQL storage plugin uses a MySQL database to store the migration history (* bun add @emigrate/mysql ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/mysql": "*" + } + } + ``` + ## Configuration diff --git a/docs/src/content/docs/plugins/storage/postgres.mdx b/docs/src/content/docs/plugins/storage/postgres.mdx index 7e586ed..a4c8503 100644 --- a/docs/src/content/docs/plugins/storage/postgres.mdx +++ b/docs/src/content/docs/plugins/storage/postgres.mdx @@ -30,6 +30,15 @@ The PostgreSQL storage plugin uses a PostgreSQL database to store the migration bun add @emigrate/postgres ``` + + ```json title="package.json" {3} + { + "dependencies": { + "@emigrate/postgres": "*" + } + } + ``` + ## Configuration diff --git a/packages/cli/README.md b/packages/cli/README.md index 6e01f65..8c84c57 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -7,7 +7,13 @@ Emigrate is a tool for managing database migrations. It is designed to be simple Install the Emigrate CLI in your project: ```bash -npm install --save-dev @emigrate/cli +npm install @emigrate/cli +# or +pnpm add @emigrate/cli +# or +yarn add @emigrate/cli +# or +bun add @emigrate/cli ``` ## Usage diff --git a/packages/mysql/README.md b/packages/mysql/README.md index 54abfe7..c9a174c 100644 --- a/packages/mysql/README.md +++ b/packages/mysql/README.md @@ -17,7 +17,13 @@ This plugin is actually three different Emigrate plugins in one: Install the plugin in your project, alongside the Emigrate CLI: ```bash -npm install --save-dev @emigrate/cli @emigrate/mysql +npm install @emigrate/cli @emigrate/mysql +# or +pnpm add @emigrate/cli @emigrate/mysql +# or +yarn add @emigrate/cli @emigrate/mysql +# or +bun add @emigrate/cli @emigrate/mysql ``` ## Usage diff --git a/packages/plugin-generate-js/README.md b/packages/plugin-generate-js/README.md index c04e9c8..3147665 100644 --- a/packages/plugin-generate-js/README.md +++ b/packages/plugin-generate-js/README.md @@ -7,7 +7,13 @@ This package contains an Emigrate plugin for generating migration files using Ja Install the package: ```bash -npm install --save-dev @emigrate/plugin-generate-js +npm install @emigrate/cli @emigrate/plugin-generate-js +# or +pnpm add @emigrate/cli @emigrate/plugin-generate-js +# or +yarn add @emigrate/cli @emigrate/plugin-generate-js +# or +bun add @emigrate/cli @emigrate/plugin-generate-js ``` Use the plugin with the `emigrate new` command: diff --git a/packages/postgres/README.md b/packages/postgres/README.md index 1e397c3..aa606b9 100644 --- a/packages/postgres/README.md +++ b/packages/postgres/README.md @@ -17,7 +17,13 @@ This plugin is actually three different Emigrate plugins in one: Install the plugin in your project, alongside the Emigrate CLI: ```bash -npm install --save-dev @emigrate/cli @emigrate/postgres +npm install @emigrate/cli @emigrate/postgres +# or +pnpm add @emigrate/cli @emigrate/postgres +# or +yarn add @emigrate/cli @emigrate/postgres +# or +bun add @emigrate/cli @emigrate/postgres ``` ## Usage diff --git a/packages/reporter-pino/README.md b/packages/reporter-pino/README.md index 975623f..73b8eb7 100644 --- a/packages/reporter-pino/README.md +++ b/packages/reporter-pino/README.md @@ -8,7 +8,13 @@ Which is great both in production environments and for piping the output to othe Install the reporter in your project, alongside the Emigrate CLI: ```bash -npm install --save-dev @emigrate/cli @emigrate/reporter-pino +npm install @emigrate/cli @emigrate/reporter-pino +# or +pnpm add @emigrate/cli @emigrate/reporter-pino +# or +yarn add @emigrate/cli @emigrate/reporter-pino +# or +bun add @emigrate/cli @emigrate/reporter-pino ``` ## Usage diff --git a/packages/storage-fs/README.md b/packages/storage-fs/README.md index 3fc6e65..d83805b 100644 --- a/packages/storage-fs/README.md +++ b/packages/storage-fs/README.md @@ -7,7 +7,13 @@ A file system storage plugin for Emigrate, suitable for simple migration setups. Install the storage plugin in your project, alongside the Emigrate CLI: ```bash -npm install --save-dev @emigrate/cli @emigrate/storage-fs +npm install @emigrate/cli @emigrate/storage-fs +# or +pnpm add @emigrate/cli @emigrate/storage-fs +# or +yarn add @emigrate/cli @emigrate/storage-fs +# or +bun add @emigrate/cli @emigrate/storage-fs ``` ## Usage