Files
immich/server/src/sql-tools/processors/table.processor.ts
Jason Rasmussen 9e48ae3052 feat: naming strategy (#19848)
* feat: naming strategy

* feat: detect renames
2025-07-11 11:35:10 -04:00

28 lines
722 B
TypeScript

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 || ctx.getNameFor({ type: 'table', name: object.name }),
columns: [],
constraints: [],
indexes: [],
triggers: [],
synchronize: options.synchronize ?? true,
},
options,
object,
);
}
};