Skip to content

Commit 5769fcd

Browse files
authored
Attempt upgrade to Laravel 11 (#37)
* Attempt upgrade to Laravel 11 * Add test bench details * Working Laravel 11 grammar tests * Fix test namespace * Test fix * database script change * Update CRDB version * Fix of tests * Add Eager Load Limit test * Remove the tiny int test * Fix PHP styling * Add test skip * Fix version test * Adds a custom casting test * Skips test with missing method * small test fixes * Fix PHP styling * bump crdb version * skip one last test * Fix PHP styling * wrong way dumby * PHPStan fixes for missing Doctrine classes * Additional tests * Blocks out some scenarios pre L11 * More version blocking * Another one * Last one for Laravel 10 and above * Fix PHP styling --------- Co-authored-by: peterfox <[email protected]>
1 parent 5f47c0c commit 5769fcd

18 files changed

+2175
-89
lines changed

.github/workflows/run-tests.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ ubuntu-latest ]
18-
php: [ 8.1, 8.2, 8.3 ]
19-
laravel: [ 10.*, 9.* ]
20-
cockroachdb: [ v22.2.17, v23.1.13 ]
18+
php: [ 8.2, 8.3 ]
19+
laravel: [ 11.*, 10.*, 9.* ]
20+
cockroachdb: [ v22.2.17, v23.2.2 ]
2121
dependencies: [ stable, lowest ]
2222
include:
23+
- laravel: 11.*
24+
testbench: ^9.0
2325
- laravel: 10.*
2426
testbench: ^8.0
2527
- laravel: 9.*

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.1",
20+
"php": "^8.2",
2121
"spatie/laravel-package-tools": "^1.9.2",
22-
"illuminate/contracts": "10.*|9.*|8.*"
22+
"illuminate/contracts": "11.*|10.*|9.*"
2323
},
2424
"require-dev": {
2525
"doctrine/dbal": "^3.2",
2626
"laravel/pint": "^1.2",
27-
"nunomaduro/collision": "7.2|^6.0|^5.10",
28-
"nunomaduro/larastan": "^2.0|^1.0",
29-
"orchestra/testbench": "^8.0|^7.0|^6.24",
27+
"nunomaduro/collision": "^8.1|7.2|^6.0|^5.10",
28+
"larastan/larastan": "^2.0",
29+
"orchestra/testbench": "^9.0|^8.0|^7.0",
3030
"pestphp/pest": "^1.21|^2.23",
3131
"pestphp/pest-plugin-laravel": "^1.1|^2.2",
3232
"phpstan/extension-installer": "^1.1",
3333
"phpstan/phpstan-deprecation-rules": "^1.0",
3434
"phpstan/phpstan-phpunit": "^1.0",
35-
"rector/rector": "^0.14.2",
35+
"rector/rector": "^0.14.2|^1.0",
3636
"spatie/laravel-ray": "^1.26"
3737
},
3838
"autoload": {

database.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
heredoc);
2626

2727
$statements = [
28-
'SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = true;',
2928
'SET CLUSTER SETTING kv.range_merge.queue_interval = \'50ms\';',
3029
'SET CLUSTER SETTING jobs.registry.interval.gc = \'30s\';',
3130
'SET CLUSTER SETTING jobs.registry.interval.cancel = \'180s\';',
3231
'SET CLUSTER SETTING jobs.retention_time = \'15s\';',
3332
'SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;',
3433
'SET CLUSTER SETTING kv.range_split.by_load_merge_delay = \'5s\';',
35-
'ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 5;',
36-
'ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 5;',
34+
'ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;',
35+
'ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;',
3736
];
3837

3938
foreach ($statements as $statement) {

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
33
crdb:
4-
image: "cockroachdb/cockroach:${VERSION:-v23.1.13}"
4+
image: "cockroachdb/cockroach:${VERSION:-v23.2.2}"
55
ports:
66
- "26257:26257"
77
- "8080:8080"

src/CockroachDbConnection.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use YlsIdeas\CockroachDb\Builder\CockroachDbBuilder as DbBuilder;
1111
use YlsIdeas\CockroachDb\Processor\CockroachDbProcessor as DbProcessor;
1212
use YlsIdeas\CockroachDb\Query\CockroachGrammar as QueryGrammar;
13-
use YlsIdeas\CockroachDb\Schema\CockroachGrammar as SchemaGrammar;
13+
use YlsIdeas\CockroachDb\Schema\CockroachDbGrammar as SchemaGrammar;
1414
use YlsIdeas\CockroachDb\Schema\CockroachSchemaState as SchemaState;
1515

1616
class CockroachDbConnection extends PostgresConnection implements ConnectionInterface
@@ -73,9 +73,11 @@ protected function getDefaultPostProcessor(): DbProcessor
7373
* Get the Doctrine DBAL driver.
7474
*
7575
* @return \Illuminate\Database\PDO\PostgresDriver
76+
* @phpstan-ignore-next-line Missing in Laravel 11
7677
*/
7778
protected function getDoctrineDriver()
7879
{
80+
/** @phpstan-ignore-next-line Now redundant in Laravel 11 */
7981
return new PostgresDriver();
8082
}
8183

src/Processor/CockroachDbProcessor.php

+26
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,30 @@
66

77
class CockroachDbProcessor extends PostgresProcessor
88
{
9+
public function processColumns($results)
10+
{
11+
return array_map(function ($result) {
12+
$result = (object) $result;
13+
14+
$autoincrement = $result->default !== null && str_starts_with($result->default, 'nextval(');
15+
16+
return [
17+
'name' => $result->name,
18+
'type_name' => $result->type_name,
19+
'type' => $result->type,
20+
'collation' => $result->collation,
21+
'nullable' => (bool) $result->nullable,
22+
'default' => ($result->generated ?? null) ? null : $result->default,
23+
'auto_increment' => $autoincrement,
24+
'comment' => $result->comment,
25+
'generation' => ($result->generated ?? null) ? [
26+
'type' => match ($result->generated) {
27+
's' => 'stored',
28+
default => null,
29+
},
30+
'expression' => $result->default,
31+
] : null,
32+
];
33+
}, $results);
34+
}
935
}

src/Schema/CockroachGrammar.php renamed to src/Schema/CockroachDbGrammar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Support\Fluent;
88
use YlsIdeas\CockroachDb\Exceptions\FeatureNotSupportedException;
99

10-
class CockroachGrammar extends PostgresGrammar
10+
class CockroachDbGrammar extends PostgresGrammar
1111
{
1212
/**
1313
* Compile the query to determine the tables.

0 commit comments

Comments
 (0)