feat: sql-tools overrides (#19796)

This commit is contained in:
Jason Rasmussen
2025-07-08 08:17:40 -04:00
committed by GitHub
parent 1f9813a28e
commit df4a27e8a7
114 changed files with 775 additions and 289 deletions

View File

@@ -0,0 +1,50 @@
import { asFunctionCreate } from 'src/sql-tools/transformers/function.transformer';
import { asIndexCreate } from 'src/sql-tools/transformers/index.transformer';
import { asTriggerCreate } from 'src/sql-tools/transformers/trigger.transformer';
import { Processor } from 'src/sql-tools/types';
export const processOverrides: Processor = (ctx) => {
if (ctx.options.overrides === false) {
return;
}
for (const func of ctx.functions) {
if (!func.synchronize) {
continue;
}
ctx.overrides.push({
name: `function_${func.name}`,
value: { type: 'function', name: func.name, sql: asFunctionCreate(func) },
synchronize: true,
});
}
for (const { triggers, indexes } of ctx.tables) {
for (const trigger of triggers) {
if (!trigger.synchronize) {
continue;
}
ctx.overrides.push({
name: `trigger_${trigger.name}`,
value: { type: 'trigger', name: trigger.name, sql: asTriggerCreate(trigger) },
synchronize: true,
});
}
for (const index of indexes) {
if (!index.synchronize) {
continue;
}
if (index.expression || index.using || index.with || index.where) {
ctx.overrides.push({
name: `index_${index.name}`,
value: { type: 'index', name: index.name, sql: asIndexCreate(index) },
synchronize: true,
});
}
}
}
};