mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 17:25:00 +03:00
33 lines
763 B
TypeScript
33 lines
763 B
TypeScript
|
|
import { Comparer, DatabaseFunction, Reason } from 'src/sql-tools/types';
|
||
|
|
|
||
|
|
export const compareFunctions: Comparer<DatabaseFunction> = {
|
||
|
|
onMissing: (source) => [
|
||
|
|
{
|
||
|
|
type: 'function.create',
|
||
|
|
function: source,
|
||
|
|
reason: Reason.MissingInTarget,
|
||
|
|
},
|
||
|
|
],
|
||
|
|
onExtra: (target) => [
|
||
|
|
{
|
||
|
|
type: 'function.drop',
|
||
|
|
functionName: target.name,
|
||
|
|
reason: Reason.MissingInSource,
|
||
|
|
},
|
||
|
|
],
|
||
|
|
onCompare: (source, target) => {
|
||
|
|
if (source.expression !== target.expression) {
|
||
|
|
const reason = `function expression has changed (${source.expression} vs ${target.expression})`;
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
type: 'function.create',
|
||
|
|
function: source,
|
||
|
|
reason,
|
||
|
|
},
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
return [];
|
||
|
|
},
|
||
|
|
};
|