0.1.19 • Published 9 months ago

@blackglory/better-sqlite3-migrations v0.1.19

Weekly downloads
96
License
MIT
Repository
github
Last release
9 months ago

better-sqlite3-migrations

A utility for database migrations with better-sqlite3.

The module using user_version to record the schema version.

Install

npm install --save @blackglory/better-sqlite3-migrations
# or
yarn add @blackglory/better-sqlite3-migrations

API

interface IMigration {
  version: number
  up: string | ((db: Database) => void)
  down: string | ((db: Database) => void)
}

You may need migration-files.

migrate

function migrate(db: Database, migrations: IMigration[], targetVersion?: number): void

If targetVersion is undefined, then use the maximum version of migrations.

FAQ

Can multiple instances migrate in parallel?

Yes, the user_version update is visible to every database connection. When the maximum migration version is less than the user_version (which means it is an obsolete instance), it will skip the migration.

You may need a proper retry strategy, because each migration uses BEGIN IMMEDIATE to ensure that parallel write transactions fail early.

0.1.19

9 months ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago