{"id":19256480,"url":"https://github.com/paroi-tech/universal-ddl","last_synced_at":"2025-06-10T12:08:57.710Z","repository":{"id":57167097,"uuid":"177257239","full_name":"paroi-tech/universal-ddl","owner":"paroi-tech","description":"Parse DDL scripts in a universal format, then generates DDL scripts for several DBMS.","archived":false,"fork":false,"pushed_at":"2020-06-09T07:12:08.000Z","size":226,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T21:19:01.115Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paroi-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-23T07:16:08.000Z","updated_at":"2024-07-08T22:51:21.000Z","dependencies_parsed_at":"2022-08-30T13:10:11.776Z","dependency_job_id":null,"html_url":"https://github.com/paroi-tech/universal-ddl","commit_stats":null,"previous_names":["tomko-team/universal-ddl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Funiversal-ddl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Funiversal-ddl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Funiversal-ddl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Funiversal-ddl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paroi-tech","download_url":"https://codeload.github.com/paroi-tech/universal-ddl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paroi-tech%2Funiversal-ddl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259072781,"owners_count":22801084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T19:05:54.954Z","updated_at":"2025-06-10T12:08:57.686Z","avatar_url":"https://github.com/paroi-tech.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Universal DDL — `universal-ddl`\n\n[![Build Status](https://travis-ci.com/paroi-tech/universal-ddl.svg?branch=master)](https://travis-ci.com/paroi-tech/universal-ddl)\n[![Dependencies Status](https://david-dm.org/paroi-tech/universal-ddl/status.svg)](https://david-dm.org/paroi-tech/universal-ddl)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/aaf18d43bfa14f7d9de6e4bf2299588d)](https://www.codacy.com/manual/paleo/universal-ddl?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=paroi-tech/universal-ddl\u0026utm_campaign=Badge_Grade)\n[![npm](https://img.shields.io/npm/dm/universal-ddl)](https://www.npmjs.com/package/universal-ddl)\n![Type definitions](https://img.shields.io/npm/types/universal-ddl)\n[![GitHub](https://img.shields.io/github/license/paroi-tech/universal-ddl)](https://github.com/paroi-tech/universal-ddl)\n\nParse DDL scripts in a universal format, then generates DDL scripts for several DBMS.\n\nThis package provides a CLI and a programmatic API for Node.js.\n\n## How to use the Command Line Interface\n\nExample:\n\n```sh\nnpx universal-ddl --autofix --postgresql --sqlite path/to/ddl-file.sql\n```\n\nThis command will generate two new files `path/to/ddl-file.postgresql.sql` and `path/to/ddl-file.sqlite.sql`.\n\nAvailable options:\n\n```\n  -h, --help                   Print this help message.\n  -a, --autofix                Enable autofix.\n  -o, --output-dir directory   The output directory (optional).\n  -p, --postgresql             Generate a DDL for Postgresql.\n  -s, --sqlite                 Generate a DDL for SQLite.\n  -m, --mariadb                Generate a DDL for Mariadb or MySQL.\n  -u, --universal-ddl          Generate a DDL using the Universal DDL syntax.\n  -d, --generate-drop          Generate drop statements (except for the Universal DDL output).\n  -e, --encoding string        Encoding for input and output file(s) (default is utf8).\n  -f, --force                  Overwrite output files.\n  --src file                   The source file (by default at last position).\n```\n\n## How to use the API from Node.js\n\nInstall as a dependency:\n\n```sh\nnpm install universal-ddl\n```\n\nThen, use it:\n\n```js\nconst {\n  parseDdl,\n  generateDdl,\n  createRds,\n  parseDdlToRds,\n} = require(\"universal-ddl\");\n\nconst input = `\n  create table t1 (\n    a integer not null primary key autoincrement\n  );\n  `;\n\n// Parse the input DDL and create an AST\nconst ast = parseDdl(input, {\n  autofix: true,\n  checkConsistency: true,\n  freeze: true,\n});\n\n// The AST is a pure JSON format, it can be stringified\nconsole.log(JSON.stringify(ast, undefined, 2));\n\n// How to generate a specific DDL for your DBMS\nconsole.log(generateDdl(ast, \"postgresql\"));\n\n// Create a RDS (Relational Database Structure). It is a POJO object, higher\n// level than an AST. It is recursive, so it can't be stringified.\nconst rds = createRds(ast, { freeze: true });\n\n// Or, create the same RDS using a shortcut\nconst rds2 = parseDdlToRds(input, { autofix: true, freeze: true });\n\n// Use the RDS\nconsole.log(rds.tables[\"t1\"].columns[\"a\"].constraints.notNull); // true\n```\n\n## Contribute\n\n### Install and build\n\nWe need a JVM (Java Virtual Machine) to build the parser because we use [ANTLR](https://www.antlr.org/), which is a Java program. So, at first, install a JVM on your system.\n\nIn a terminal, open the cloned `universal-ddl/` repository. Then:\n\n```sh\n# Download once the ANTLR JAR file in the project's root directory\nwget https://www.antlr.org/download/antlr-4.7.2-complete.jar\n\n# Install once all Node.js dependencies\nnpm install\n\n# Build\nnpm run build\n\n# Run tests\nnpm run test\n```\n\n### Development environment\n\nWith VS Code, our recommanded plugins are:\n\n- **ANTLR4 grammar syntax support** from Mike Lischke (`mike-lischke.vscode-antlr4`)\n- **TSLint** from Microsoft (`ms-vscode.vscode-typescript-tslint-plugin`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparoi-tech%2Funiversal-ddl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparoi-tech%2Funiversal-ddl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparoi-tech%2Funiversal-ddl/lists"}