Skip to content

Commit 28a41c7

Browse files
juliusknorrAndyScherzinger
authored andcommitted
fix: use bigint in initial lock migrations
Assisted-by: Codex:GPT-6 Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent d98644b commit 28a41c7

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎lib/Migration/Version0001Date20191105000001.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5050
$table = $schema->createTable('files_lock');
5151

5252
$table->addColumn(
53-
'id', 'integer',
53+
'id', 'bigint',
5454
[
5555
'autoincrement' => true,
5656
'unsigned' => true,
5757
'notnull' => true,
58-
'length' => 11
58+
'length' => 20
5959
]
6060
);
6161
$table->addColumn(
@@ -66,11 +66,11 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
6666
]
6767
);
6868
$table->addColumn(
69-
'file_id', 'integer',
69+
'file_id', 'bigint',
7070
[
7171
'notnull' => true,
7272
'unsigned' => true,
73-
'length' => 11,
73+
'length' => 20,
7474
]
7575
);
7676
$table->addColumn(

‎lib/Migration/Version1000Date20220201111525.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
4848

4949
if (!$table->hasColumn('ttl')) {
5050
$table->addColumn(
51-
'ttl', Types::INTEGER,
51+
'ttl', Types::BIGINT,
5252
[
5353
'default' => 0,
54+
'length' => 20,
5455
]
5556
);
5657
$hasSchemaChanges = true;

‎tests/Unit/Migration/Version35000Date20260928000000Test.php‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
class Version35000Date20260928000000Test extends TestCase {
2525

26-
public function testMigrationPreservesSchemaAndCanRunAgain(): void {
26+
/**
27+
* @dataProvider schemaProvider
28+
*/
29+
public function testMigrationPreservesSchemaAndCanRunAgain(bool $legacySchema): void {
2730
$table = new Table(new DBALTable('files_lock'));
2831
$schema = $this->createMock(ISchemaWrapper::class);
2932
$schema->method('hasTable')->with('files_lock')->willReturn(false);
@@ -35,6 +38,15 @@ public function testMigrationPreservesSchemaAndCanRunAgain(): void {
3538
(new Version0001Date20191105000001($this->createMock(IDBConnection::class)))->changeSchema($output, $schemaClosure, []);
3639
(new Version1000Date20220201111525())->changeSchema($output, $schemaClosure, []);
3740
(new Version1000Date20220430180808())->changeSchema($output, $schemaClosure, []);
41+
foreach (['id', 'file_id', 'ttl'] as $name) {
42+
$column = $table->getColumn($name);
43+
self::assertSame(Types::BIGINT, $column->getType()->getName());
44+
self::assertSame(20, $column->getLength());
45+
if ($legacySchema) {
46+
$column->setType(Types::INTEGER);
47+
$column->setLength($name === 'ttl' ? null : 11);
48+
}
49+
}
3850
$before = clone $table->getWrappedTable();
3951

4052
$migration = new Version35000Date20260928000000();
@@ -52,4 +64,11 @@ public function testMigrationPreservesSchemaAndCanRunAgain(): void {
5264
self::assertEquals($before->getIndexes(), $table->getWrappedTable()->getIndexes());
5365
}
5466
}
67+
68+
public static function schemaProvider(): array {
69+
return [
70+
'fresh install' => [false],
71+
'legacy integer columns' => [true],
72+
];
73+
}
5574
}

0 commit comments

Comments
 (0)