Skip to content

Commit

Permalink
fix: migration broke in laravel v11.15 (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama authored Aug 7, 2024
1 parent 416faae commit da20e47
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v8.2.0 (2024-08-05)

> [!NOTE] Minimum supported Laravel version is bumped to 11.15.0 for #224.
- Fixed an issue where Schema changes were applied twice. (#224)

# v8.1.3 (2024-06-24)

Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"php": "^8.2",
"ext-grpc": "*",
"ext-json": "*",
"laravel/framework": "^11",
"laravel/framework": "^11.15.0",
"google/cloud-spanner": "^1.58.4",
"grpc/grpc": "^1.42",
"symfony/cache": "~7",
Expand Down
6 changes: 3 additions & 3 deletions src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Illuminate\Support\Str;

/**
* @mixin Builder
* @mixin Builder<static>
*/
class Model extends BaseModel
{
Expand All @@ -42,7 +42,7 @@ class Model extends BaseModel
public $incrementing = false;

/**
* @param BaseModel|Relation $query
* @param BaseModel|Relation<BaseModel, $this, BaseModel> $query
* @param mixed $value
* @param string|null $field
* @return BuilderContract
Expand All @@ -59,7 +59,7 @@ public function resolveRouteBindingQuery($query, $value, $field = null)
* @param string $childType
* @param mixed $value
* @param string|null $field
* @return Relation
* @return Relation<BaseModel, $this, *>
*/
protected function resolveChildRouteBindingQuery($childType, $value, $field)
{
Expand Down
28 changes: 20 additions & 8 deletions src/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@ public function compileCreate(Blueprint $blueprint, Fluent $command)
*
* @param Blueprint $blueprint
* @param Fluent<string, mixed> $command
* @return string[]
* @return list<string>|string
*/
public function compileAdd(Blueprint $blueprint, Fluent $command)
{
return $this->prefixArray(
'alter table '.$this->wrapTable($blueprint).' add column',
$this->getColumns($blueprint)
$column = $command->column;

$sql = sprintf('alter table %s add column %s %s',
$this->wrapTable($blueprint),
$this->wrap($column),
$this->getType($column),
);

return $this->addModifiers($sql, $blueprint, $column);
}

/**
Expand All @@ -131,14 +136,19 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
* @param Blueprint $blueprint
* @param Fluent<string, mixed> $command
* @param Connection $connection
* @return string[]
* @return list<string>|string
*/
public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return $this->prefixArray(
'alter table '.$this->wrapTable($blueprint).' alter column',
$this->getChangedColumns($blueprint)
$column = $command->column;

$sql = sprintf('alter table %s alter column %s %s',
$this->wrapTable($blueprint),
$this->wrap($column),
$this->getType($column),
);

return $this->addModifiers($sql, $blueprint, $column);
}

/**
Expand Down Expand Up @@ -830,6 +840,8 @@ protected function formatTimestampValue(Fluent $column, mixed $value): string
/**
* Compile the blueprint's column definitions.
*
* @deprecated Not used anymore. Will be deleted in 9.x.
*
* @param Blueprint $blueprint
* @return array<int, string>
*/
Expand Down

0 comments on commit da20e47

Please sign in to comment.