New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sqldiff

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqldiff

Generate SQL table schema diffs

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-34.29%
Maintainers
2
Weekly downloads
 
Created
Source

sqldiff Build Status

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;

FAQs

Package last updated on 29 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc