6.0.66 • Published 4 years ago

@zxteam/sql v6.0.66

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

ZXTeam's SQL Facade Contract

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

The package declares TypeScript interfaces and error classes.

API

Interfaces

EmbeddedSqlProviderFactory

SqlProviderFactory

SqlData

SqlProvider

SqlResultRecord

SqlStatement

SqlTemporaryTable

Enums

SqlDialect

Types

SqlStatementParam

TBD

Migration

The library provides general low-level approach to control database version. Each version bundle (directory) contains set of SQL files and scripts that provide install/rollback behavior.

Migration Directory layout

MyDatabase
├── v0001
│   ├── install
│   │   ├── 01-init.sql
│   │   ├── 50-migration.js
│   │   └── 99-finalize.sql
│   └── rollback
│       ├── drop-A.sql
│       ├── drop-B.sql
│       └── drop-C.sql
├── v0002
│   ├── install
│   │   ├── 01-init.sql
│   │   ├── 50-migration.js
│   │   └── 99-finalize.sql
│   └── rollback
│       ├── 10-drop-table-user.sql
│       └── 20-drop-table-group.sql
└── vXXXX
    ├── install
    │   ├── 01-init.sql
    │   ├── 50-migration.js
    │   └── 99-finalize.sql
    └── rollback
        ├── 1-drop-something.sql
        └── 2-drop-something.js

Migration Components

  • MigrationSources - JavaScript class provides lazy loader around set of SQL files and scripts. Main responsibility is read/write Migration Directory Layout
  • MigrationManager - JavaScript class represents migration executor. Main responsibility install/rollback database versions.

MigrationSources

MigrationSources provides:

  • Static methods for read sources from filesystem and networks
  • Methods to transform content (for example: apply templating processor over SQL scripts)
  • Methods to iterate through version bundles and files inside a version bundle
  • Methods to save sources (for example: after transformation)

MigrationManager

MigrationManager works with your database in order to bring the database to the required version. Your database should have a techninal table where MigrationManager stores migration history. Migraton Algorithm is pretty straightforward.

!!!Note Version directories and migration files are sorted in ascending, ASCII character order.

Increment version
  • MigrationManager detects current version of DB
  • MigrationManager executes files instal/* on each version bundle (directory) unless target version(or latest version) is reached
Decrement version
  • MigrationManager detects current version of DB
  • MigrationManager executes files rollback/* on each-down version bundle (directory) unless target version(or latest version) is reached
6.0.66

4 years ago

6.0.65

4 years ago

6.0.64

4 years ago

6.0.63

4 years ago

6.0.62

4 years ago

6.0.61

4 years ago

6.0.60

4 years ago

6.0.59

4 years ago

6.0.58

4 years ago

6.0.57

4 years ago

6.0.56

4 years ago

6.0.50

4 years ago

6.0.49

4 years ago

6.0.45

4 years ago

6.0.44

4 years ago

6.0.43

4 years ago

6.0.41

4 years ago

6.0.38

4 years ago

6.0.39

4 years ago

6.0.40

4 years ago

6.0.35

4 years ago

6.0.24

5 years ago

6.0.23

5 years ago