From f46254b4597bf2bb75e49c9b9b2f114eee993a1b Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Mon, 26 Aug 2019 11:04:38 +0200 Subject: [PATCH] FEAT #11270 TIME 0:20 Custom fields: migration if field exist + default_value --- migration/19.12/migrateCustomFields.php | 12 +++++++++++- sql/develop.sql | 1 + sql/structure.sql | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/migration/19.12/migrateCustomFields.php b/migration/19.12/migrateCustomFields.php index c510c062f5b..00f5e42a0fc 100644 --- a/migration/19.12/migrateCustomFields.php +++ b/migration/19.12/migrateCustomFields.php @@ -29,6 +29,16 @@ foreach ($customs as $custom) { if ($loadedXml) { $i = 0; foreach ($loadedXml->INDEX as $value) { + $customExists = \SrcCore\models\DatabaseModel::select([ + 'select' => [1], + 'table' => ['doctypes_indexes'], + 'where' => ['field_name = ?'], + 'data' => [(string)$value->column] + ]); + if (empty($customExists)) { + continue; + } + $label = (string)$value->label; $type = (string)$value->type; @@ -67,5 +77,5 @@ foreach ($customs as $custom) { } } - printf("Migration Champs Custom (CUSTOM {$custom}) : " . $migrated . " Champs custom trouvé(s) et migré(s).\n"); + printf("Migration Champs Custom (CUSTOM {$custom}) : " . $migrated . " Champs custom utilisé(s) et migré(s).\n"); } diff --git a/sql/develop.sql b/sql/develop.sql index 8229986d01b..520d45f4141 100755 --- a/sql/develop.sql +++ b/sql/develop.sql @@ -117,6 +117,7 @@ CREATE TABLE custom_fields label character varying(256) NOT NULL, type character varying(256) NOT NULL, values jsonb, + default_value text, CONSTRAINT custom_fields_pkey PRIMARY KEY (id), CONSTRAINT custom_fields_unique_key UNIQUE (label) ) diff --git a/sql/structure.sql b/sql/structure.sql index b6695f8bab9..e48b993d7a0 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -2010,6 +2010,7 @@ CREATE TABLE custom_fields label character varying(256) NOT NULL, type character varying(256) NOT NULL, values jsonb, + default_value text, CONSTRAINT custom_fields_pkey PRIMARY KEY (id), CONSTRAINT custom_fields_unique_key UNIQUE (label) ) -- GitLab