From 14c57c9c6d4fae51ae267c313d478a255614d17b Mon Sep 17 00:00:00 2001 From: Ayomide Oludare Date: Sat, 27 Sep 2025 08:28:15 +0100 Subject: [PATCH 1/4] feat: add foreign id to morph conversion methods to Blueprint --- src/Illuminate/Database/Schema/Blueprint.php | 74 +++++++++++++ .../Database/Schema/Grammars/Grammar.php | 19 ++++ .../Database/Schema/Grammars/MySqlGrammar.php | 20 ++++ .../Schema/Grammars/PostgresGrammar.php | 19 ++++ .../Schema/Grammars/SQLiteGrammar.php | 13 +++ .../Schema/Grammars/SqlServerGrammar.php | 19 ++++ .../Database/DatabaseSchemaBlueprintTest.php | 100 +++++++++++++++++- 7 files changed, 261 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index de2233249055..c819f8c90506 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -1048,6 +1048,80 @@ public function foreignIdFor($model, $column = null) ->referencesModelColumn($model->getKeyName()); } + /** + * Convert a foreign key column to a polymorphic relationship (integer IDs). + * + * @param string $column + * @param string $morphName + * @param string $defaultOwnerType + * @return void + */ + public function foreignIdToMorph($column, $morphName, $defaultOwnerType) + { + $this->convertToMorph($column, $morphName, $defaultOwnerType, 'bigInteger', ['unsigned' => true]); + } + + /** + * Convert a foreign key column to a polymorphic relationship (UUID IDs). + * + * @param string $column + * @param string $morphName + * @param string $defaultOwnerType + * @return void + */ + public function foreignIdToUuidMorph($column, $morphName, $defaultOwnerType) + { + $this->convertToMorph($column, $morphName, $defaultOwnerType, 'uuid'); + } + + /** + * Convert a foreign key column to a polymorphic relationship (ULID IDs). + * + * @param string $column + * @param string $morphName + * @param string $defaultOwnerType + * @return void + */ + public function foreignIdToUlidMorph($column, $morphName, $defaultOwnerType) + { + $this->convertToMorph($column, $morphName, $defaultOwnerType, 'char', ['length' => 26]); + } + + /** + * Convert a foreign key column to a polymorphic relationship. + * + * @param string $column + * @param string $morphName + * @param string $defaultOwnerType + * @param string $columnType + * @param array $columnOptions + * @return void + */ + protected function convertToMorph($column, $morphName, $defaultOwnerType, $columnType, $columnOptions = []) + { + // Drop the foreign key constraint if it exists + $this->dropForeign([$column]); + + // Rename the column first + $this->renameColumn($column, "{$morphName}_id"); + + // Change the column type + $this->addColumn($columnType, "{$morphName}_id", $columnOptions)->change(); + + // Add the morph type column + $this->string("{$morphName}_type")->after("{$morphName}_id")->nullable(); + + // Add index for the morph columns + $this->index(["{$morphName}_type", "{$morphName}_id"]); + + // Add command to update existing records with the default owner type + $this->addCommand('updateMorphType', [ + 'morphIdColumn' => "{$morphName}_id", + 'morphTypeColumn' => "{$morphName}_type", + 'defaultOwnerType' => $defaultOwnerType, + ]); + } + /** * Create a new float column on the table. * diff --git a/src/Illuminate/Database/Schema/Grammars/Grammar.php b/src/Illuminate/Database/Schema/Grammars/Grammar.php index 391324b9c6d2..dc7308387b66 100755 --- a/src/Illuminate/Database/Schema/Grammars/Grammar.php +++ b/src/Illuminate/Database/Schema/Grammars/Grammar.php @@ -507,4 +507,23 @@ public function supportsSchemaTransactions() { return $this->transactions; } + + /** + * Compile an update morph type command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) + { + return sprintf( + 'update %s set %s = %s where %s is not null and %s is null', + $this->wrapTable($blueprint->getTable()), + $this->wrap($command->morphTypeColumn), + $this->getDefaultValue($command->defaultOwnerType), + $this->wrap($command->morphIdColumn), + $this->wrap($command->morphTypeColumn) + ); + } } diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 16e8634d3e6b..7b585ebf3e61 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -1390,4 +1390,24 @@ protected function wrapJsonSelector($value) return 'json_unquote(json_extract('.$field.$path.'))'; } + + /** + * Compile an update morph type command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) + { + return sprintf( + 'update %s set %s = %s where %s is not null and %s is null', + $this->wrapTable($blueprint->getTable()), + $this->wrap($command->morphTypeColumn), + $this->getDefaultValue(addslashes($command->defaultOwnerType)), + $this->wrap($command->morphIdColumn), + $this->wrap($command->morphTypeColumn) + ); + } + } diff --git a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php index fa95e2a50fd9..42765407c4f9 100755 --- a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php @@ -1316,4 +1316,23 @@ protected function modifyGeneratedAs(Blueprint $blueprint, Fluent $column) return $sql; } + + /** + * Compile an update morph type command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) + { + return sprintf( + 'update %s set %s = %s where %s is not null and %s is null', + $this->wrapTable($blueprint->getTable()), + $this->wrap($command->morphTypeColumn), + $this->getDefaultValue($command->defaultOwnerType), + $this->wrap($command->morphIdColumn), + $this->wrap($command->morphTypeColumn) + ); + } } diff --git a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php index 8908836dd9c7..9099f16a04bb 100644 --- a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php @@ -1201,4 +1201,17 @@ protected function wrapJsonSelector($value) return 'json_extract('.$field.$path.')'; } + + public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) + { + return sprintf( + 'update %s set %s = %s where %s is not null and %s is null', + $this->wrapTable($blueprint->getTable()), + $this->wrap($command->morphTypeColumn), + $this->getDefaultValue($command->defaultOwnerType), + $this->wrap($command->morphIdColumn), + $this->wrap($command->morphTypeColumn) + ); + } + } diff --git a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php index 28b5e5a7a161..0a44eafb367d 100755 --- a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php @@ -1042,4 +1042,23 @@ public function quoteString($value) return "N'$value'"; } + + /** + * Compile an update morph type command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) + { + return sprintf( + 'update %s set %s = %s where %s is not null and %s is null', + $this->wrapTable($blueprint->getTable()), + $this->wrap($command->morphTypeColumn), + $this->getDefaultValue($command->defaultOwnerType), + $this->wrap($command->morphIdColumn), + $this->wrap($command->morphTypeColumn) + ); + } } diff --git a/tests/Database/DatabaseSchemaBlueprintTest.php b/tests/Database/DatabaseSchemaBlueprintTest.php index 76c734baa369..7c6e918cdc5b 100755 --- a/tests/Database/DatabaseSchemaBlueprintTest.php +++ b/tests/Database/DatabaseSchemaBlueprintTest.php @@ -413,6 +413,99 @@ public function testDefaultUsingNullableUlidMorph() ], $getSql('MySql')); } + public function testForeignIdToMorph() + { + $getSql = function ($grammar) { + if ($grammar == 'MySql') { + $connection = $this->getConnection($grammar); + $connection->shouldReceive('getServerVersion')->andReturn('8.0.4'); + $connection->shouldReceive('isMaria')->andReturn(false); + + return (new Blueprint($connection, 'posts', function ($table) { +$table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); + + }))->toSql(); + } else { + return $this->getBlueprint($grammar, 'posts', function ($table) { +$table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); + + })->toSql(); + } + }; + + $this->assertEquals([ + 'alter table `posts` drop foreign key `posts_user_id_foreign`', + 'alter table `posts` rename column `user_id` to `author_id`', + 'alter table `posts` modify `author_id` bigint unsigned not null', + 'alter table `posts` add `author_type` varchar(255) null after `author_id`', + 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', + 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', + + ], $getSql('MySql')); + } + + public function testForeignIdToUuidMorph() + { + $getSql = function ($grammar) { + if ($grammar == 'MySql') { + $connection = $this->getConnection($grammar); + $connection->shouldReceive('getServerVersion')->andReturn('8.0.4'); + $connection->shouldReceive('isMaria')->andReturn(false); + + return (new Blueprint($connection, 'posts', function ($table) { +$table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); + + }))->toSql(); + } else { + return $this->getBlueprint($grammar, 'posts', function ($table) { +$table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); + + })->toSql(); + } + }; + + $this->assertEquals([ + 'alter table `posts` drop foreign key `posts_user_id_foreign`', + 'alter table `posts` rename column `user_id` to `author_id`', + 'alter table `posts` modify `author_id` char(36) not null', + 'alter table `posts` add `author_type` varchar(255) null after `author_id`', + 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', + 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', + + ], $getSql('MySql')); + } + + public function testForeignIdToUlidMorph() + { + $getSql = function ($grammar) { + if ($grammar == 'MySql') { + $connection = $this->getConnection($grammar); + $connection->shouldReceive('getServerVersion')->andReturn('8.0.4'); + $connection->shouldReceive('isMaria')->andReturn(false); + + return (new Blueprint($connection, 'posts', function ($table) { +$table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); + + }))->toSql(); + } else { + return $this->getBlueprint($grammar, 'posts', function ($table) { +$table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); + + })->toSql(); + } + }; + + $this->assertEquals([ + 'alter table `posts` drop foreign key `posts_user_id_foreign`', + 'alter table `posts` rename column `user_id` to `author_id`', + 'alter table `posts` modify `author_id` char(26) not null', + 'alter table `posts` add `author_type` varchar(255) null after `author_id`', + 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', + 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', + + ], $getSql('MySql')); + } + public function testGenerateRelationshipColumnWithIncrementalModel() { $getSql = function ($grammar) { @@ -663,8 +756,8 @@ protected function getConnection(?string $grammar = null, string $prefix = '') ->getMock(); $grammar ??= 'MySql'; - $grammarClass = 'Illuminate\Database\Schema\Grammars\\'.$grammar.'Grammar'; - $builderClass = 'Illuminate\Database\Schema\\'.$grammar.'Builder'; +$grammarClass = 'Illuminate\Database\Schema\Grammars\\'.$grammar.'Grammar'; +$builderClass = 'Illuminate\Database\Schema\\'.$grammar.'Builder'; $connection->shouldReceive('getSchemaGrammar')->andReturn(new $grammarClass($connection)); $connection->shouldReceive('getSchemaBuilder')->andReturn(m::mock($builderClass)); @@ -695,5 +788,6 @@ protected function getBlueprint( enum ApostropheBackedEnum: string { case ValueWithoutApostrophe = 'this will work'; - case ValueWithApostrophe = 'this\'ll work too'; +case ValueWithApostrophe = 'this\'ll work too'; + } From 2bf0bbcccd109564e86d5bd57f5f1eae62643fb3 Mon Sep 17 00:00:00 2001 From: Ayomide Oludare Date: Sat, 27 Sep 2025 08:43:48 +0100 Subject: [PATCH 2/4] fix styleci issues --- .../Database/Schema/Grammars/MySqlGrammar.php | 1 - .../Database/DatabaseSchemaBlueprintTest.php | 21 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 7b585ebf3e61..13758c501acd 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -1409,5 +1409,4 @@ public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) $this->wrap($command->morphTypeColumn) ); } - } diff --git a/tests/Database/DatabaseSchemaBlueprintTest.php b/tests/Database/DatabaseSchemaBlueprintTest.php index 7c6e918cdc5b..5fb8acbf5c65 100755 --- a/tests/Database/DatabaseSchemaBlueprintTest.php +++ b/tests/Database/DatabaseSchemaBlueprintTest.php @@ -422,12 +422,12 @@ public function testForeignIdToMorph() $connection->shouldReceive('isMaria')->andReturn(false); return (new Blueprint($connection, 'posts', function ($table) { -$table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { -$table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); })->toSql(); } @@ -440,7 +440,6 @@ public function testForeignIdToMorph() 'alter table `posts` add `author_type` varchar(255) null after `author_id`', 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', - ], $getSql('MySql')); } @@ -453,12 +452,12 @@ public function testForeignIdToUuidMorph() $connection->shouldReceive('isMaria')->andReturn(false); return (new Blueprint($connection, 'posts', function ($table) { -$table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { -$table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); })->toSql(); } @@ -471,7 +470,6 @@ public function testForeignIdToUuidMorph() 'alter table `posts` add `author_type` varchar(255) null after `author_id`', 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', - ], $getSql('MySql')); } @@ -484,12 +482,12 @@ public function testForeignIdToUlidMorph() $connection->shouldReceive('isMaria')->andReturn(false); return (new Blueprint($connection, 'posts', function ($table) { -$table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { -$table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); + $table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); })->toSql(); } @@ -502,7 +500,6 @@ public function testForeignIdToUlidMorph() 'alter table `posts` add `author_type` varchar(255) null after `author_id`', 'alter table `posts` add index `posts_author_type_author_id_index`(`author_type`, `author_id`)', 'update `posts` set `author_type` = \'App\\\\Models\\\\Post\' where `author_id` is not null and `author_type` is null', - ], $getSql('MySql')); } @@ -756,8 +753,8 @@ protected function getConnection(?string $grammar = null, string $prefix = '') ->getMock(); $grammar ??= 'MySql'; -$grammarClass = 'Illuminate\Database\Schema\Grammars\\'.$grammar.'Grammar'; -$builderClass = 'Illuminate\Database\Schema\\'.$grammar.'Builder'; + $grammarClass = 'Illuminate\Database\Schema\Grammars\\'.$grammar.'Grammar'; + $builderClass = 'Illuminate\Database\Schema\\'.$grammar.'Builder'; $connection->shouldReceive('getSchemaGrammar')->andReturn(new $grammarClass($connection)); $connection->shouldReceive('getSchemaBuilder')->andReturn(m::mock($builderClass)); @@ -788,6 +785,6 @@ protected function getBlueprint( enum ApostropheBackedEnum: string { case ValueWithoutApostrophe = 'this will work'; -case ValueWithApostrophe = 'this\'ll work too'; + case ValueWithApostrophe = 'this\'ll work too'; } From 3f453d0748645dbc47873ceef8fb364ac87f2b20 Mon Sep 17 00:00:00 2001 From: Ayomide Oludare Date: Sat, 27 Sep 2025 08:46:14 +0100 Subject: [PATCH 3/4] style: fix styleci issues --- src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php | 1 - tests/Database/DatabaseSchemaBlueprintTest.php | 7 ------- 2 files changed, 8 deletions(-) diff --git a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php index 9099f16a04bb..0ed765c422c4 100644 --- a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php @@ -1213,5 +1213,4 @@ public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) $this->wrap($command->morphTypeColumn) ); } - } diff --git a/tests/Database/DatabaseSchemaBlueprintTest.php b/tests/Database/DatabaseSchemaBlueprintTest.php index 5fb8acbf5c65..b617af213be5 100755 --- a/tests/Database/DatabaseSchemaBlueprintTest.php +++ b/tests/Database/DatabaseSchemaBlueprintTest.php @@ -423,12 +423,10 @@ public function testForeignIdToMorph() return (new Blueprint($connection, 'posts', function ($table) { $table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); - }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { $table->foreignIdToMorph('user_id', 'author', 'App\Models\Post'); - })->toSql(); } }; @@ -453,12 +451,10 @@ public function testForeignIdToUuidMorph() return (new Blueprint($connection, 'posts', function ($table) { $table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); - }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { $table->foreignIdToUuidMorph('user_id', 'author', 'App\Models\Post'); - })->toSql(); } }; @@ -483,12 +479,10 @@ public function testForeignIdToUlidMorph() return (new Blueprint($connection, 'posts', function ($table) { $table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); - }))->toSql(); } else { return $this->getBlueprint($grammar, 'posts', function ($table) { $table->foreignIdToUlidMorph('user_id', 'author', 'App\Models\Post'); - })->toSql(); } }; @@ -786,5 +780,4 @@ enum ApostropheBackedEnum: string { case ValueWithoutApostrophe = 'this will work'; case ValueWithApostrophe = 'this\'ll work too'; - } From add77ee00e4693e1782acd19c3bf292142d67ec2 Mon Sep 17 00:00:00 2001 From: Ayomide Oludare Date: Sun, 28 Sep 2025 00:48:06 +0100 Subject: [PATCH 4/4] remove compileUpdateMorphType where it's the same as default --- .../Schema/Grammars/PostgresGrammar.php | 19 ------------------- .../Schema/Grammars/SQLiteGrammar.php | 12 ------------ .../Schema/Grammars/SqlServerGrammar.php | 19 ------------------- 3 files changed, 50 deletions(-) diff --git a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php index 42765407c4f9..fa95e2a50fd9 100755 --- a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php @@ -1316,23 +1316,4 @@ protected function modifyGeneratedAs(Blueprint $blueprint, Fluent $column) return $sql; } - - /** - * Compile an update morph type command. - * - * @param \Illuminate\Database\Schema\Blueprint $blueprint - * @param \Illuminate\Support\Fluent $command - * @return string - */ - public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) - { - return sprintf( - 'update %s set %s = %s where %s is not null and %s is null', - $this->wrapTable($blueprint->getTable()), - $this->wrap($command->morphTypeColumn), - $this->getDefaultValue($command->defaultOwnerType), - $this->wrap($command->morphIdColumn), - $this->wrap($command->morphTypeColumn) - ); - } } diff --git a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php index 0ed765c422c4..8908836dd9c7 100644 --- a/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php @@ -1201,16 +1201,4 @@ protected function wrapJsonSelector($value) return 'json_extract('.$field.$path.')'; } - - public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) - { - return sprintf( - 'update %s set %s = %s where %s is not null and %s is null', - $this->wrapTable($blueprint->getTable()), - $this->wrap($command->morphTypeColumn), - $this->getDefaultValue($command->defaultOwnerType), - $this->wrap($command->morphIdColumn), - $this->wrap($command->morphTypeColumn) - ); - } } diff --git a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php index 0a44eafb367d..28b5e5a7a161 100755 --- a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php @@ -1042,23 +1042,4 @@ public function quoteString($value) return "N'$value'"; } - - /** - * Compile an update morph type command. - * - * @param \Illuminate\Database\Schema\Blueprint $blueprint - * @param \Illuminate\Support\Fluent $command - * @return string - */ - public function compileUpdateMorphType(Blueprint $blueprint, Fluent $command) - { - return sprintf( - 'update %s set %s = %s where %s is not null and %s is null', - $this->wrapTable($blueprint->getTable()), - $this->wrap($command->morphTypeColumn), - $this->getDefaultValue($command->defaultOwnerType), - $this->wrap($command->morphIdColumn), - $this->wrap($command->morphTypeColumn) - ); - } }