mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: initial kysely migration file (#17678)
This commit is contained in:
parent
e275f2d8b3
commit
6474a78b8b
13 changed files with 499 additions and 139 deletions
|
|
@ -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 });
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue