dbmodel is a command-line utility and JavaScript library within the DbGate ecosystem, designed for managing SQL database schemas. It allows users to `load` an existing database structure into a local file-based project, `deploy` a local project's structure to a database, and `build` SQL scripts offline from a project. The model is represented as a collection of YAML files for tables (columns, indexes, primary keys, foreign keys) and SQL files for views, stored procedures, and functions. It leverages DbGate tooling and plugins to support various databases including MySQL, MS SQL Server, PostgreSQL, SQLite, Oracle, MariaDB, CockroachDB, and Amazon Redshift. The current stable version is 7.1.9, with frequent patch releases addressing fixes and minor enhancements. Its key differentiator is its model-first approach for schema management, avoiding data-loss operations during deployment by design, and its integration with the broader DbGate platform. For programmatic JavaScript interface usage, the related `dbgate-api` package is recommended.
npm install dbmodelVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic use of `dbmodel` to load a database schema, deploy changes, and build an SQL script. This requires `dbgate-api` and specific `dbgate-plugin-*` packages.
Manually review and apply destructive schema changes (e.g., dropping columns or tables) after `dbmodel deploy` by writing custom SQL or using other database management tools.
Review DbGate cloud connection configurations and update endpoint URLs or related settings as per DbGate documentation for new infrastructure.
Install the required database plugin: `npm install --save dbgate-plugin-<engine_name>` and specify it with the `-e` or `--engine` flag in CLI commands, or in connection options programmatically.
Upgrade to `dbmodel` version 7.1.9 or higher to ensure proper validation and mitigation of these security vulnerabilities. Sanitize all user-provided function and file names if using older versions.
Run `npm install --save dbgate-plugin-mssql` (or the appropriate plugin for your database) in your project.
Double-check server, user, password, database, and engine parameters. Ensure the engine string (e.g., 'mssql@dbgate-plugin-mssql') is correctly formatted and the plugin is installed.
Ensure you are using one of the supported commands: `load`, `deploy`, or `build`. Refer to the `dbmodel --help` output for available commands.