Skip to content

Commit 56f12af

Browse files
mikeutaylorotwell
authored andcommitted
Schema-qualify table names when dropping all FKs (#30221)
1 parent f6b5903 commit 56f12af

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,11 @@ public function compileDisableForeignKeyConstraints()
320320
public function compileDropAllForeignKeys()
321321
{
322322
return "DECLARE @sql NVARCHAR(MAX) = N'';
323-
SELECT @sql += 'ALTER TABLE ' + QUOTENAME(OBJECT_NAME(parent_object_id))
323+
SELECT @sql += 'ALTER TABLE '
324+
+ QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + + QUOTENAME(OBJECT_NAME(parent_object_id))
324325
+ ' DROP CONSTRAINT ' + QUOTENAME(name) + ';'
325326
FROM sys.foreign_keys;
326-
327+
327328
EXEC sp_executesql @sql;";
328329
}
329330

0 commit comments

Comments
 (0)