{"id":43943,"library":"sql-schema-control","title":"sql-schema-control","description":"Declarative database schema management tool for provisioning, tracking, syncing, and modifying database schemas using plain, version-controlled SQL. Current stable version is 1.7.1. It supports PostgreSQL and MySQL, and is inspired by Liquibase and Terraform. Key differentiators include a declarative approach with two schema management classes (changes and resources), automatic detection of out-of-sync resources, and seamless integration into CI/CD pipelines. Release cadence is not specified but appears active. It ships TypeScript types and requires Node >=8.0.0.","status":"active","version":"1.7.1","language":"javascript","source_language":"en","source_url":"https://github.com/ehmpathy/sql-schema-control","tags":["javascript","database","schema","migrations","sql","mysql","liquibase","db-migrate","typescript"],"install":[{"cmd":"npm install sql-schema-control","lang":"bash","label":"npm"},{"cmd":"yarn add sql-schema-control","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-schema-control","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL driver required for Postgres connections","package":"pg","optional":true},{"reason":"MySQL driver required for MySQL connections","package":"mysql","optional":true}],"imports":[{"note":"Named export for applying changes; ESM usage requires 'type': 'module' or .mjs extension","wrong":"const sqlSchemaControl = require('sql-schema-control'); sqlSchemaControl.apply()","symbol":"apply","correct":"import { apply } from 'sql-schema-control'"},{"note":"plan is exported from the main package, not a subpath; do not use a subpath import","wrong":"import { plan } from 'sql-schema-control/plan'","symbol":"plan","correct":"import { plan } from 'sql-schema-control'"},{"note":"CommonJS require works but ESM import is preferred; types are included","wrong":"const pull = require('sql-schema-control').pull","symbol":"pull","correct":"import { pull } from 'sql-schema-control'"}],"quickstart":{"code":"import { plan, apply } from 'sql-schema-control';\nimport pg from 'pg';\n\n// Assuming a connection config is defined elsewhere\nconst connectionConfig = {\n  host: 'localhost',\n  port: 5432,\n  database: 'mydb',\n  schema: 'public',\n  username: 'user',\n  password: process.env.DB_PASSWORD ?? ''\n};\n\nasync function run() {\n  // Plan the actions needed to sync the schema\n  const actions = await plan({\n    language: 'postgres',\n    dialect: '10.7',\n    connection: connectionConfig,\n    strict: true,\n    controlDir: './sql'  // directory containing .sql files\n  });\n  console.log('Planned actions:', actions);\n\n  // Apply the changes\n  const result = await apply({\n    language: 'postgres',\n    dialect: '10.7',\n    connection: connectionConfig,\n    strict: true,\n    controlDir: './sql'\n  });\n  console.log('Applied result:', result);\n}\n\nrun().catch(console.error);","lang":"typescript","description":"Shows how to plan and apply schema changes using sql-schema-control with PostgreSQL, including connection setup and error handling."},"warnings":[{"fix":"Grant DDL privileges (e.g., CREATE, ALTER, DROP) to the user specified in the connection config.","message":"The schema user must have DDL permissions; otherwise operations will fail silently or with cryptic errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set strict: false in the control config if you expect uncontrolled resources.","message":"When using strict: true (default), any uncontrolled resources in the database cause failures; set strict: false to ignore them.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update your config to pass the connection object directly instead of a module path.","message":"The old 'connection' field as a string path to a module is deprecated; use a connection object directly.","severity":"deprecated","affected_versions":"<=1.6.0"},{"fix":"Set the dialect to the exact version of your PostgreSQL or MySQL server (e.g., '10.7' for Postgres).","message":"The 'dialect' version must match the actual database server version, otherwise SQL syntax errors may occur.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your control directory contains only .sql files, organized by changes/ and resources/ subdirectories.","message":"The control directory (controlDir) should only contain .sql files; other files may be ignored or cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.7.1':28 '8.0.0':84 'activ':76 'appear':75 'approach':46 'automat':55 'cadenc':70 'chang':52 'ci/cd':67 'class':51 'control':4,22 'current':24 'databas':6,16,86 'db':93 'db-migrat':92 'declar':5,45 'detect':56 'differenti':42 'includ':43 'inspir':36 'integr':65 'javascript':85 'key':41 'liquibas':38,91 'manag':8,50 'migrat':88,94 'modifi':15 'mysql':33,90 'node':83 'out-of-sync':58 'pipelin':68 'plain':19 'postgresql':31 'provis':11 'releas':69 'requir':82 'resourc':54,62 'schema':3,7,17,49,87 'seamless':64 'ship':78 'specifi':73 'sql':2,23,89 'sql-schema-control':1 'stabl':25 'support':30 'sync':13,61 'terraform':40 'tool':9 'track':12 'two':48 'type':80 'typescript':79,95 'use':18 'version':21,26 'version-control':20","created_at":"2026-06-05T17:02:13.474552+00:00","updated_at":"2026-06-05T17:02:13.474552+00:00","problems":[{"fix":"Run: npm install pg --save-dev","cause":"Missing PostgreSQL driver when using Postgres connection.","error":"Error: Cannot find module 'pg'"},{"fix":"Ensure the database server is running and the host/port are correct in the connection config.","cause":"Database server is not running or connection config is wrong.","error":"Error: connect ECONNREFUSED 127.0.0.1:5432"},{"fix":"Grant USAGE, CREATE on schema and DDL privileges to the user. For example: GRANT ALL ON SCHEMA public TO your_user;","cause":"The database user lacks DDL permissions.","error":"Error: permission denied for schema public"},{"fix":"Pass a connection object directly instead of a module path, or ensure the module exports a promiseConfig function.","cause":"The connection config object is missing the promiseConfig function when using a module path.","error":"TypeError: promiseConfig is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ehmpathy/sql-schema-control","github":"https://github.com/ehmpathy/sql-schema-control","docs":null,"changelog":null,"pypi":null,"npm":"sql-schema-control","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}