https://github.com/redraskal/bun-migrate
A simple SQLite file-based migration system for Bun.
https://github.com/redraskal/bun-migrate
bun migrations sqlite typescript
Last synced: 15 days ago
JSON representation
A simple SQLite file-based migration system for Bun.
- Host: GitHub
- URL: https://github.com/redraskal/bun-migrate
- Owner: redraskal
- License: mit
- Created: 2023-07-17T23:36:10.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-23T22:16:26.000Z (9 months ago)
- Last Synced: 2025-03-25T01:51:13.224Z (about 1 month ago)
- Topics: bun, migrations, sqlite, typescript
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bun-migrate
A simple SQLite file-based migration system for Bun.
## 1. Install
```bash
bun i redraskal/bun-migrate#main
```## 2. Pick a migrations folder
Choose a folder name, or use a default "migrations" folder in your project.
## 3. Add your first migration
Create a file in your migrations folder with the following name:
```bash
1.{name}.sql # Example: 1.initial.sql
```Future migrations should have an incrementing or sequential id sequence.
Example:
- 1.initial.sql
- 2.create_accounts.sql
- 6.banana.sql## 4. Apply your migrations
```ts
import Database from "bun:sqlite";
import { migrate, migrations } from "bun-migrate";const db = new Database("bun.sqlite");
await migrate(db);
// "🌩️ Running migrations..."
// " ⚡ 1.initial.sql"
// " ⚡ 2.create_accounts.sql"
// ...// or specify a folder
await migrate(db, {
migrations: "./cool_migrations",
});const files = await migrations("./cool_migrations");
console.log(files);
/**
* [
* {
* id: 1,
* name: "1.initial.sql",
* content: "CREATE TABLE..."
* },
* ...
* ]
*/
```This project was created using `bun init` in bun v0.6.15. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.