From b3973ca1a5929d6b2c95ebe9fe0740ba48ead219 Mon Sep 17 00:00:00 2001 From: patrickakk Date: Sat, 9 Nov 2024 13:46:49 +0100 Subject: [PATCH] add unique on invitetranslations - language_id #59 --- RELEASE_NOTES.md | 4 ++-- ...AddLanguageIdIndexToInviteTranslations.php | 22 +++++++++++++++++++ src/Model/Table/InviteTranslationsTable.php | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 config/Migrations/20241109122958_AddLanguageIdIndexToInviteTranslations.php diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cd8395a7..d68c1f65 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,8 +3,8 @@ ## Version 2024-12 *Release date: ...* -### Change -- xyz +### Changes +- Added unique validation for invite translation - language id #59 ## Version 2024-11 diff --git a/config/Migrations/20241109122958_AddLanguageIdIndexToInviteTranslations.php b/config/Migrations/20241109122958_AddLanguageIdIndexToInviteTranslations.php new file mode 100644 index 00000000..e9c78312 --- /dev/null +++ b/config/Migrations/20241109122958_AddLanguageIdIndexToInviteTranslations.php @@ -0,0 +1,22 @@ +table('invite_translations'); + $table->addIndex('language_id', ['unique' => true]); + $table->update(); + } +} diff --git a/src/Model/Table/InviteTranslationsTable.php b/src/Model/Table/InviteTranslationsTable.php index 0bf1982a..c49b690d 100644 --- a/src/Model/Table/InviteTranslationsTable.php +++ b/src/Model/Table/InviteTranslationsTable.php @@ -61,6 +61,7 @@ public function validationDefault(Validator $validator): Validator public function buildRules(RulesChecker $rules): RulesChecker { $rules->add($rules->isUnique(['sortOrder']), ['errorField' => 'sortOrder']); + $rules->add($rules->isUnique(['language_id']), ['errorField' => 'language_id']); $rules->add($rules->existsIn(['language_id'], 'Languages'), ['errorField' => 'language_id']); return $rules;