diff --git a/src/main/core/Entity/Template/Template.php b/src/main/core/Entity/Template/Template.php index 4d44e754a62..1ad0d04b5d5 100644 --- a/src/main/core/Entity/Template/Template.php +++ b/src/main/core/Entity/Template/Template.php @@ -19,12 +19,8 @@ /** * @ORM\Entity - * @ORM\Table( - * name="claro_template", - * uniqueConstraints={ - * @ORM\UniqueConstraint(name="template_unique_name", columns={"claro_template_type", "entity_name"}) - * } - * ) + * + * @ORM\Table(name="claro_template") */ class Template { @@ -34,6 +30,7 @@ class Template /** * @ORM\ManyToOne(targetEntity="Claroline\CoreBundle\Entity\Template\TemplateType") + * * @ORM\JoinColumn(name="claro_template_type", nullable=false, onDelete="CASCADE") * * @var TemplateType diff --git a/src/main/core/Installation/Migrations/Version20240705075828.php b/src/main/core/Installation/Migrations/Version20240705075828.php new file mode 100644 index 00000000000..9bb956b0307 --- /dev/null +++ b/src/main/core/Installation/Migrations/Version20240705075828.php @@ -0,0 +1,30 @@ +addSql(' + DROP INDEX template_unique_name ON claro_template + '); + } + + public function down(Schema $schema): void + { + $this->addSql(' + CREATE UNIQUE INDEX claro_template_type_entity_name ON claro_template ( + claro_template_type, entity_name + ) + '); + } +} diff --git a/src/main/core/Resources/modules/administration/template/components/form.jsx b/src/main/core/Resources/modules/administration/template/components/form.jsx index 4cff8d58f4c..f9a5adafd39 100644 --- a/src/main/core/Resources/modules/administration/template/components/form.jsx +++ b/src/main/core/Resources/modules/administration/template/components/form.jsx @@ -35,12 +35,7 @@ const TemplateForm = (props) => type: 'string', label: trans('name'), required: true, - disabled: (template) => template.system, - options: { - unique: { - check: ['apiv2_template_get', {field: 'name'}] - } - } + disabled: (template) => template.system }, { name: 'defineAsDefault', type: 'boolean',