feat: support for Bun
This commit is contained in:
parent
c284cc48d1
commit
ce6946cac4
25 changed files with 111 additions and 2 deletions
12
.changeset/lazy-plums-wink.md
Normal file
12
.changeset/lazy-plums-wink.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
'@emigrate/plugin-generate-js': minor
|
||||||
|
'@emigrate/reporter-pino': minor
|
||||||
|
'@emigrate/plugin-tools': minor
|
||||||
|
'@emigrate/storage-fs': minor
|
||||||
|
'@emigrate/postgres': minor
|
||||||
|
'@emigrate/mysql': minor
|
||||||
|
'@emigrate/types': minor
|
||||||
|
'@emigrate/cli': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Emigrate supports Bun, make use of the `bun` key in package.json `exports`
|
||||||
16
README.md
16
README.md
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
It's effectively a successor of [klei-migrate](https://www.npmjs.com/package/klei-migrate) and [Immigration](https://www.npmjs.com/package/immigration).
|
It's effectively a successor of [klei-migrate](https://www.npmjs.com/package/klei-migrate) and [Immigration](https://www.npmjs.com/package/immigration).
|
||||||
|
|
||||||
|
📖 Read the [documentation](https://emigrate.dev) for more information!
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Database agnostic
|
- Database agnostic
|
||||||
|
|
@ -29,6 +31,12 @@ Install the Emigrate CLI in your project:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install --save-dev @emigrate/cli
|
npm install --save-dev @emigrate/cli
|
||||||
|
# or
|
||||||
|
pnpm add --save-dev @emigrate/cli
|
||||||
|
# or
|
||||||
|
yarn add --dev @emigrate/cli
|
||||||
|
# or
|
||||||
|
bun add --dev @emigrate/cli
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
@ -36,7 +44,13 @@ npm install --save-dev @emigrate/cli
|
||||||
Create a new migration:
|
Create a new migration:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
emigrate new -d migrations -e .js create some fancy table
|
npx emigrate new -d migrations -e .js create some fancy table
|
||||||
|
# or
|
||||||
|
pnpm emigrate new -d migrations -e .js create some fancy table
|
||||||
|
# or
|
||||||
|
yarn emigrate new -d migrations -e .js create some fancy table
|
||||||
|
# or
|
||||||
|
bunx --bun emigrate new -d migrations -e .js create some fancy table
|
||||||
```
|
```
|
||||||
|
|
||||||
Will create a new empty JavaScript migration file with the name "YYYYMMDDHHmmssuuu_create_some_fancy_table.js" in the `migrations` directory.
|
Will create a new empty JavaScript migration file with the name "YYYYMMDDHHmmssuuu_create_some_fancy_table.js" in the `migrations` directory.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ It then sorts the migrations by filename in ascending order and outputs them and
|
||||||
yarn emigrate list [options]
|
yarn emigrate list [options]
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bunx --bun emigrate list [options]
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
<TabItem label="package.json">
|
<TabItem label="package.json">
|
||||||
```json {3}
|
```json {3}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ The migration file can be based on a template, generated by a <Link href="/plugi
|
||||||
yarn emigrate new [options] <name>
|
yarn emigrate new [options] <name>
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bunx --bun emigrate new [options] <name>
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
<TabItem label="package.json">
|
<TabItem label="package.json">
|
||||||
```json {3}
|
```json {3}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ The `remove` command is used to remove a migration from the history. This is use
|
||||||
yarn emigrate remove [options] <name>
|
yarn emigrate remove [options] <name>
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bunx --bun emigrate remove [options] <name>
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
<TabItem label="package.json">
|
<TabItem label="package.json">
|
||||||
```json {3}
|
```json {3}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@ If any of the migrations fail, the command will be aborted and the rest of the m
|
||||||
yarn emigrate up [options]
|
yarn emigrate up [options]
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bunx --bun emigrate up [options]
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
<TabItem label="package.json">
|
<TabItem label="package.json">
|
||||||
```json {3}
|
```json {3}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@ But for now, this is the way to go.
|
||||||
yarn add @emigrate/cli
|
yarn add @emigrate/cli
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/cli
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### Pick a storage plugin
|
### Pick a storage plugin
|
||||||
|
|
@ -59,6 +64,11 @@ Install the plugin you want to use, for example the <Link href="/plugins/storage
|
||||||
yarn add @emigrate/postgres
|
yarn add @emigrate/postgres
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/postgres
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### Create your first migration
|
### Create your first migration
|
||||||
|
|
|
||||||
|
|
@ -8,6 +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.
|
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'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'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'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).
|
* 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>.
|
* Other languages can be used by using a <Link href="/plugins/loaders/">Loader Plugin</Link>.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ A <Link href="/plugins/generators/">generator plugin</Link> for generating new m
|
||||||
yarn add @emigrate/plugin-generate-js
|
yarn add @emigrate/plugin-generate-js
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/plugin-generate-js
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The MySQL generator creates new migration files with the `.sql` extension. In th
|
||||||
yarn add @emigrate/mysql
|
yarn add @emigrate/mysql
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/mysql
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The PostgreSQL generator creates new migration files with the `.sql` extension.
|
||||||
yarn add @emigrate/postgres
|
yarn add @emigrate/postgres
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/postgres
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The MySQL loader plugin transforms `.sql` files into JavaScript functions that E
|
||||||
yarn add @emigrate/mysql
|
yarn add @emigrate/mysql
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/mysql
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The PostgreSQL loader plugin transforms `.sql` files into JavaScript functions t
|
||||||
yarn add @emigrate/postgres
|
yarn add @emigrate/postgres
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/postgres
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ This is useful in production environments where you want all logs as JSON, which
|
||||||
yarn add @emigrate/reporter-pino
|
yarn add @emigrate/reporter-pino
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/reporter-pino
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ This is suitable for simple setups, but for more advanced setups for instance wh
|
||||||
yarn add @emigrate/storage-fs
|
yarn add @emigrate/storage-fs
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/storage-fs
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The MySQL storage plugin uses a MySQL database to store the migration history (*
|
||||||
yarn add @emigrate/mysql
|
yarn add @emigrate/mysql
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/mysql
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ The PostgreSQL storage plugin uses a PostgreSQL database to store the migration
|
||||||
yarn add @emigrate/postgres
|
yarn add @emigrate/postgres
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem label="bun">
|
||||||
|
```bash
|
||||||
|
bun add @emigrate/postgres
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ Options:
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
emigrate new -d src/migrations -t migration-template.js create users table
|
emigrate new -d src/migrations -t migration-template.js create users table
|
||||||
emigrate new --directory ./migrations --plugin @emigrate/plugin-generate-sql create_users_table
|
emigrate new --directory ./migrations --plugin @emigrate/postgres create_users_table
|
||||||
emigrate new -d ./migrations -e .sql create_users_table
|
emigrate new -d ./migrations -e .sql create_users_table
|
||||||
emigrate new -d ./migrations -t .migration-template -e .sql "drop some table"
|
emigrate new -d ./migrations -t .migration-template -e .sql "drop some table"
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"bun": "./src/index.ts",
|
||||||
"import": "./dist/index.js",
|
"import": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue