6.0.67 • Published 4 years ago
@zxteam/sql-sqlite v6.0.67
ZXTeam's SQLite Facade
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
6.0.67
4 years ago