mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: sql-tools overrides (#19796)
This commit is contained in:
parent
1f9813a28e
commit
df4a27e8a7
114 changed files with 775 additions and 289 deletions
29
server/src/sql-tools/comparers/override.comparer.ts
Normal file
29
server/src/sql-tools/comparers/override.comparer.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { Comparer, DatabaseOverride, Reason } from 'src/sql-tools/types';
|
||||
|
||||
export const compareOverrides: Comparer<DatabaseOverride> = {
|
||||
onMissing: (source) => [
|
||||
{
|
||||
type: 'OverrideCreate',
|
||||
override: source,
|
||||
reason: Reason.MissingInTarget,
|
||||
},
|
||||
],
|
||||
onExtra: (target) => [
|
||||
{
|
||||
type: 'OverrideDrop',
|
||||
overrideName: target.name,
|
||||
reason: Reason.MissingInSource,
|
||||
},
|
||||
],
|
||||
onCompare: (source, target) => {
|
||||
if (source.value.name !== target.value.name || source.value.sql !== target.value.sql) {
|
||||
const sourceValue = JSON.stringify(source.value);
|
||||
const targetValue = JSON.stringify(target.value);
|
||||
return [
|
||||
{ type: 'OverrideUpdate', override: source, reason: `value is different (${sourceValue} vs ${targetValue})` },
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue