How DrawDB Handles Schema Migrations Between Different Database Types
DrawDB does not support incremental schema migrations; instead, it generates complete DDL scripts for each target database engine using dedicated export utilities.
DrawDB takes a fundamentally different approach to schema migrations than traditional database migration tools. Rather than computing differences between schema versions, the open-source diagram tool converts your entire data model into a fresh create-script tailored for your chosen database engine. This design choice shapes how developers must approach evolving their database structures when working with DrawDB.
What DrawDB Actually Provides: Full DDL Export
When you request schema output from DrawDB, the application produces complete DDL statements that recreate your entire database from scratch. This is implemented across six supported database engines through specialized converter functions.
The core architecture resides in src/utils/exportSQL/generic.js, where each target DBMS has its own generator:
- MySQL:
jsonToMySQL() - PostgreSQL:
jsonToPostgreSQL() - SQLite:
jsonToSQLite() - MariaDB:
jsonToMariaDB() - SQL Server:
jsonToSQLServer() - Oracle SQL:
jsonToOracleSQL()
These functions iterate through your diagram's tables, fields, constraints, and indexes—emitting native DDL syntax for the selected engine.
The Type Mapping Engine
Database-specific type translation happens through getTypeString(field, currentDb, dbms, baseType) in src/utils/exportSQL/generic.js. This function switches on the dbms parameter to return appropriate native types.
// Examples of type mapping decisions:
// MySQL: VARCHAR(255)
// SQLite: TEXT
// SQL Server: NVARCHAR(255)
// PostgreSQL: VARCHAR(255)
The function receives context about both source and target databases through parameters defined in src/data/constants.js, where the DB enum identifies each supported engine.
Why Migration Generation Is Explicitly Disabled
DrawDB's UI actively prevents users from requesting migrations for generic diagram types. The internationalization files contain explicit messaging for this limitation.
In src/i18n/locales/en.js, the string migration_not_supported_generic informs users that migrations are not supported for their selected diagram type. This reflects the architectural reality: the codebase contains no delta-computation logic to identify changes between schema versions.
Generating Schema Scripts: Practical Examples
To export your diagram to SQL, import the appropriate converter and pass your diagram object:
// Generate a complete MySQL DDL script
import { jsonToMySQL } from '@/utils/exportSQL/generic';
const mysqlScript = jsonToMySQL(diagramObject);
// Output contains CREATE TABLE, INDEX, FOREIGN KEY statements
// Generate a complete PostgreSQL DDL script
import { jsonToPostgreSQL } from '@/utils/exportSQL/generic';
const postgresScript = jsonToPostgreSQL(diagramObject);
// Output uses PostgreSQL-specific syntax and types
Each call produces a standalone script that can be executed directly against a fresh database instance. There is no equivalent generateMigration() API that would output only incremental changes.
The Per-Engine Export Implementation
The src/utils/exportSQL/ directory structure reflects DrawDB's engine-specific approach. While generic.js contains the shared type-mapping logic and most DDL generators, the system is designed to accommodate dialect-specific variations through the DB enum reference in src/data/constants.js and database metadata in src/data/databases.js.
Each generator follows the same pattern:
- Iterate
obj.tablesandobj.typesfrom the diagram model - Call
getTypeString()for every column to obtain native types - Append primary key, unique constraints, foreign keys, and indexes
- Add database-specific comment syntax where applicable
Implications for Schema Migration Workflows
Developers using DrawDB for schema migrations between different database types must adapt their workflow. Since DrawDB handles schema migrations by generating full recreate-scripts rather than incremental updates, typical approaches include:
- Version controlling exported DDL scripts as snapshots of each schema state
- Using external diff tools to compare generated scripts between diagram versions
- Applying scripts to fresh environments rather than migrating existing data
This approach prioritizes portability across database engines over incremental change tracking—a trade-off that simplifies cross-database compatibility but requires complementary tools for production migration management.
Summary
- DrawDB does not generate incremental migrations; the UI explicitly disables this functionality with
migration_not_supported_genericmessages - Schema export relies on complete DDL generation through engine-specific functions in
src/utils/exportSQL/generic.js - Type translation occurs via
getTypeString(), which maps diagram types to native database types using theDBenum fromsrc/data/constants.js - Six database engines are supported through dedicated
jsonTo*functions that produce standalone create-scripts - Developers must use external tools or manual processes to track schema changes between diagram versions
Frequently Asked Questions
Can DrawDB generate delta migrations between two versions of my diagram?
No. DrawDB has no logic to compute differences between schema versions. The codebase lacks any delta-comparison functions; instead, it always exports the complete current state as a fresh DDL script. You would need to use external diff tools on exported scripts to identify changes.
How do I convert a DrawDB diagram from MySQL to PostgreSQL?
Export your diagram using jsonToPostgreSQL() instead of jsonToMySQL(). The same diagram object generates appropriate DDL for either engine—DrawDB handles type mapping automatically. For example, MySQL VARCHAR becomes PostgreSQL VARCHAR, while engine-specific features may translate to closest equivalents or be omitted.
Why does DrawDB say migrations are "not supported" when I try to generate them?
The UI checks your diagram type and displays migration_not_supported_generic from the i18n locale files for generic diagrams. This accurately reflects that DrawDB only provides full-schema export utilities, not incremental migration generation. The application prevents misleading expectations about its capabilities.
What files should I examine to understand DrawDB's schema export logic?
Start with src/utils/exportSQL/generic.js for the core implementation including getTypeString() and all jsonTo* generators. Reference src/data/constants.js for the DB enum, src/data/databases.js for supported engine definitions, and src/i18n/locales/en.js for the migration limitation messaging.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →