docs: include Deno usage instructions in the documentation

This commit is contained in:
Joakim Carlstein 2023-12-19 15:32:16 +01:00 committed by Joakim Carlstein
parent e8e35215be
commit 7bae76f496
22 changed files with 505 additions and 50 deletions

View file

@ -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

View file

@ -34,14 +34,21 @@ It then sorts the migrations by filename in ascending order and outputs them and
bunx --bun emigrate list [options]
```
</TabItem>
<TabItem label="package.json">
```json {3}
<TabItem label="deno">
```json title="package.json" {3,6}
{
"scripts": {
"emigrate": "emigrate list [options]"
"emigrate": "emigrate"
},
"dependencies": {
"@emigrate/cli": "*"
}
}
```
```bash
deno task emigrate list [options]
```
</TabItem>
</Tabs>

View file

@ -33,14 +33,21 @@ The migration file can be based on a template, generated by a <Link href="/plugi
bunx --bun emigrate new [options] <name>
```
</TabItem>
<TabItem label="package.json">
```json {3}
<TabItem label="deno">
```json title="package.json" {3,6}
{
"scripts": {
"emigrate": "emigrate new [options] <name>"
"emigrate": "emigrate"
},
"dependencies": {
"@emigrate/cli": "*"
}
}
```
```bash
deno task emigrate new [options] <name>
```
</TabItem>
</Tabs>

View file

@ -31,14 +31,21 @@ The `remove` command is used to remove a migration from the history. This is use
bunx --bun emigrate remove [options] <name>
```
</TabItem>
<TabItem label="package.json">
```json {3}
<TabItem label="deno">
```json title="package.json" {3,6}
{
"scripts": {
"emigrate": "emigrate remove [options] <name>"
"emigrate": "emigrate"
},
"dependencies": {
"@emigrate/cli": "*"
}
}
```
```bash
deno task emigrate remove [options] <name>
```
</TabItem>
</Tabs>

View file

@ -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]
```
</TabItem>
<TabItem label="package.json">
```json {3}
<TabItem label="deno">
```json title="package.json" {3,6}
{
"scripts": {
"emigrate": "emigrate up [options]"
"emigrate": "emigrate"
},
"dependencies": {
"@emigrate/cli": "*"
}
}
```
```bash
deno task emigrate up [options]
```
</TabItem>
</Tabs>

View file

@ -40,6 +40,18 @@ But for now, this is the way to go.
bun add @emigrate/cli
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3,6}
{
"scripts": {
"emigrate": "emigrate"
},
"dependencies": {
"@emigrate/cli": "*"
}
}
```
</TabItem>
</Tabs>
### Pick a storage plugin
@ -69,15 +81,57 @@ Install the plugin you want to use, for example the <Link href="/plugins/storage
bun add @emigrate/postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {4}
{
"dependencies": {
"@emigrate/cli": "*",
"@emigrate/postgres": "*"
}
}
```
</TabItem>
</Tabs>
### 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
```
<Tabs>
<TabItem label="npm">
```bash title="Create a new migration file"
npx emigrate new --plugin postgres create users table
```
</TabItem>
<TabItem label="pnpm">
```bash title="Create a new migration file"
pnpm emigrate new --plugin postgres create users table
```
</TabItem>
<TabItem label="yarn">
```bash title="Create a new migration file"
yarn emigrate new --plugin postgres create users table
```
</TabItem>
<TabItem label="bun">
```bash title="Create a new migration file"
bunx --bun emigrate new --plugin postgres create users table
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash title="Create a new migration file"
deno task emigrate new --plugin postgres create users table
```
</TabItem>
</Tabs>
```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
```
<Tabs>
<TabItem label="npm">
```bash title="Show all migrations"
npx emigrate list --storage postgres
```
</TabItem>
<TabItem label="pnpm">
```bash title="Show all migrations"
pnpm emigrate list --storage postgres
```
</TabItem>
<TabItem label="yarn">
```bash title="Show all migrations"
yarn emigrate list --storage postgres
```
</TabItem>
<TabItem label="bun">
```bash title="Show all migrations"
bunx --bun emigrate list --storage postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash title="Show all migrations"
deno task emigrate list --storage postgres
```
</TabItem>
</Tabs>
```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
```
<Tabs>
<TabItem label="npm">
```bash title="Show pending migrations"
npx emigrate up --storage postgres --plugin postgres --dry
```
</TabItem>
<TabItem label="pnpm">
```bash title="Show pending migrations"
pnpm emigrate up --storage postgres --plugin postgres --dry
```
</TabItem>
<TabItem label="yarn">
```bash title="Show pending migrations"
yarn emigrate up --storage postgres --plugin postgres --dry
```
</TabItem>
<TabItem label="bun">
```bash title="Show pending migrations"
bunx --bun emigrate up --storage postgres --plugin postgres --dry
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash title="Show pending migrations"
deno task emigrate up --storage postgres --plugin postgres --dry
```
</TabItem>
</Tabs>
:::note
This will connect to the database using some default values. For ways to configure the connection, see <Link href="/reference/configuration/">Configuration</Link>.

View file

@ -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 <Link href="/plugins/loaders/default/">CommonJS or ES Modules out of the box</Link>, 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 <Link href="/plugins/loaders/">Loader Plugin</Link>.

View file

@ -30,12 +30,53 @@ A <Link href="/plugins/generators/">generator plugin</Link> for generating new m
bun add @emigrate/plugin-generate-js
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/plugin-generate-js": "*"
}
}
```
</TabItem>
</Tabs>
## Usage
```bash
emigrate new --plugin generate-js create some fancy table
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate new --plugin generate-js create some fancy table
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate new --plugin generate-js create some fancy table
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate new --plugin generate-js create some fancy table
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate new --plugin generate-js create some fancy table
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate new --plugin generate-js create some fancy table
```
</TabItem>
</Tabs>
For more information see <Link href="/commands/new/">the `new` command</Link>'s documentation.

View file

@ -30,12 +30,53 @@ The MySQL generator creates new migration files with the `.sql` extension. In th
bun add @emigrate/mysql
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/mysql": "*"
}
}
```
</TabItem>
</Tabs>
## Usage
```bash
emigrate new --plugin mysql create some fancy table
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate new --plugin mysql create some fancy table
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate new --plugin mysql create some fancy table
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate new --plugin mysql create some fancy table
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate new --plugin mysql create some fancy table
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate new --plugin mysql create some fancy table
```
</TabItem>
</Tabs>
For more information see <Link href="/commands/new/">the `new` command</Link>'s documentation.

View file

@ -30,12 +30,53 @@ The PostgreSQL generator creates new migration files with the `.sql` extension.
bun add @emigrate/postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/postgres": "*"
}
}
```
</TabItem>
</Tabs>
## Usage
```bash
emigrate new --plugin postgres create some fancy table
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate new --plugin postgres create some fancy table
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate new --plugin postgres create some fancy table
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate new --plugin postgres create some fancy table
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate new --plugin postgres create some fancy table
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate new --plugin postgres create some fancy table
```
</TabItem>
</Tabs>
For more information see <Link href="/commands/new/">the `new` command</Link>'s documentation.

View file

@ -30,6 +30,15 @@ The MySQL loader plugin transforms `.sql` files into JavaScript functions that E
bun add @emigrate/mysql
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/mysql": "*"
}
}
```
</TabItem>
</Tabs>
## 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
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate list --plugin mysql
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate list --plugin mysql
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate list --plugin mysql
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate list --plugin mysql
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate list --plugin mysql
```
</TabItem>
</Tabs>
Or when specifying the plugin in the <Link href="/reference/configuration/">`emigrate.config.js` file</Link> as a string:

View file

@ -30,6 +30,15 @@ The PostgreSQL loader plugin transforms `.sql` files into JavaScript functions t
bun add @emigrate/postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/postgres": "*"
}
}
```
</TabItem>
</Tabs>
## 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
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate list --plugin postgres
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate list --plugin postgres
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate list --plugin postgres
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate list --plugin postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate list --plugin postgres
```
</TabItem>
</Tabs>
Or when specifying the plugin in the <Link href="/reference/configuration/">`emigrate.config.js` file</Link> as a string:

View file

@ -32,6 +32,15 @@ This is useful in production environments where you want all logs as JSON, which
bun add @emigrate/reporter-pino
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/reporter-pino": "*"
}
}
```
</TabItem>
</Tabs>
## Usage
@ -42,9 +51,41 @@ The `@emigrate/reporter-` prefix is optional when using this reporter.
### Via CLI
```bash
emigrate <command> --reporter pino
```
<Tabs>
<TabItem label="npm">
```bash
npx emigrate <command> --reporter pino
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate <command> --reporter pino
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate <command> --reporter pino
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate <command> --reporter pino
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"scripts": {
"emigrate": "emigrate"
}
}
```
```bash
deno task emigrate <command> --reporter pino
```
</TabItem>
</Tabs>
See for instance the <Link href="/commands/up/#-r---reporter-name">Reporter Option</Link> for the `up` command for more information.

View file

@ -34,6 +34,15 @@ This is suitable for simple setups, but for more advanced setups for instance wh
bun add @emigrate/storage-fs
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/storage-fs": "*"
}
}
```
</TabItem>
</Tabs>
## Configuration

View file

@ -30,6 +30,15 @@ The MySQL storage plugin uses a MySQL database to store the migration history (*
bun add @emigrate/mysql
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/mysql": "*"
}
}
```
</TabItem>
</Tabs>
## Configuration

View file

@ -30,6 +30,15 @@ The PostgreSQL storage plugin uses a PostgreSQL database to store the migration
bun add @emigrate/postgres
```
</TabItem>
<TabItem label="deno">
```json title="package.json" {3}
{
"dependencies": {
"@emigrate/postgres": "*"
}
}
```
</TabItem>
</Tabs>
## Configuration

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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