diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index bfccb9c2f8..07d08fe833 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -50,6 +50,7 @@ use Symfony\Component\Validator\Constraints as Assert; security: "is_granted('ROLE_USER')" )] #[ORM\Table(name: 'course')] +#[ORM\Index(columns: ['sticky'], name: 'idx_course_sticky')] #[UniqueEntity('code')] #[UniqueEntity('visualCode')] #[ORM\Entity(repositoryClass: CourseRepository::class)] diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php index 142b26b505..eae52083fc 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php @@ -36,6 +36,10 @@ class Version20191101132000 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE course ADD sticky TINYINT(1) NOT NULL'); } + if (!$table->hasIndex('idx_course_sticky')) { + $this->addSql('CREATE INDEX idx_course_sticky ON course (sticky)'); + } + if (!$table->hasColumn('resource_node_id')) { $this->addSql('ALTER TABLE course ADD COLUMN resource_node_id INT DEFAULT NULL;'); $this->addSql(