@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * columns and columns of the data table). |
| 77 | 77 | */ |
| 78 | 78 | public function createAuditTable(string $dataSchemaName, |
| 79 | - string $auditSchemaName, |
|
| 80 | - string $tableName, |
|
| 81 | - TableColumnsMetadata $columns): void |
|
| 79 | + string $auditSchemaName, |
|
| 80 | + string $tableName, |
|
| 81 | + TableColumnsMetadata $columns): void |
|
| 82 | 82 | { |
| 83 | 83 | $helper = new CreateAuditTable($dataSchemaName, $auditSchemaName, $tableName, $columns); |
| 84 | 84 | $sql = $helper->buildStatement(); |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | * @param string[] $additionSql Additional SQL statements. |
| 102 | 102 | */ |
| 103 | 103 | public function createAuditTrigger(string $dataSchemaName, |
| 104 | - string $auditSchemaName, |
|
| 105 | - string $tableName, |
|
| 106 | - string $triggerName, |
|
| 107 | - string $triggerAction, |
|
| 108 | - TableColumnsMetadata $additionalAuditColumns, |
|
| 109 | - TableColumnsMetadata $tableColumns, |
|
| 104 | + string $auditSchemaName, |
|
| 105 | + string $tableName, |
|
| 106 | + string $triggerName, |
|
| 107 | + string $triggerAction, |
|
| 108 | + TableColumnsMetadata $additionalAuditColumns, |
|
| 109 | + TableColumnsMetadata $tableColumns, |
|
| 110 | 110 | ?string $skipVariable, |
| 111 | - array $additionSql): void |
|
| 111 | + array $additionSql): void |
|
| 112 | 112 | { |
| 113 | 113 | $helper = new CreateAuditTrigger($dataSchemaName, |
| 114 | - $auditSchemaName, |
|
| 115 | - $tableName, |
|
| 116 | - $triggerName, |
|
| 117 | - $triggerAction, |
|
| 118 | - $additionalAuditColumns, |
|
| 119 | - $tableColumns, |
|
| 120 | - $skipVariable, |
|
| 121 | - $additionSql); |
|
| 114 | + $auditSchemaName, |
|
| 115 | + $tableName, |
|
| 116 | + $triggerName, |
|
| 117 | + $triggerAction, |
|
| 118 | + $additionalAuditColumns, |
|
| 119 | + $tableColumns, |
|
| 120 | + $skipVariable, |
|
| 121 | + $additionSql); |
|
| 122 | 122 | $sql = $helper->buildStatement(); |
| 123 | 123 | |
| 124 | 124 | $this->executeNone($sql); |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | where TABLE_SCHEMA = %s |
| 301 | 301 | and TABLE_NAME = %s |
| 302 | 302 | order by ORDINAL_POSITION", |
| 303 | - $this->quoteString($schemaName), |
|
| 304 | - $this->quoteString($tableName)); |
|
| 303 | + $this->quoteString($schemaName), |
|
| 304 | + $this->quoteString($tableName)); |
|
| 305 | 305 | |
| 306 | 306 | return $this->executeRows($sql); |
| 307 | 307 | } |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | inner join information_schema.COLLATION_CHARACTER_SET_APPLICABILITY t2 on t2.COLLATION_NAME = t1.TABLE_COLLATION |
| 328 | 328 | where t1.TABLE_SCHEMA = %s |
| 329 | 329 | and t1.TABLE_NAME = %s', |
| 330 | - $this->quoteString($schemaName), |
|
| 331 | - $this->quoteString($tableName)); |
|
| 330 | + $this->quoteString($schemaName), |
|
| 331 | + $this->quoteString($tableName)); |
|
| 332 | 332 | |
| 333 | 333 | return $this->executeRow1($sql); |
| 334 | 334 | } |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | where TRIGGER_SCHEMA = %s |
| 351 | 351 | and EVENT_OBJECT_TABLE = %s |
| 352 | 352 | order by Trigger_Name', |
| 353 | - $this->quoteString($schemaName), |
|
| 354 | - $this->quoteString($tableName)); |
|
| 353 | + $this->quoteString($schemaName), |
|
| 354 | + $this->quoteString($tableName)); |
|
| 355 | 355 | |
| 356 | 356 | return $this->executeRows($sql); |
| 357 | 357 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | where TRIGGER_SCHEMA = %s |
| 394 | 394 | order by EVENT_OBJECT_TABLE |
| 395 | 395 | , TRIGGER_NAME', |
| 396 | - $this->quoteString($schemaName)); |
|
| 396 | + $this->quoteString($schemaName)); |
|
| 397 | 397 | |
| 398 | 398 | return $this->executeRows($sql); |
| 399 | 399 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * @return TableColumnsMetadata |
| 423 | 423 | */ |
| 424 | 424 | public function resolveCanonicalAdditionalAuditColumns(string $auditSchema, |
| 425 | - array $additionalAuditColumns): TableColumnsMetadata |
|
| 425 | + array $additionalAuditColumns): TableColumnsMetadata |
|
| 426 | 426 | { |
| 427 | 427 | if (empty($additionalAuditColumns)) |
| 428 | 428 | { |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | $tableColumns, |
| 120 | 120 | $skipVariable, |
| 121 | 121 | $additionSql); |
| 122 | - $sql = $helper->buildStatement(); |
|
| 122 | + $sql = $helper->buildStatement(); |
|
| 123 | 123 | |
| 124 | 124 | $this->executeNone($sql); |
| 125 | 125 | } |
@@ -332,29 +332,29 @@ |
||
| 332 | 332 | * @param TableColumnsMetadata $alteredColumns The metadata of the altered columns. |
| 333 | 333 | */ |
| 334 | 334 | private function logColumnInfo(TableColumnsMetadata $newColumns, |
| 335 | - TableColumnsMetadata $obsoleteColumns, |
|
| 336 | - TableColumnsMetadata $alteredColumns): void |
|
| 335 | + TableColumnsMetadata $obsoleteColumns, |
|
| 336 | + TableColumnsMetadata $alteredColumns): void |
|
| 337 | 337 | { |
| 338 | 338 | foreach ($newColumns->getColumns() as $column) |
| 339 | 339 | { |
| 340 | 340 | $this->io->logInfo('New column <dbo>%s.%s</dbo>', |
| 341 | - $this->tableName, |
|
| 342 | - $column->getName()); |
|
| 341 | + $this->tableName, |
|
| 342 | + $column->getName()); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | foreach ($obsoleteColumns->getColumns() as $column) |
| 346 | 346 | { |
| 347 | 347 | $this->io->logInfo('Obsolete column <dbo>%s.%s</dbo>', |
| 348 | - $this->tableName, |
|
| 349 | - $column->getName()); |
|
| 348 | + $this->tableName, |
|
| 349 | + $column->getName()); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | foreach ($alteredColumns->getColumns() as $column) |
| 353 | 353 | { |
| 354 | 354 | $this->io->logInfo('Type of <dbo>%s.%s</dbo> has been altered to <dbo>%s</dbo>', |
| 355 | - $this->tableName, |
|
| 356 | - $column->getName(), |
|
| 357 | - $column->getProperty('column_type')); |
|
| 355 | + $this->tableName, |
|
| 356 | + $column->getName(), |
|
| 357 | + $column->getProperty('column_type')); |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | protected function configure() |
| 22 | 22 | { |
| 23 | 23 | $this->setName('drop-triggers') |
| 24 | - ->setDescription('Drops all triggers') |
|
| 25 | - ->setHelp('Drops all triggers (including triggers not created by audit) from all tables (including tables '. |
|
| 26 | - 'excluded for auditing) in the data schema.') |
|
| 27 | - ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file'); |
|
| 24 | + ->setDescription('Drops all triggers') |
|
| 25 | + ->setHelp('Drops all triggers (including triggers not created by audit) from all tables (including tables '. |
|
| 26 | + 'excluded for auditing) in the data schema.') |
|
| 27 | + ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | foreach ($triggers as $trigger) |
| 61 | 61 | { |
| 62 | 62 | $this->io->logInfo('Dropping trigger <dbo>%s</dbo> from table <dbo>%s</dbo>', |
| 63 | - $trigger['trigger_name'], |
|
| 64 | - $trigger['table_name']); |
|
| 63 | + $trigger['trigger_name'], |
|
| 64 | + $trigger['table_name']); |
|
| 65 | 65 | |
| 66 | 66 | AuditDataLayer::$dl->dropTrigger($dataSchema, $trigger['trigger_name']); |
| 67 | 67 | } |
@@ -99,10 +99,10 @@ |
||
| 99 | 99 | protected function connect(): void |
| 100 | 100 | { |
| 101 | 101 | $connector = new MySqlDefaultConnector($this->config->getManString('database.host'), |
| 102 | - $this->config->getManString('database.user'), |
|
| 103 | - $this->config->getManString('database.password'), |
|
| 104 | - $this->config->getManString('database.data_schema'), |
|
| 105 | - $this->config->getManInt('database.port', 3306)); |
|
| 102 | + $this->config->getManString('database.user'), |
|
| 103 | + $this->config->getManString('database.password'), |
|
| 104 | + $this->config->getManString('database.data_schema'), |
|
| 105 | + $this->config->getManInt('database.port', 3306)); |
|
| 106 | 106 | $dl = new AuditDataLayer($connector, $this->io); |
| 107 | 107 | $dl->connect(); |
| 108 | 108 | } |
@@ -160,12 +160,12 @@ |
||
| 160 | 160 | if ($audit===true) |
| 161 | 161 | { |
| 162 | 162 | $currentTable = new AuditTable($this->io, |
| 163 | - $this->config->getManString('database.data_schema'), |
|
| 164 | - $this->config->getManString('database.audit_schema'), |
|
| 165 | - $table['table_name'], |
|
| 166 | - $this->additionalAuditColumns, |
|
| 167 | - $this->config->getOptString('tables.'.$table['table_name'].'.alias'), |
|
| 168 | - $this->config->getOptString('tables.'.$table['table_name'].'.skip')); |
|
| 163 | + $this->config->getManString('database.data_schema'), |
|
| 164 | + $this->config->getManString('database.audit_schema'), |
|
| 165 | + $table['table_name'], |
|
| 166 | + $this->additionalAuditColumns, |
|
| 167 | + $this->config->getOptString('tables.'.$table['table_name'].'.alias'), |
|
| 168 | + $this->config->getOptString('tables.'.$table['table_name'].'.skip')); |
|
| 169 | 169 | |
| 170 | 170 | // Ensure the audit table exists. |
| 171 | 171 | if (RowSetHelper::searchInRowSet($this->auditSchemaTables, 'table_name', $table['table_name'])===null) |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | $maxLength = $diff->getLongestColumnNameLength(); |
| 106 | 106 | |
| 107 | 107 | $this->codeStore->append(sprintf('alter table `%s`.`%s`', |
| 108 | - $this->config->getManString('database.audit_schema'), |
|
| 109 | - $auditTable->getTableName())); |
|
| 108 | + $this->config->getManString('database.audit_schema'), |
|
| 109 | + $auditTable->getTableName())); |
|
| 110 | 110 | |
| 111 | 111 | $first = true; |
| 112 | 112 | foreach ($diff->getColumns() as $column) |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | if (!$first) $this->codeStore->appendToLastLine(','); |
| 118 | 118 | |
| 119 | 119 | $this->codeStore->append(sprintf('change column `%s`%s`%s`%s%s', |
| 120 | - $name, |
|
| 121 | - $filler, |
|
| 122 | - $name, |
|
| 123 | - $filler, |
|
| 124 | - $column->getColumnAuditDefinition())); |
|
| 120 | + $name, |
|
| 121 | + $filler, |
|
| 122 | + $name, |
|
| 123 | + $filler, |
|
| 124 | + $column->getColumnAuditDefinition())); |
|
| 125 | 125 | |
| 126 | 126 | $first = false; |
| 127 | 127 | } |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $this->codeStore->append(sprintf('alter table `%s`.`%s` %s;', |
| 170 | - $this->config->getManString('database.audit_schema'), |
|
| 171 | - $auditTable->getTableName(), |
|
| 172 | - implode(' ', $parts))); |
|
| 170 | + $this->config->getManString('database.audit_schema'), |
|
| 171 | + $auditTable->getTableName(), |
|
| 172 | + implode(' ', $parts))); |
|
| 173 | 173 | $this->codeStore->append(''); |
| 174 | 174 | } |
| 175 | 175 | } |