diff --git a/app/Migrations/V1Dot4Dot4.php b/app/Migrations/V1Dot4Dot4.php new file mode 100644 index 00000000..beb2141c --- /dev/null +++ b/app/Migrations/V1Dot4Dot4.php @@ -0,0 +1,82 @@ +getConfig()->get('isMultilangActive', false) && !empty($locales = $this->getConfig()->get('inputLanguageList', []))) { + $parts = []; + + foreach ($locales as $locale) { + $field = 'name_' . strtolower($locale); + + $parts[] = " ADD $field VARCHAR(255) DEFAULT NULL UNIQUE COLLATE `utf8mb4_unicode_ci`"; + } + + $this->execute("ALTER TABLE asset_type" . implode(',', $parts)); + } + } + + /** + * @inheritDoc + */ + public function down(): void + { + if ($this->getConfig()->get('isMultilangActive', false) && !empty($locales = $this->getConfig()->get('inputLanguageList', []))) { + $parts = []; + + foreach ($locales as $locale) { + $field = 'name_' . strtolower($locale); + $parts[] = " DROP $field"; + } + + $this->execute("ALTER TABLE asset_type" . implode(',', $parts)); + } + } + + protected function execute(string $query): void + { + try { + $this->getPDO()->exec($query); + } catch (\Throwable $e) { + } + } +} diff --git a/app/Resources/metadata/entityDefs/AssetType.json b/app/Resources/metadata/entityDefs/AssetType.json index 85162dea..68e25d7f 100644 --- a/app/Resources/metadata/entityDefs/AssetType.json +++ b/app/Resources/metadata/entityDefs/AssetType.json @@ -4,7 +4,8 @@ "type": "varchar", "required": true, "unique": true, - "trim": true + "trim": true, + "isMultilang": true }, "createdAt": { "type": "datetime", @@ -72,4 +73,4 @@ ] } } -} \ No newline at end of file +} diff --git a/app/Resources/metadata/scopes/AssetType.json b/app/Resources/metadata/scopes/AssetType.json index 2da1bac9..d976e7e8 100644 --- a/app/Resources/metadata/scopes/AssetType.json +++ b/app/Resources/metadata/scopes/AssetType.json @@ -11,4 +11,4 @@ "module": "Dam", "object": true, "skipAssetSorting": true -} \ No newline at end of file +}