{"id":48701,"library":"nexusql","title":"nexusql: PostgreSQL Migration Toolkit with DBML Support","description":"nexusql is a database migration toolkit for PostgreSQL that uses DBML (Database Markup Language) schema definitions to generate and apply migration SQL. Current stable version is 0.9.10. It is actively maintained with weekly releases. Unlike other migration tools, nexusql integrates with migra (a Python diffing engine) to produce accurate migration SQL by comparing the live database schema against the DBML file. It also generates TypeScript type definitions from the schema, making it particularly useful for full-stack TypeScript projects. Major features include CLI commands for initialization, migration generation, applying/rolling back migrations, and type generation. The tool bundles most dependencies except migra, which must be installed separately via pip.","status":"active","version":"0.9.10","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","postgresql","postgres","database","migration","schema","dbml","sql","cli","typescript"],"install":[{"cmd":"npm install nexusql","lang":"bash","label":"npm"},{"cmd":"yarn add nexusql","lang":"bash","label":"yarn"},{"cmd":"pnpm add nexusql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"External tool for diffing database schemas, required by nexusql to generate migration SQL","package":"migra (Python)","optional":false},{"reason":"Runtime requirement; older versions not supported","package":"Node.js >=18","optional":false}],"imports":[{"note":"nexusql is primarily a CLI tool; no programmatic API is exposed. Use npx for one-off usage.","wrong":"npm install -g nexusql && nexusql (works but npx avoids global install)","symbol":"cli","correct":"npx nexusql <command>"},{"note":"nexusql uses DBML syntax (square brackets for annotations), not raw SQL DDL. Common mistake: using SQL keywords like PRIMARY KEY, NOT NULL instead of DBML equivalents.","wrong":"Table users { id uuid PRIMARY KEY }","symbol":"DBML schema syntax","correct":"Table users { id uuid [pk] }"},{"note":"nexusql does not expose a JavaScript/TypeScript API; type generation is via CLI command only.","wrong":"npm run types (custom script required)","symbol":"TypeScript type generation","correct":"nexusql types -o types/db.d.ts"}],"quickstart":{"code":"# Ensure migra is installed\npip install migra\n\n# Install nexusql globally (or use npx)\nnpm install -g nexusql\n\n# Initialize project\nnexusql init\n\n# Set your database URL in .env\ncat > .env <<EOF\nDATABASE_URL=postgres://user:password@localhost:5432/mydb\nEOF\n\n# Create schema.dbml\ncat > schema.dbml <<EOF\nTable users {\n  id uuid [pk, default: `uuid_generate_v4()`]\n  email varchar(255) [unique, not null]\n  name varchar(255)\n  created_at timestamp [default: `now()`]\n}\nEOF\n\n# Generate and apply migrations\nnexusql migrate -a -y","lang":"bash","description":"Shows complete setup: install migra, nexusql, init project, configure DB URL, create DBML schema, and run migration."},"warnings":[{"fix":"Upgrade Node.js to version 18 or later.","message":"Node.js version must be >=18.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Run 'pip install migra' before using nexusql.","message":"migra is an external Python dependency that must be installed via pip.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set the password as-is in .env (e.g., password@123) and nexusql will encode it.","message":"Special characters in DATABASE_URL password are handled automatically but must not be URL-encoded in the .env file.","severity":"gotcha","affected_versions":">=0.9.4"},{"fix":"Replace SQL keywords like NOT NULL with DBML attributes such as [not null].","message":"Using SQL DDL keywords in schema.dbml is not supported; use DBML syntax.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.9.10':34 'accur':56 'activ':37 'also':70 'appli':27 'applying/rolling':97 'back':98 'bundl':105 'cli':91,125 'command':92 'compar':60 'current':30 'databas':11,19,63,120 'dbml':6,18,67,123 'definit':23,74 'depend':107 'dif':52 'engin':53 'except':108 'featur':89 'file':68 'full':84 'full-stack':83 'generat':25,71,96,102 'includ':90 'initi':94 'instal':113 'integr':47 'javascript':117 'languag':21 'live':62 'maintain':38 'major':88 'make':78 'markup':20 'migra':49,109 'migrat':3,12,28,44,57,95,99,121 'must':111 'nexusql':1,8,46 'particular':80 'pip':116 'postgr':119 'postgresql':2,15,118 'produc':55 'project':87 'python':51 'releas':41 'schema':22,64,77,122 'separ':114 'sql':29,58,124 'stabl':31 'stack':85 'support':7 'tool':45,104 'toolkit':4,13 'type':73,101 'typescript':72,86,126 'unlik':42 'use':17,81 'version':32 'via':115 'week':40","created_at":"2026-06-07T16:58:00.674747+00:00","updated_at":"2026-06-07T16:58:00.674747+00:00","problems":[{"fix":"Ensure PostgreSQL is running on localhost and check DATABASE_URL spelling.","cause":"Database host not resolvable; local server not running or wrong host.","error":"Error: Could not connect to database: getaddrinfo ENOTFOUND localhost"},{"fix":"Run 'pip install migra' and ensure Python is in PATH.","cause":"migra Python package not installed.","error":"Error: 'migra' is not recognized as an internal or external command"},{"fix":"Replace 'PRIMARY KEY' with '[pk]' and use [unique, not null] etc.","cause":"Used SQL keywords instead of DBML syntax in schema.dbml.","error":"Error: Invalid schema: unexpected token 'PRIMARY'"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"nexusql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}