Skip to content
Snippets Groups Projects
Commit 73f689d9 authored by Peter Rotich's avatar Peter Rotich
Browse files

Saved Searches : Save old records

Commit 5be0de0d introduced the idea of moving up old saved searches to make
room for custom queues - but failed to account for cases where the system
has more than 30 saved searches.

This commit addresses the issue by just re-inserting the old records after
queues are imported.
parent 5bfabd28
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,7 @@ function db_fetch_field($res) {
return ($res) ? $res->fetch_field() : NULL;
}
function db_assoc_array($res, $mode=false) {
function db_assoc_array($res, $mode=MYSQLI_ASSOC) {
$result = array();
if($res && db_num_rows($res)) {
while ($row=db_fetch_array($res, $mode))
......
......@@ -9,14 +9,24 @@ class QueueSortCreator extends MigrationTask {
foreach ($columns as $C) {
QueueColumn::__create($C);
}
// Make room for the new queues starting at ID 1
$id = new SqlField('id');
CustomQueue::objects()->update(['id' => $id->plus(30)]);
// Save old records
$old = db_assoc_array(db_query('SELECT * FROM '.QUEUE_TABLE));
// Truncate Queue table - make room for the new queues starting at ID 1
db_query('TRUNCATE TABLE '.QUEUE_TABLE);
$queues = $i18n->getTemplate('queue.yaml')->getData();
foreach ($queues as $C) {
CustomQueue::__create($C);
}
// Re-insert old saved searches
foreach ($old ?: array() as $row) {
$row['root'] = 'T';
CustomQueue::__create(array_intersect_key($row, array_flip(
array('staff_id', 'title', 'config', 'flags',
'root', 'created', 'updated'))));
}
$columns = $i18n->getTemplate('queue_sort.yaml')->getData();
foreach ($columns as $C) {
QueueSort::__create($C);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment