Skip to content

Commit 3fa4ebc

Browse files
Fixed ResetCommand table isolation issues for postgresql and mssql (#66) (#76)
1 parent 58fc72f commit 3fa4ebc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Console/ResetCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ private function safelyDropTable($table)
8989
$schema = $this->connection->getSchemaManager();
9090
$schema->dropTable($table);
9191

92-
$queryEnablingCardinalityChecks = $instructions['needsTableIsolation'] ?
93-
sprintf($instructions['enable'], $table) :
94-
$instructions['enable'];
95-
$this->connection->query($queryEnablingCardinalityChecks);
92+
// When table is already dropped we cannot enable any cardinality checks on it
93+
// See https://github.com/laravel-doctrine/migrations/issues/50
94+
if (!$instructions['needsTableIsolation']) {
95+
$this->connection->query($instructions['enable']);
96+
}
9697
}
9798

9899
/**
@@ -103,7 +104,6 @@ private function getCardinalityCheckInstructions()
103104
return [
104105
'mssql' => [
105106
'needsTableIsolation' => true,
106-
'enable' => 'ALTER TABLE %s NOCHECK CONSTRAINT ALL',
107107
'disable' => 'ALTER TABLE %s CHECK CONSTRAINT ALL',
108108
],
109109
'mysql' => [
@@ -113,7 +113,6 @@ private function getCardinalityCheckInstructions()
113113
],
114114
'postgresql' => [
115115
'needsTableIsolation' => true,
116-
'enable' => 'ALTER TABLE %s ENABLE TRIGGER ALL',
117116
'disable' => 'ALTER TABLE %s DISABLE TRIGGER ALL',
118117
],
119118
'sqlite' => [

0 commit comments

Comments
 (0)