Skip to content

Commit da20e47

Browse files
authored
fix: migration broke in laravel v11.15 (#224)
1 parent 416faae commit da20e47

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v8.2.0 (2024-08-05)
2+
3+
> [!NOTE] Minimum supported Laravel version is bumped to 11.15.0 for #224.
4+
5+
- Fixed an issue where Schema changes were applied twice. (#224)
6+
17
# v8.1.3 (2024-06-24)
28

39
Fixed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"php": "^8.2",
1212
"ext-grpc": "*",
1313
"ext-json": "*",
14-
"laravel/framework": "^11",
14+
"laravel/framework": "^11.15.0",
1515
"google/cloud-spanner": "^1.58.4",
1616
"grpc/grpc": "^1.42",
1717
"symfony/cache": "~7",

src/Eloquent/Model.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Illuminate\Support\Str;
2525

2626
/**
27-
* @mixin Builder
27+
* @mixin Builder<static>
2828
*/
2929
class Model extends BaseModel
3030
{
@@ -42,7 +42,7 @@ class Model extends BaseModel
4242
public $incrementing = false;
4343

4444
/**
45-
* @param BaseModel|Relation $query
45+
* @param BaseModel|Relation<BaseModel, $this, BaseModel> $query
4646
* @param mixed $value
4747
* @param string|null $field
4848
* @return BuilderContract
@@ -59,7 +59,7 @@ public function resolveRouteBindingQuery($query, $value, $field = null)
5959
* @param string $childType
6060
* @param mixed $value
6161
* @param string|null $field
62-
* @return Relation
62+
* @return Relation<BaseModel, $this, *>
6363
*/
6464
protected function resolveChildRouteBindingQuery($childType, $value, $field)
6565
{

src/Schema/Grammar.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,19 @@ public function compileCreate(Blueprint $blueprint, Fluent $command)
115115
*
116116
* @param Blueprint $blueprint
117117
* @param Fluent<string, mixed> $command
118-
* @return string[]
118+
* @return list<string>|string
119119
*/
120120
public function compileAdd(Blueprint $blueprint, Fluent $command)
121121
{
122-
return $this->prefixArray(
123-
'alter table '.$this->wrapTable($blueprint).' add column',
124-
$this->getColumns($blueprint)
122+
$column = $command->column;
123+
124+
$sql = sprintf('alter table %s add column %s %s',
125+
$this->wrapTable($blueprint),
126+
$this->wrap($column),
127+
$this->getType($column),
125128
);
129+
130+
return $this->addModifiers($sql, $blueprint, $column);
126131
}
127132

128133
/**
@@ -131,14 +136,19 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
131136
* @param Blueprint $blueprint
132137
* @param Fluent<string, mixed> $command
133138
* @param Connection $connection
134-
* @return string[]
139+
* @return list<string>|string
135140
*/
136141
public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
137142
{
138-
return $this->prefixArray(
139-
'alter table '.$this->wrapTable($blueprint).' alter column',
140-
$this->getChangedColumns($blueprint)
143+
$column = $command->column;
144+
145+
$sql = sprintf('alter table %s alter column %s %s',
146+
$this->wrapTable($blueprint),
147+
$this->wrap($column),
148+
$this->getType($column),
141149
);
150+
151+
return $this->addModifiers($sql, $blueprint, $column);
142152
}
143153

144154
/**
@@ -830,6 +840,8 @@ protected function formatTimestampValue(Fluent $column, mixed $value): string
830840
/**
831841
* Compile the blueprint's column definitions.
832842
*
843+
* @deprecated Not used anymore. Will be deleted in 9.x.
844+
*
833845
* @param Blueprint $blueprint
834846
* @return array<int, string>
835847
*/

0 commit comments

Comments
 (0)