feat: initial kysely migration file (#17678)

This commit is contained in:
Jason Rasmussen 2025-04-17 17:38:47 -04:00 committed by GitHub
parent e275f2d8b3
commit 6474a78b8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 499 additions and 139 deletions

View file

@ -6,6 +6,13 @@ export const processTables: Processor = (builder, items) => {
for (const {
item: { options, object },
} of items.filter((item) => item.type === 'table')) {
const test = readMetadata(object);
if (test) {
throw new Error(
`Table ${test.name} has already been registered. Does ${object.name} have two @Table() decorators?`,
);
}
const tableName = options.name || asSnakeCase(object.name);
writeMetadata(object, { name: tableName, options });

View file

@ -50,12 +50,8 @@ const asFunctionExpression = (options: FunctionOptions) => {
}
if ('body' in options) {
sql.push(
//
`AS $$`,
' ' + options.body.trim(),
`$$;`,
);
const body = options.body;
sql.push(...(body.includes('\n') ? [`AS $$`, ' ' + body.trim(), `$$;`] : [`AS $$${body}$$;`]));
}
return sql.join('\n ').trim();