@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3// Switch PhabricatorWorkerActiveTask from auto-increment IDs to counter IDs.
4// Set the initial counter ID to be larger than any known task ID.
5
6$active_table = new PhabricatorWorkerActiveTask();
7$archive_table = new PhabricatorWorkerArchiveTask();
8
9$old_table = 'worker_task';
10
11$conn_w = $active_table->establishConnection('w');
12
13$active_auto = head(queryfx_one(
14 $conn_w,
15 'SELECT auto_increment FROM information_schema.tables
16 WHERE table_name = %s
17 AND table_schema = DATABASE()',
18 $old_table));
19
20$active_max = head(queryfx_one(
21 $conn_w,
22 'SELECT MAX(id) FROM %T',
23 $old_table));
24
25$archive_max = head(queryfx_one(
26 $conn_w,
27 'SELECT MAX(id) FROM %T',
28 $archive_table->getTableName()));
29
30$initial_counter = max((int)$active_auto, (int)$active_max, (int)$archive_max);
31
32queryfx(
33 $conn_w,
34 'INSERT INTO %T (counterName, counterValue)
35 VALUES (%s, %d)
36 ON DUPLICATE KEY UPDATE counterValue = %d',
37 LiskDAO::COUNTER_TABLE_NAME,
38 $old_table,
39 $initial_counter + 1,
40 $initial_counter + 1);