Skip to content

Commit 135e624

Browse files
committed
fix(Migration): only add the locked_at column once
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 16496a4 commit 135e624

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

lib/Migration/Version006000000Date20260302135634.php

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,45 @@ public function __construct(
3333
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
3434
/** @var ISchemaWrapper $schema */
3535
$schema = $schemaClosure();
36+
$schemaChanged = false;
3637

3738
if ($schema->hasTable('context_chat_action_queue')) {
3839
$table = $schema->getTable('context_chat_action_queue');
39-
$table->addColumn('locked_at', Types::DATETIME, [
40-
'notnull' => false,
41-
'default' => null,
42-
]);
43-
$table->addIndex(['locked_at'], 'cc_action_queue_lock');
40+
if (!$table->hasColumn('locked_at')) {
41+
$table->addColumn('locked_at', Types::DATETIME, [
42+
'notnull' => false,
43+
'default' => null,
44+
]);
45+
$table->addIndex(['locked_at'], 'cc_action_queue_lock');
46+
$schemaChanged = true;
47+
}
4448
}
4549

4650
if ($schema->hasTable('context_chat_content_queue')) {
4751
$table = $schema->getTable('context_chat_content_queue');
48-
$table->addColumn('locked_at', Types::DATETIME, [
49-
'notnull' => false,
50-
'default' => null,
51-
]);
52-
$table->addIndex(['locked_at'], 'cc_content_queue_lock');
52+
if (!$table->hasColumn('locked_at')) {
53+
$table->addColumn('locked_at', Types::DATETIME, [
54+
'notnull' => false,
55+
'default' => null,
56+
]);
57+
$table->addIndex(['locked_at'], 'cc_content_queue_lock');
58+
$schemaChanged = true;
59+
}
5360
}
5461

5562
if ($schema->hasTable('context_chat_queue')) {
5663
$table = $schema->getTable('context_chat_queue');
57-
$table->addColumn('locked_at', Types::DATETIME, [
58-
'notnull' => false,
59-
'default' => null,
60-
]);
61-
$table->addIndex(['locked_at'], 'cc_queue_lock');
64+
if (!$table->hasColumn('locked_at')) {
65+
$table->addColumn('locked_at', Types::DATETIME, [
66+
'notnull' => false,
67+
'default' => null,
68+
]);
69+
$table->addIndex(['locked_at'], 'cc_queue_lock');
70+
$schemaChanged = true;
71+
}
6272
}
6373

64-
return $schema;
74+
return $schemaChanged ? $schema : null;
6575
}
6676

6777
/**
@@ -73,6 +83,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
7383
if (($configVal = $this->appConfig->getAppValueInt('last_indexed_file_id', -1, lazy: true)) === -1) {
7484
return;
7585
}
86+
$this->appConfig->deleteAppValue('last_indexed_file_id');
7687

7788
if (($queueFile = $this->queueMapper->findQueueItemByFileId($configVal)) === null) {
7889
return;

0 commit comments

Comments
 (0)