Add erdn sql command for SQL DDL export with multi-DBMS support#6
Merged
Conversation
Agent-Logs-Url: https://github.com/headercat/erdn-lang/sessions/b3efad42-e0a8-45f1-b22d-38a5e4ce981e Co-authored-by: nemorize <51209191+nemorize@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
nemorize
April 14, 2026 00:00
View session
🗂 ER Diagram Render✅ Tests passed —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
sqlsubcommand that generates SQL DDL from an.erdnschema, targeting MySQL, PostgreSQL, MSSQL, Oracle, or SQLite via--dbms.New command
Defaults to
mysql. Output file defaults to<schema>.sql.What gets generated
CREATE TABLEwith DBMS-appropriate column typesPRIMARY KEYtable constraintsAUTO_INCREMENT(MySQL),IDENTITY(1,1)(MSSQL),GENERATED ALWAYS AS IDENTITY(PostgreSQL/Oracle),INTEGER PRIMARY KEY AUTOINCREMENT(SQLite)CREATE INDEXforindexedcolumnslinkdeclarations —ALTER TABLE … ADD CONSTRAINT … FOREIGN KEYfor most DBMSes; inlineFOREIGN KEYtable constraints for SQLite (withPRAGMA foreign_keys = ON)Type mapping highlights
boolTINYINT(1)BOOLEANBITNUMBER(1)INTEGERvarchar(n)VARCHAR(n)VARCHAR(n)NVARCHAR(n)VARCHAR2(n)TEXTtextTEXTTEXTNVARCHAR(MAX)CLOBTEXTbigintBIGINTBIGINTBIGINTNUMBER(19)INTEGERuuidCHAR(36)UUIDUNIQUEIDENTIFIERCHAR(36)TEXTNOW()defaults are translated per dialect (GETDATE()for MSSQL,SYSDATEfor Oracle,CURRENT_TIMESTAMPfor SQLite). Unknown types pass through uppercased.Changes
internal/sqlexport/sqlexport.go— new package; all generation logic isolated hereinternal/sqlexport/sqlexport_test.go— tests covering all five DBMSes, type mappings, self-referential links, default value translation, indexes, and FK outputcmd/erdn/main.go— wiresrunSQL()into the subcommand dispatcherREADME.md/website/guide.md— documents the new command and DBMS table