2012-11-07 22:33:07 +01:00
|
|
|
<?php
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
// Switch PhabricatorWorkerActiveTask from auto-increment IDs to counter IDs.
|
2012-11-07 22:33:07 +01:00
|
|
|
// Set the initial counter ID to be larger than any known task ID.
|
|
|
|
|
|
|
|
$active_table = new PhabricatorWorkerActiveTask();
|
|
|
|
$archive_table = new PhabricatorWorkerArchiveTask();
|
|
|
|
|
2012-11-16 19:19:22 +01:00
|
|
|
$old_table = 'worker_task';
|
|
|
|
|
2012-11-07 22:33:07 +01:00
|
|
|
$conn_w = $active_table->establishConnection('w');
|
|
|
|
|
|
|
|
$active_auto = head(queryfx_one(
|
|
|
|
$conn_w,
|
|
|
|
'SELECT auto_increment FROM information_schema.tables
|
|
|
|
WHERE table_name = %s
|
|
|
|
AND table_schema = DATABASE()',
|
2012-11-16 19:19:22 +01:00
|
|
|
$old_table));
|
2012-11-07 22:33:07 +01:00
|
|
|
|
|
|
|
$active_max = head(queryfx_one(
|
|
|
|
$conn_w,
|
|
|
|
'SELECT MAX(id) FROM %T',
|
2012-11-16 19:19:22 +01:00
|
|
|
$old_table));
|
2012-11-07 22:33:07 +01:00
|
|
|
|
|
|
|
$archive_max = head(queryfx_one(
|
|
|
|
$conn_w,
|
|
|
|
'SELECT MAX(id) FROM %T',
|
|
|
|
$archive_table->getTableName()));
|
|
|
|
|
|
|
|
$initial_counter = max((int)$active_auto, (int)$active_max, (int)$archive_max);
|
|
|
|
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
2012-11-08 20:17:28 +01:00
|
|
|
'INSERT INTO %T (counterName, counterValue)
|
|
|
|
VALUES (%s, %d)
|
|
|
|
ON DUPLICATE KEY UPDATE counterValue = %d',
|
2012-11-07 22:33:07 +01:00
|
|
|
LiskDAO::COUNTER_TABLE_NAME,
|
2012-11-16 19:19:22 +01:00
|
|
|
$old_table,
|
2012-11-08 20:17:28 +01:00
|
|
|
$initial_counter + 1,
|
2012-11-07 22:33:07 +01:00
|
|
|
$initial_counter + 1);
|