0.3.0 • Published 2 years ago
sqldiff v0.3.0
sqldiff
Diff SQL table definitions to produce statements to patch them. This module does not execute any SQL.
Installation
npm install sqldiff
Example
import { Table, SchemaDiffer, Postgres, SQLite } from 'sqldiff';
// boilerplate to build up old/new table definitions
const oldTable = new Table('users');
const newTable = new Table('users');
oldTable.addColumn('id', 'pk');
oldTable.addColumn('name', 'string');
newTable.addColumn('id', 'pk');
newTable.addColumn('name', 'string');
newTable.addColumn('description', 'string');
newTable.addColumn('age', 'integer');
newTable.addColumn('height', 'double');
// generate a diff of the tables
const differ = new SchemaDiffer({ tables: [oldTable] },
{ tables: [newTable] });
// now we can turn it into different SQL dialects
const pg = new Postgres(differ);
console.log(pg.generate());
// ALTER TABLE "users" ADD COLUMN "description" text;
// ALTER TABLE "users" ADD COLUMN "age" bigint;
// ALTER TABLE "users" ADD COLUMN "height" float;
const sqlite = new SQLite(differ);
console.log(sqlite.generate());
// ALTER TABLE `users` ADD COLUMN `description` TEXT;
// ALTER TABLE `users` ADD COLUMN `age` INTEGER;
// ALTER TABLE `users` ADD COLUMN `height` REAL;
0.3.0
2 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.1.0
5 years ago
0.0.30
5 years ago
0.0.29
5 years ago
0.0.28
5 years ago
0.0.27
6 years ago
0.0.26
6 years ago
0.0.25
6 years ago
0.0.24
6 years ago
0.0.23
6 years ago
0.0.22
6 years ago
0.0.21
6 years ago
0.0.20
7 years ago
0.0.19
8 years ago
0.0.18
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15
8 years ago
0.0.14
8 years ago
0.0.13
8 years ago
0.0.12
8 years ago
0.0.11
8 years ago
0.0.10
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago