mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 09:14:58 +03:00
27 lines
653 B
TypeScript
27 lines
653 B
TypeScript
|
|
import { SqlTransformer } from 'src/sql-tools/to-sql/transformers/types';
|
||
|
|
import { DatabaseFunction, SchemaDiff } from 'src/sql-tools/types';
|
||
|
|
|
||
|
|
export const transformFunctions: SqlTransformer = (item: SchemaDiff) => {
|
||
|
|
switch (item.type) {
|
||
|
|
case 'function.create': {
|
||
|
|
return asFunctionCreate(item.function);
|
||
|
|
}
|
||
|
|
|
||
|
|
case 'function.drop': {
|
||
|
|
return asFunctionDrop(item.functionName);
|
||
|
|
}
|
||
|
|
|
||
|
|
default: {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const asFunctionCreate = (func: DatabaseFunction): string => {
|
||
|
|
return func.expression;
|
||
|
|
};
|
||
|
|
|
||
|
|
const asFunctionDrop = (functionName: string): string => {
|
||
|
|
return `DROP FUNCTION ${functionName};`;
|
||
|
|
};
|