MCPcopy
hub / github.com/drawdb-io/drawdb / toTypeDefinition

Function toTypeDefinition

src/utils/migrations/diffToSQL.js:221–231  ·  view source on GitHub ↗
(type, database, q)

Source from the content-addressed store, hash-verified

219}
220
221function toTypeDefinition(type, database, q) {
222 if (!type || !databases[database]?.hasTypes) return null;
223 const fields = (type.fields || [])
224 .map((f) => `\t${q(f.name)} ${f.type}`)
225 .join(",\n");
226 let s = `CREATE TYPE ${q(type.name)} AS (\n${fields}\n);`;
227 if (type.comment?.trim()) {
228 s += `\nCOMMENT ON TYPE ${q(type.name)} IS '${escapeQuotes(type.comment)}';`;
229 }
230 return s;
231}
232
233function toEnumDefinition(e, database, q) {
234 if (!e || !databases[database]?.hasEnums) return null;

Callers 1

generateMigrationSQLFunction · 0.85

Calls 1

escapeQuotesFunction · 0.90

Tested by

no test coverage detected