Relational-schema is a utility package designed to introspect and generate a comprehensive, semantic schema representation of a relational database (currently supporting PostgreSQL and MySQL) into various developer-friendly formats. It outputs schema definitions as JavaScript, TypeScript, CommonJS, or JSON files. Currently at version 0.6.3, the package receives regular updates, primarily bug fixes and feature enhancements, though minor version increments (0.x.x) may introduce breaking changes without a major version bump. Unlike simplified ORM models, it provides a detailed schema including full table definitions, columns with types, default values, nullability, keys, constraints, unique key combinations, and intricate table relations with human-readable aliases, soft-delete identification, and enums. This tool aims to leverage the strictness of relational schemas for building more robust and automated tooling, such as the Gybson query client.
npm install relational-schemaVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic database introspection and schema file generation using the library's core functions, including setting environment variables for credentials and handling output files. It also outlines the more common CLI usage.
Pin package versions in your `package.json` to prevent unintended updates, and carefully review the GitHub release notes or changelog before performing any minor version upgrades.
Grant `SELECT` permissions on relevant system schemas and tables to the configured database user. For PostgreSQL, this typically includes `pg_catalog` and `information_schema`.
Verify that the database client is properly installed and configured on the system where `relational-schema` is executed, and ensure that all connection parameters (host, port, user, password, database) are correct and the database is accessible.
If your database includes partitioned tables, carefully review the generated schema after updating to `0.6.3` or newer to confirm it aligns with your expected database structure. This update is generally a positive refinement.
Verify your database server's operational status and confirm the `host` and `port` values in your configuration accurately reflect your database connection.
Install the package globally using `npm install -g relational-schema`, or execute the command directly via `npx relational-schema introspect` to use the local installation.
Grant `SELECT` permissions on the relevant system schemas and tables (e.g., `pg_catalog`, `information_schema`) to the database user used by `relational-schema`.
Create a `relation-config.json` file in your project root or current directory, or use the `--config <path/to/config.json>` flag to specify its exact location.
No dependency data recorded yet.