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

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

24 lines
703 B
TypeScript

import { ConstraintType, Processor } from 'src/sql-tools/types';
export const processCheckConstraints: Processor = (ctx, items) => {
for (const {
item: { object, options },
} of items.filter((item) => item.type === 'checkConstraint')) {
const table = ctx.getTableByObject(object);
if (!table) {
ctx.warnMissingTable('@Check', object);
continue;
}
const tableName = table.name;
table.constraints.push({
type: ConstraintType.CHECK,
name: options.name || ctx.getNameFor({ type: 'check', tableName, expression: options.expression }),
tableName,
expression: options.expression,
synchronize: options.synchronize ?? true,
});
}
};