Files
immich/server/src/sql-tools/comparers/enum.comparer.ts

39 lines
909 B
TypeScript
Raw Normal View History

import { Comparer, DatabaseEnum, Reason } from 'src/sql-tools/types';
export const compareEnums: Comparer<DatabaseEnum> = {
onMissing: (source) => [
{
2025-07-03 10:59:17 -04:00
type: 'EnumCreate',
enum: source,
reason: Reason.MissingInTarget,
},
],
onExtra: (target) => [
{
2025-07-03 10:59:17 -04:00
type: 'EnumDrop',
enumName: target.name,
reason: Reason.MissingInSource,
},
],
onCompare: (source, target) => {
if (source.values.toString() !== target.values.toString()) {
// TODO add or remove values if the lists are different or the order has changed
const reason = `enum values has changed (${source.values} vs ${target.values})`;
return [
{
2025-07-03 10:59:17 -04:00
type: 'EnumDrop',
enumName: source.name,
reason,
},
{
2025-07-03 10:59:17 -04:00
type: 'EnumCreate',
enum: source,
reason,
},
];
}
return [];
},
};