Skip to content

Commit 3fe231c

Browse files
Try to fix with Laravel 12 compatibility
1 parent e724cd9 commit 3fe231c

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"require": {
3838
"php": "^8.0",
3939
"ext-pdo": "*",
40-
"doctrine/dbal": "^3.0 || ^4.0",
4140
"dragon-code/contracts": "^2.15",
4241
"dragon-code/support": "^6.0",
4342
"illuminate/contracts": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
@@ -47,10 +46,14 @@
4746
"require-dev": {
4847
"ext-pdo_mysql": "*",
4948
"ext-pdo_pgsql": "*",
49+
"doctrine/dbal": "^3.0 || ^4.0",
5050
"mockery/mockery": "^1.0",
5151
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
5252
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0 || ^12.0"
5353
},
54+
"suggest": {
55+
"doctrine/dbal": "[For Laravel 8-10] Required to rename columns and drop SQLite columns (^3.5.1)."
56+
},
5457
"minimum-stability": "stable",
5558
"prefer-stable": true,
5659
"autoload": {

src/Console/Migrate.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
class Migrate extends Command
1818
{
1919
protected $signature = 'db:migrate'
20-
. ' {--schema-from= : Source connection name}'
21-
. ' {--schema-to= : Target connection name}'
22-
. ' {--exclude=* : Comma separated table names to exclude}'
23-
. ' {--tables=* : Comma separated table names to migrate only}';
20+
. ' {--schema-from= : Source connection name}'
21+
. ' {--schema-to= : Target connection name}'
22+
. ' {--exclude=* : Comma separated table names to exclude}'
23+
. ' {--tables=* : Comma separated table names to migrate only}';
2424

2525
protected $description = 'Data transfer from one database to another';
2626

@@ -135,9 +135,9 @@ protected function migrateTable(string $table, string $column): void
135135
$this->builder($this->source(), $table)
136136
->orderBy($column)
137137
->chunk(1000, function (Collection $items) use ($table) {
138-
$items = Arr::resolve($items);
139-
140-
$this->builder($this->target(), $table)->insertOrIgnore($items);
138+
$this->builder($this->target(), $table)->updateOrInsert(
139+
Arr::resolve($items)
140+
);
141141
});
142142

143143
$this->migrated[] = $table;

tests/Concerns/Seeders.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests\Concerns;
44

5+
use Illuminate\Foundation\Application;
56
use Illuminate\Support\Facades\DB;
67
use Illuminate\Support\Str;
78

@@ -33,10 +34,20 @@ protected function fillTable(string $table): void
3334

3435
protected function fillUlidTable(string $table): void
3536
{
37+
$ulids = [];
38+
39+
for ($i = 0; $i < 3; $i++) {
40+
$ulids[$i] = (string) Str::ulid();
41+
42+
if (Str::startsWith(Application::VERSION, '12.')) {
43+
usleep(500);
44+
}
45+
}
46+
3647
DB::connection($this->source_connection)->table($table)->insert([
37-
['value' => $table . '_1', 'ulid' => (string) Str::ulid()],
38-
['value' => $table . '_2', 'ulid' => (string) Str::ulid()],
39-
['value' => $table . '_3', 'ulid' => (string) Str::ulid()],
48+
['value' => $table . '_1', 'ulid' => $ulids[0]],
49+
['value' => $table . '_2', 'ulid' => $ulids[1]],
50+
['value' => $table . '_3', 'ulid' => $ulids[2]],
4051
]);
4152
}
4253

0 commit comments

Comments
 (0)