mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 01:11:32 +03:00
24 lines
703 B
TypeScript
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,
|
|
});
|
|
}
|
|
};
|