https://github.com/patlux/bun-sqlite-migrations
Migration management for bun.sh
https://github.com/patlux/bun-sqlite-migrations
bun migration migration-tool sqlite
Last synced: 30 days ago
JSON representation
Migration management for bun.sh
- Host: GitHub
- URL: https://github.com/patlux/bun-sqlite-migrations
- Owner: patlux
- Created: 2023-08-11T17:35:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T17:58:43.000Z (almost 2 years ago)
- Last Synced: 2025-04-20T12:15:04.380Z (about 1 month ago)
- Topics: bun, migration, migration-tool, sqlite
- Language: TypeScript
- Homepage: https://patwoz.dev
- Size: 13.7 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bun-sqlite-migrations
Simple function for migration management for [bun:sqlite](https://bun.sh/docs/api/sqlite)
## Getting started
```sh
bun add bun-sqlite-migrations
```### Example
Add your `.sql` files into `./migrations`, e.g.:
- `0001_init.sql`
- `0002_add_users_table.sql`
- `0003_add_column_gender_to_users_table.sql`> Only the sorting matters. The index of the last executed migration will be stored into the database.
```ts
import { migrate, getMigrations } from 'bun-sqlite-migrations'const db = new Database(`data.db`)
migrate(db, getMigrations('./migrations'))
```**Verify**:
```sh
sqlite3 data.db "PRAGMA user_version;"
# should return the number of migrations which were executed
3
```