6.0.67 • Published 4 years ago

@zxteam/sql-sqlite v6.0.67

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

ZXTeam's SQLite Facade

npm version badge downloads badge commit activity badge last commit badge twitter badge

Interfaces

Classes

SqliteProviderFactory

Provides SQLite implementation for EmbeddedSqlProviderFactory interface defined in @zxteam/sql contact package

Functions

migration

import { DUMMY_CANCELLATION_TOKEN } from "@zxteam/cancellation";
import { migration } from "@zxteam/sql-sqlite";

const dbURL: URL = new URL("file:///path/to/db.sql");
const migrationFilesRootPath: string = './database/';

const sqlProviderFactory = new SqliteProviderFactory(dbURL);

await sqlProviderFactory.migration(DUMMY_CANCELLATION_TOKEN, migrationFilesRootPath /*, targetVersion*/ ); // targetVersion is optional, if ommited, the migration update DB to latest version

Guides

Migration guide

Structure sql file (example)

Three files per version init.sql, migration.js and finalize.sql that applied one by one. Versions are applied one by one from oldest to newest (according string sorting).

./database/0.0.1/init.sql
./database/0.0.1/migration.js
./database/0.0.1/finalize.sql
./database/0.0.2/init.sql
./database/0.0.2/finalize.sql
./database/0.0.3/finalize.sql

The files inside version are optional, but at least one file should present.

Detect DB version

To detect DB version, the Migration is used table with name version inside your DB. So do not create a table with same name to prevent conflicts.

Update DB

TBD