fix: triggers not exported if related table not included

This commit is contained in:
Fabio Di Stasio 2023-04-04 11:55:39 +02:00
parent 28f0419af4
commit d802b32597
1 changed files with 4 additions and 4 deletions

View File

@ -184,9 +184,9 @@ CREATE TABLE \`${view.Name}\`(
const { rows: triggers } = await this._client.raw( const { rows: triggers } = await this._client.raw(
`SHOW TRIGGERS FROM \`${this.schemaName}\`` `SHOW TRIGGERS FROM \`${this.schemaName}\``
); );
const generatedTables = this._tables // const generatedTables = this._tables
.filter(t => t.includeStructure) // .filter(t => t.includeStructure)
.map(t => t.table); // .map(t => t.table);
let sqlString = ''; let sqlString = '';
@ -200,7 +200,7 @@ CREATE TABLE \`${view.Name}\`(
sql_mode: sqlMode sql_mode: sqlMode
} = trigger; } = trigger;
if (!generatedTables.includes(table)) continue; // if (!generatedTables.includes(table)) continue;// Commented to avoid issues if export contains triggers without tables
const definer = this.getEscapedDefiner(trigger.Definer); const definer = this.getEscapedDefiner(trigger.Definer);
sqlString += '/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;;\n'; sqlString += '/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;;\n';