Skip to content

Commit

Permalink
[Template ] unique name template (#2822)
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfyWin authored Jul 5, 2024
1 parent fd3a092 commit af940ac
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/main/core/Entity/Template/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/main/core/Installation/Migrations/Version20240705075828.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Claroline\CoreBundle\Installation\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated migration based on mapping information: modify it with caution.
*
* Generation date: 2024/07/05 07:58:29
*/
final class Version20240705075828 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->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
)
');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit af940ac

Please sign in to comment.