UNPKG

ddl-manager

Version:

store postgres procedures and triggers in files

55 lines 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MainComparator = void 0; const Migration_1 = require("../Migrator/Migration"); const CacheComparator_1 = require("./CacheComparator"); const TriggersComparator_1 = require("./TriggersComparator"); const FunctionsComparator_1 = require("./FunctionsComparator"); const IndexComparator_1 = require("./IndexComparator"); class MainComparator { constructor(driver, database, fs) { this.migration = Migration_1.Migration.empty(); this.cache = new CacheComparator_1.CacheComparator(driver, database, fs, this.migration); this.functions = new FunctionsComparator_1.FunctionsComparator(driver, database, fs, this.migration, this.cache.getAllCacheTriggers()); this.triggers = new TriggersComparator_1.TriggersComparator(driver, database, fs, this.migration, this.cache.getAllCacheTriggers()); this.indexes = new IndexComparator_1.IndexComparator(driver, database, fs, this.migration); } static async compare(driver, database, fs) { const comparator = new MainComparator(driver, database, fs); return await comparator.compare(); } static async logAllFuncsMigration(driver, database, fs) { const comparator = new MainComparator(driver, database, fs); return await comparator.logAllFuncsMigration(); } static async refreshCache(driver, database, fs, targetTablesOrColumns) { const comparator = new MainComparator(driver, database, fs); return await comparator.refreshCache(targetTablesOrColumns); } async compare() { // need add new functions to migration // before rebuild cache this.functions.create(); await this.dropOldObjects(); await this.cache.create(); this.triggers.create(); this.indexes.create(); return this.migration; } async logAllFuncsMigration() { this.functions.createLogFuncs(); return this.migration; } async refreshCache(targetTablesOrColumns) { await this.cache.refreshCache(targetTablesOrColumns); return this.migration; } async dropOldObjects() { this.functions.drop(); this.triggers.drop(); await this.cache.drop(); this.indexes.drop(); } } exports.MainComparator = MainComparator; //# sourceMappingURL=MainComparator.js.map