Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting all triggers when using include-tables #270

Open
juppwerner opened this issue Nov 14, 2023 · 1 comment
Open

Exporting all triggers when using include-tables #270

juppwerner opened this issue Nov 14, 2023 · 1 comment

Comments

@juppwerner
Copy link

Hello,

I have skip-triggers set to false.
I am also using include-tables to only select some tables.

I expect to only get the triggers related to the included tables. But all triggers get exported.

I believe a fix could be:

public function getDatabaseStructureTriggers()
{
    // Listing all triggers from database
    if (false === $this->dumpSettings['skip-triggers']) {
        foreach ($this->dbHandler->query($this->typeAdapter->show_triggers($this->dbName)) as $row) {
            if(in_array($row['Table'], $this->dumpSettings['include-views']))
                array_push($this->triggers, $row['Trigger']);
        }
    }
    return;
}

Thank you.

Regards
Joachim

@ifsnop
Copy link
Owner

ifsnop commented Sep 20, 2024

Maybe change include-views for include-tables in your code and add a check to ignore include-tables if it is empty?

 // Listing all triggers from database
    if (false === $this->dumpSettings['skip-triggers']) {
        foreach ($this->dbHandler->query($this->typeAdapter->show_triggers($this->dbName)) as $row) {
           if ( 0 == count($this->dumpSettings['include-tables']) ) 
               array_push($this->triggers, $row['Trigger']);
           else
               if(in_array($row['Table'], $this->dumpSettings['include-tables']))
                    array_push($this->triggers, $row['Trigger']);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants