feat: support for Bun

This commit is contained in:
Joakim Carlstein 2023-12-19 14:00:20 +01:00 committed by Joakim Carlstein
parent c284cc48d1
commit ce6946cac4
25 changed files with 111 additions and 2 deletions

View 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`

View file

@ -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).
📖 Read the [documentation](https://emigrate.dev) for more information!
## Features
- Database agnostic
@ -29,6 +31,12 @@ Install the Emigrate CLI in your project:
```bash
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
@ -36,7 +44,13 @@ npm install --save-dev @emigrate/cli
Create a new migration:
```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.

View file

@ -29,6 +29,11 @@ It then sorts the migrations by filename in ascending order and outputs them and
yarn emigrate list [options]
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate list [options]
```
</TabItem>
<TabItem label="package.json">
```json {3}
{

View file

@ -28,6 +28,11 @@ The migration file can be based on a template, generated by a <Link href="/plugi
yarn emigrate new [options] <name>
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate new [options] <name>
```
</TabItem>
<TabItem label="package.json">
```json {3}
{

View file

@ -26,6 +26,11 @@ The `remove` command is used to remove a migration from the history. This is use
yarn emigrate remove [options] <name>
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate remove [options] <name>
```
</TabItem>
<TabItem label="package.json">
```json {3}
{

View file

@ -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]
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate up [options]
```
</TabItem>
<TabItem label="package.json">
```json {3}
{

View file

@ -35,6 +35,11 @@ But for now, this is the way to go.
yarn add @emigrate/cli
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/cli
```
</TabItem>
</Tabs>
### 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
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/postgres
```
</TabItem>
</Tabs>
### Create your first migration

View file

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

@ -25,6 +25,11 @@ A <Link href="/plugins/generators/">generator plugin</Link> for generating new m
yarn add @emigrate/plugin-generate-js
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/plugin-generate-js
```
</TabItem>
</Tabs>
## Usage

View file

@ -25,6 +25,11 @@ The MySQL generator creates new migration files with the `.sql` extension. In th
yarn add @emigrate/mysql
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/mysql
```
</TabItem>
</Tabs>
## Usage

View file

@ -25,6 +25,11 @@ The PostgreSQL generator creates new migration files with the `.sql` extension.
yarn add @emigrate/postgres
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/postgres
```
</TabItem>
</Tabs>
## Usage

View file

@ -25,6 +25,11 @@ The MySQL loader plugin transforms `.sql` files into JavaScript functions that E
yarn add @emigrate/mysql
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/mysql
```
</TabItem>
</Tabs>
## Configuration

View file

@ -25,6 +25,11 @@ The PostgreSQL loader plugin transforms `.sql` files into JavaScript functions t
yarn add @emigrate/postgres
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/postgres
```
</TabItem>
</Tabs>
## Configuration

View file

@ -27,6 +27,11 @@ This is useful in production environments where you want all logs as JSON, which
yarn add @emigrate/reporter-pino
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/reporter-pino
```
</TabItem>
</Tabs>
## Usage

View file

@ -29,6 +29,11 @@ This is suitable for simple setups, but for more advanced setups for instance wh
yarn add @emigrate/storage-fs
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/storage-fs
```
</TabItem>
</Tabs>
## Configuration

View file

@ -25,6 +25,11 @@ The MySQL storage plugin uses a MySQL database to store the migration history (*
yarn add @emigrate/mysql
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/mysql
```
</TabItem>
</Tabs>
## Configuration

View file

@ -25,6 +25,11 @@ The PostgreSQL storage plugin uses a PostgreSQL database to store the migration
yarn add @emigrate/postgres
```
</TabItem>
<TabItem label="bun">
```bash
bun add @emigrate/postgres
```
</TabItem>
</Tabs>
## Configuration

View file

@ -143,7 +143,7 @@ Options:
Examples:
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 -t .migration-template -e .sql "drop some table"
`;

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}

View file

@ -10,6 +10,7 @@
"type": "module",
"exports": {
".": {
"bun": "./src/index.ts",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}