Skip to content
Snippets Groups Projects
Commit 7e011ee0 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
...@@ -9,14 +9,24 @@ class QueueSortCreator extends MigrationTask { ...@@ -9,14 +9,24 @@ class QueueSortCreator extends MigrationTask {
foreach ($columns as $C) { foreach ($columns as $C) {
QueueColumn::__create($C); QueueColumn::__create($C);
} }
// Make room for the new queues starting at ID 1
$id = new SqlField('id'); // Save old records
CustomQueue::objects()->update(['id' => $id->plus(30)]); $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(); $queues = $i18n->getTemplate('queue.yaml')->getData();
foreach ($queues as $C) { foreach ($queues as $C) {
CustomQueue::__create($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',
'created', 'updated'))));
}
$columns = $i18n->getTemplate('queue_sort.yaml')->getData(); $columns = $i18n->getTemplate('queue_sort.yaml')->getData();
foreach ($columns as $C) { foreach ($columns as $C) {
QueueSort::__create($C); QueueSort::__create($C);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment