From 7535d634f4927ab6504e623f4748996865d9858e Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 12 Aug 2024 13:00:13 +0200 Subject: [PATCH] Fix migrations for PSQL --- lib/Db/Catalog.php | 6 ------ lib/Migration/Version6Date20240723125106.php | 12 ++++++------ lib/Migration/Version6Date20240808085441.php | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/Db/Catalog.php b/lib/Db/Catalog.php index 05958101..320b0aac 100644 --- a/lib/Db/Catalog.php +++ b/lib/Db/Catalog.php @@ -42,12 +42,6 @@ public function getJsonFields(): array public function hydrate(array $object): self { - - - if(isset($object['metadata']) === false) { - $object['metadata'] = []; - } - $jsonFields = $this->getJsonFields(); foreach($object as $key => $value) { diff --git a/lib/Migration/Version6Date20240723125106.php b/lib/Migration/Version6Date20240723125106.php index d12ccc8d..b04a1818 100644 --- a/lib/Migration/Version6Date20240723125106.php +++ b/lib/Migration/Version6Date20240723125106.php @@ -80,18 +80,18 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'notnull' => false, ] ); - $table->addColumn(name: 'organization', typeName: TYPES::JSON, options: [ - 'default' => 'a:0:{}', + $organization = $table->addColumn(name: 'organization', typeName: TYPES::JSON, options: [ 'notnull' => false, ]); - $table->addColumn(name: 'data', typeName: TYPES::JSON, options: [ - 'default' => 'a:0:{}', + $organization->setDefault('{}'); + $data = $table->addColumn(name: 'data', typeName: TYPES::JSON, options: [ 'notnull' => false, ]); - $table->addColumn(name: 'attachments', typeName: TYPES::JSON, options: [ - 'default' => 'a:0:{}', + $data->setDefault('{}'); + $attachments = $table->addColumn(name: 'attachments', typeName: TYPES::JSON, options: [ 'notnull' => false, ]); + $attachments->setDefault('{}'); $table->addColumn(name: 'attachment_count', typeName: TYPES::INTEGER); $table->addColumn(name: 'schema', typeName: TYPES::STRING); $table->addColumn(name: 'status', typeName: TYPES::STRING); diff --git a/lib/Migration/Version6Date20240808085441.php b/lib/Migration/Version6Date20240808085441.php index 28e43b3a..c1a2bea2 100644 --- a/lib/Migration/Version6Date20240808085441.php +++ b/lib/Migration/Version6Date20240808085441.php @@ -53,13 +53,13 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt ]); } if($table->hasColumn(name: 'metadata') === false) { - $table->addColumn( + $metadata = $table->addColumn( name: 'metadata', typeName: Types::JSON, options: [ 'notNull' => false, - 'default' => 'a:0:{}' ]); + $metadata->setDefault('{}'); } }