Socket
Book a DemoInstallSign in
Socket

@blackglory/better-sqlite3-migrations

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blackglory/better-sqlite3-migrations

A utility for database migrations with better-sqlite3

latest
Source
npmnpm
Version
0.1.20
Version published
Weekly downloads
40
135.29%
Maintainers
0
Weekly downloads
 
Created
Source

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.

Keywords

migration

FAQs

Package last updated on 21 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts