Skip to content

Commit 20fac06

Browse files
committed
wip
1 parent 6a89095 commit 20fac06

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/database/src/Migrations/MigrationManager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ public function dropAll(): void
109109
$tables = $this->getTableDefinitions();
110110

111111
// Disable foreign key checks
112-
new SetForeignKeyChecksStatement(enable: false)->execute($this->dialect);
112+
new SetForeignKeyChecksStatement(enable: false)->execute($this->dialect, $this->onDatabase);
113113

114114
// Drop each table
115115
foreach ($tables as $table) {
116-
new DropTableStatement($table->name)->execute($this->dialect);
116+
new DropTableStatement($table->name)->execute($this->dialect, $this->onDatabase);
117117

118118
event(new TableDropped($table->name));
119119
}
120120
} catch (Throwable $throwable) {
121121
event(new FreshMigrationFailed($throwable));
122122
} finally {
123123
// Enable foreign key checks
124-
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect);
124+
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect, $this->onDatabase);
125125
}
126126
}
127127

@@ -249,15 +249,15 @@ public function executeDown(MigrationInterface $migration): void
249249
// TODO: don't just disable FK checking when executing down
250250

251251
// Disable foreign key checks
252-
new SetForeignKeyChecksStatement(enable: false)->execute($this->dialect);
252+
new SetForeignKeyChecksStatement(enable: false)->execute($this->dialect, $this->onDatabase);
253253

254254
$this->database->execute($query);
255255

256256
// Disable foreign key checks
257-
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect);
257+
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect, $this->onDatabase);
258258
} catch (PDOException $pdoException) {
259259
// Disable foreign key checks
260-
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect);
260+
new SetForeignKeyChecksStatement(enable: true)->execute($this->dialect, $this->onDatabase);
261261

262262
event(new MigrationFailed($migration->name, $pdoException));
263263

packages/database/src/QueryStatements/CanExecuteStatement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
use Tempest\Database\Config\DatabaseDialect;
88
use Tempest\Database\Id;
99
use Tempest\Database\Query;
10+
use UnitEnum;
1011

1112
trait CanExecuteStatement
1213
{
13-
public function execute(DatabaseDialect $dialect): ?Id
14+
public function execute(DatabaseDialect $dialect, null|string|UnitEnum $onDatabase): ?Id
1415
{
1516
$sql = $this->compile($dialect);
1617

1718
if (! $sql) {
1819
return null;
1920
}
2021

21-
return new Query($sql)->execute();
22+
return new Query($sql)->onDatabase($onDatabase)->execute();
2223
}
2324
}

0 commit comments

Comments
 (0)