Changed snapshot to JSONs
This commit is contained in:
parent
ad8b235bb8
commit
178b17897c
3 changed files with 29 additions and 4 deletions
|
@ -14,8 +14,8 @@ class SnapshotEntityConverter extends AbstractEntityConverter implements IEntity
|
|||
'primaryKey' => $entity->getPrimaryKey(),
|
||||
'userId' => $entity->getUserId(),
|
||||
'operation' => $entity->getOperation(),
|
||||
'data' => serialize($entity->getData()),
|
||||
'dataDifference' => serialize($entity->getDataDifference()),
|
||||
'data' => json_encode($entity->getData()),
|
||||
'dataDifference' => json_encode($entity->getDataDifference()),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ class SnapshotEntityConverter extends AbstractEntityConverter implements IEntity
|
|||
$entity->setPrimaryKey($array['primaryKey']);
|
||||
$entity->setUserId($array['userId']);
|
||||
$entity->setOperation($array['operation']);
|
||||
$entity->setData(unserialize($array['data']));
|
||||
$entity->setDataDifference(unserialize($array['dataDifference']));
|
||||
$entity->setData(json_decode($array['data'], true));
|
||||
$entity->setDataDifference(json_decode($array['dataDifference'], true));
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
|
24
src/Upgrades/Upgrade31.php
Normal file
24
src/Upgrades/Upgrade31.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace Szurubooru\Upgrades;
|
||||
use Szurubooru\DatabaseConnection;
|
||||
|
||||
class Upgrade31 implements IUpgrade
|
||||
{
|
||||
public function run(DatabaseConnection $databaseConnection)
|
||||
{
|
||||
$pdo = $databaseConnection->getPDO();
|
||||
|
||||
foreach (array_chunk(iterator_to_array($pdo->from('snapshots')), 100) as $chunk)
|
||||
{
|
||||
$pdo->beginTransaction();
|
||||
foreach ($chunk as $array)
|
||||
{
|
||||
$pdo->update('snapshots')->set([
|
||||
'data' => json_encode(unserialize($array['data'])),
|
||||
'dataDifference' => json_encode(unserialize($array['dataDifference']))
|
||||
])->where('id', $array['id'])->execute();
|
||||
}
|
||||
$pdo->commit();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ return [
|
|||
$container->get(\Szurubooru\Upgrades\Upgrade28::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade29::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade30::class),
|
||||
$container->get(\Szurubooru\Upgrades\Upgrade31::class),
|
||||
];
|
||||
}),
|
||||
|
||||
|
|
Loading…
Reference in a new issue