mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
28 lines
747 B
TypeScript
28 lines
747 B
TypeScript
import { asSnakeCase } from 'src/sql-tools/helpers';
|
|
import { Processor } from 'src/sql-tools/types';
|
|
|
|
export const processTables: Processor = (ctx, items) => {
|
|
for (const {
|
|
item: { options, object },
|
|
} of items.filter((item) => item.type === 'table')) {
|
|
const test = ctx.getTableByObject(object);
|
|
if (test) {
|
|
throw new Error(
|
|
`Table ${test.name} has already been registered. Does ${object.name} have two @Table() decorators?`,
|
|
);
|
|
}
|
|
|
|
ctx.addTable(
|
|
{
|
|
name: options.name || asSnakeCase(object.name),
|
|
columns: [],
|
|
constraints: [],
|
|
indexes: [],
|
|
triggers: [],
|
|
synchronize: options.synchronize ?? true,
|
|
},
|
|
options,
|
|
object,
|
|
);
|
|
}
|
|
};
|