mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 17:25:00 +03:00
refactor: sql-tools (#19717)
This commit is contained in:
32
server/src/sql-tools/comparers/function.comparer.ts
Normal file
32
server/src/sql-tools/comparers/function.comparer.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Comparer, DatabaseFunction, Reason } from 'src/sql-tools/types';
|
||||
|
||||
export const compareFunctions: Comparer<DatabaseFunction> = {
|
||||
onMissing: (source) => [
|
||||
{
|
||||
type: 'FunctionCreate',
|
||||
function: source,
|
||||
reason: Reason.MissingInTarget,
|
||||
},
|
||||
],
|
||||
onExtra: (target) => [
|
||||
{
|
||||
type: 'FunctionDrop',
|
||||
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: 'FunctionCreate',
|
||||
function: source,
|
||||
reason,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user