Skip to content

Commit

Permalink
SqlProvisioner bug fixes (CFM-74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Feb 7, 2024
1 parent 9e67f3b commit 37ac9f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,11 @@ public function applySchema($id) {
*/

public function localAfterSave(\Cake\Event\EventInterface $event, \Cake\Datasource\EntityInterface $entity, \ArrayObject $options): bool {
// We may not have a Server configuration yet on first save
if(!empty($spcfg->server_id)) {
// We may not have a Server configuration yet on first save.

// Also, When the SQL Provisioner is deleted, neither the
// database schema nor reference data is touched (PAR-SqlProvisioner-4).
if(!empty($entity->server_id) && !$entity->deleted) {
// Apply the database schema (PAR-SqlProvisioner-1)
$this->llog('rule', "PAR-SqlProvisioner-1 Applying database schema for SqlProvisioner " . $entity->id);
$this->applySchema($entity->id);
Expand Down
3 changes: 3 additions & 0 deletions app/plugins/CoreServer/src/Model/Table/SqlServersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public function connect(int $serverId, string $name): bool {
'timezone' => 'UTC'
];

// We need to drop the existing configuration before we can reconfigure it
ConnectionManager::drop('targetdb');

ConnectionManager::setConfig('targetdb', $dbconfig);

return true;
Expand Down
3 changes: 3 additions & 0 deletions app/src/Lib/Util/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public function __construct(?ConsoleIo $io=null, string $connection='default') {
$cfargs['ssl_ca'] = $cfg['ssl_ca'];
}

if($this->io) $this->io->out("Connecting to database " . $cfg['database'] . " as "
. $cfg['username'] . "@" . $cfg['host']);

$this->conn = DriverManager::getConnection($cfargs, $config);
$this->driver = $cfg['driver'];
}
Expand Down

0 comments on commit 37ac9f6

Please sign in to comment.