mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-22 20:25:43 +00:00
fix: status must be an array of string
This commit is contained in:
parent
acaf4fe594
commit
6caea8fc68
48
migrations/Version20251106151250.php
Normal file
48
migrations/Version20251106151250.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20251106151250 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Convert status object to array';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->addSql("UPDATE domain_status
|
||||||
|
SET add_status = (
|
||||||
|
SELECT jsonb_agg(value::text::jsonb)
|
||||||
|
FROM jsonb_array_elements(
|
||||||
|
CASE
|
||||||
|
WHEN jsonb_typeof(add_status) = 'array' THEN add_status
|
||||||
|
WHEN jsonb_typeof(add_status) = 'object' THEN to_jsonb(array(SELECT jsonb_array_elements_text(jsonb_agg(value)) FROM jsonb_each_text(add_status)))
|
||||||
|
ELSE '[]'::jsonb
|
||||||
|
END
|
||||||
|
) AS t(value)
|
||||||
|
), delete_status = (
|
||||||
|
SELECT jsonb_agg(value::text::jsonb)
|
||||||
|
FROM jsonb_array_elements(
|
||||||
|
CASE
|
||||||
|
WHEN jsonb_typeof(delete_status) = 'array' THEN delete_status
|
||||||
|
WHEN jsonb_typeof(delete_status) = 'object' THEN to_jsonb(array(SELECT jsonb_array_elements_text(jsonb_agg(value)) FROM jsonb_each_text(delete_status)))
|
||||||
|
ELSE '[]'::jsonb
|
||||||
|
END
|
||||||
|
) AS t(value)
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -317,8 +317,8 @@ class RDAPService
|
|||||||
{
|
{
|
||||||
if (isset($rdapData['status']) && is_array($rdapData['status'])) {
|
if (isset($rdapData['status']) && is_array($rdapData['status'])) {
|
||||||
$status = array_map(fn ($s) => strtolower($s), array_unique($rdapData['status']));
|
$status = array_map(fn ($s) => strtolower($s), array_unique($rdapData['status']));
|
||||||
$addedStatus = array_diff($status, $domain->getStatus());
|
$addedStatus = array_values(array_diff($status, $domain->getStatus()));
|
||||||
$deletedStatus = array_diff($domain->getStatus(), $status);
|
$deletedStatus = array_values(array_diff($domain->getStatus(), $status));
|
||||||
$domain->setStatus($status);
|
$domain->setStatus($status);
|
||||||
|
|
||||||
if (count($addedStatus) > 0 || count($deletedStatus) > 0) {
|
if (count($addedStatus) > 0 || count($deletedStatus) > 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user