This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
how import SQL DDL MSSQL ? #7
Labels
enhancement
New feature or request
Comments
DDL Parser currently relies on sql-ddl-to-json-schema, so only mysql is supported. Instead, you can try after transformation with mysql delimitation. MySQL syntax CREATE TABLE users (
id INT(11) NOT NULL AUTO_INCREMENT,
nickname VARCHAR(255) NOT NULL,
deleted_at TIMESTAMP NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
) ENGINE MyISAM COMMENT 'All system users';
ALTER TABLE users ADD UNIQUE KEY unq_nick (nickname); Example of converting mssql data type const dataTypeMapping = [
{ mssql: "numeric", mysql: "FLOAT" },
{ mssql: "smallmoney", mysql: "FLOAT" },
{ mssql: "money", mysql: "DOUBLE" },
{ mssql: "real", mysql: "FLOAT" },
{ mssql: "datetimeoffset", mysql: "DATETIME" },
{ mssql: "datetime2", mysql: "DATETIME" },
{ mssql: "smalldatetime", mysql: "DATETIME" },
{ mssql: "nchar", mysql: "CHAR" },
{ mssql: "nvarchar", mysql: "VARCHAR" },
{ mssql: "ntext", mysql: "TEXT" },
{ mssql: "image", mysql: "BLOB" },
{ mssql: "sql_variant", mysql: "VARCHAR" },
{ mssql: "xml", mysql: "BLOB" },
{ mssql: "geography", mysql: "VARCHAR" },
];
const fs = require("fs");
const mssqlTEXT = fs.readFileSync("./mssqlDDL.sql", "utf8");
let convertText = mssqlTEXT;
convertText = convertText.replace(/GO/gi, ";");
dataTypeMapping.forEach((mapping) => {
convertText = convertText.replace(
new RegExp(mapping.mssql, "gi"),
mapping.mysql
);
});
console.log(convertText);
fs.writeFileSync("./mssqlDDLConvertDataType.sql", convertText); |
Would love to see PostgreSQL import capability here. |
SQL DDL parser is working! I'll try my best. |
Current Support Syntax Here |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I cannot Import SQL DDL MSSQL, I need solution from MSSQL.
can help me ?
The text was updated successfully, but these errors were encountered: