Fix Specified key was too long; max key length is 767 bytes

pull/2635/head
Julio Montoya 6 years ago
parent d2c3a21c95
commit cf05163a71
  1. 8
      app/Migrations/Schema/V200/Version20.php
  2. 2
      src/CoreBundle/Entity/Block.php
  3. 2
      src/CoreBundle/Entity/HookEvent.php
  4. 2
      src/CoreBundle/Entity/HookObserver.php
  5. 4
      src/CoreBundle/Entity/SettingsCurrent.php
  6. 2
      src/CoreBundle/Entity/SettingsOptions.php
  7. 2
      src/CourseBundle/Entity/CDropboxFile.php
  8. 2
      src/FaqBundle/Entity/Category.php
  9. 83
      src/FaqBundle/Entity/CategoryRepository.php
  10. 18
      src/FaqBundle/Entity/CategoryTranslation.php
  11. 2
      src/FaqBundle/Entity/Question.php
  12. 53
      src/FaqBundle/Entity/QuestionRepository.php
  13. 16
      src/FaqBundle/Entity/QuestionTranslation.php

@ -39,8 +39,8 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('CREATE TABLE IF NOT EXISTS media__gallery_media (id INT AUTO_INCREMENT NOT NULL, gallery_id INT DEFAULT NULL, media_id INT DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_80D4C5414E7AF8F (gallery_id), INDEX IDX_80D4C541EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS media__gallery (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, context VARCHAR(64) NOT NULL, default_format VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS media__media (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, enabled TINYINT(1) NOT NULL, provider_name VARCHAR(255) NOT NULL, provider_status INT NOT NULL, provider_reference VARCHAR(255) NOT NULL, provider_metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', width INT DEFAULT NULL, height INT DEFAULT NULL, length NUMERIC(10, 0) DEFAULT NULL, content_type VARCHAR(255) DEFAULT NULL, content_size INT DEFAULT NULL, copyright VARCHAR(255) DEFAULT NULL, author_name VARCHAR(255) DEFAULT NULL, context VARCHAR(64) DEFAULT NULL, cdn_is_flushable TINYINT(1) DEFAULT NULL, cdn_flush_identifier VARCHAR(64) DEFAULT NULL, cdn_flush_at DATETIME DEFAULT NULL, cdn_status INT DEFAULT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_5C6DD74E12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_question_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_C2D1A2C2AC5D3 (translatable_id), UNIQUE INDEX faq_question_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_5493B0FC2C2AC5D3 (translatable_id), UNIQUE INDEX faq_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_question_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(190) NOT NULL, INDEX IDX_C2D1A2C2AC5D3 (translatable_id), UNIQUE INDEX faq_question_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(190) NOT NULL, INDEX IDX_5493B0FC2C2AC5D3 (translatable_id), UNIQUE INDEX faq_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_category (id INT AUTO_INCREMENT NOT NULL, rank INT NOT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX is_active_idx (is_active), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS faq_question (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, rank INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, only_auth_users TINYINT(1) NOT NULL, is_active TINYINT(1) NOT NULL, INDEX IDX_4A55B05912469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
$this->addSql('CREATE TABLE IF NOT EXISTS contact_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_3E770F302C2AC5D3 (translatable_id), UNIQUE INDEX contact_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;');
@ -133,6 +133,10 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE course_category ADD CONSTRAINT FK_AFF87497727ACA70 FOREIGN KEY (parent_id) REFERENCES course_category (id);');
$this->addSql('ALTER TABLE settings_current ADD CONSTRAINT FK_62F79C3B9436187B FOREIGN KEY (access_url) REFERENCES access_url (id);');
$this->addSql('ALTER TABLE settings_current CHANGE variable variable VARCHAR(190) DEFAULT NULL, CHANGE subkey subkey VARCHAR(190) DEFAULT NULL;');
$this->addSql('ALTER TABLE settings_options CHANGE variable variable VARCHAR(190) DEFAULT NULL, CHANGE value value VARCHAR(190) DEFAULT NULL');
$this->addSql(' ALTER TABLE hook_event CHANGE class_name class_name VARCHAR(190) DEFAULT NULL;');
$this->addSql('ALTER TABLE access_url_rel_session ADD id INT AUTO_INCREMENT NOT NULL, CHANGE access_url_id access_url_id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL, ADD PRIMARY KEY (id);');
$this->addSql('ALTER TABLE access_url_rel_session ADD CONSTRAINT FK_6CBA5F5D613FECDF FOREIGN KEY (session_id) REFERENCES session (id);');

@ -43,7 +43,7 @@ class Block
/**
* @var string
*
* @ORM\Column(name="path", type="string", length=255, nullable=false)
* @ORM\Column(name="path", type="string", length=190, nullable=false)
*/
protected $path;

@ -20,7 +20,7 @@ class HookEvent
/**
* @var string
*
* @ORM\Column(name="class_name", type="string", length=255, nullable=true)
* @ORM\Column(name="class_name", type="string", length=190, nullable=true)
*/
protected $className;

@ -20,7 +20,7 @@ class HookObserver
/**
* @var string
*
* @ORM\Column(name="class_name", type="string", length=255, nullable=true)
* @ORM\Column(name="class_name", type="string", length=190, nullable=true)
*/
protected $className;

@ -39,14 +39,14 @@ class SettingsCurrent
/**
* @var string
*
* @ORM\Column(name="variable", type="string", length=255, nullable=true)
* @ORM\Column(name="variable", type="string", length=190, nullable=true)
*/
protected $variable;
/**
* @var string
*
* @ORM\Column(name="subkey", type="string", length=255, nullable=true)
* @ORM\Column(name="subkey", type="string", length=190, nullable=true)
*/
protected $subkey;

@ -29,7 +29,7 @@ class SettingsOptions
/**
* @var string
*
* @ORM\Column(name="variable", type="string", length=255, nullable=true)
* @ORM\Column(name="variable", type="string", length=190, nullable=true)
*/
protected $variable;

@ -56,7 +56,7 @@ class CDropboxFile
/**
* @var string
*
* @ORM\Column(name="filename", type="string", length=250, nullable=false)
* @ORM\Column(name="filename", type="string", length=190, nullable=false)
*/
protected $filename;

@ -10,7 +10,7 @@ use Knp\DoctrineBehaviors\Model as ORMBehaviors;
/**
* Class Category.
*
* @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Entity\CategoryRepository")
* @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Repository\CategoryRepository")
* @ORM\Table(
* name="faq_category",
* indexes={@ORM\Index(name="is_active_idx", columns={"is_active"})}

@ -1,83 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\FaqBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* Class CategoryRepository.
*
* @package Genj\FaqBundle\Entity
*/
class CategoryRepository extends EntityRepository
{
/**
* @return mixed
*/
public function retrieveActive()
{
$query = $this->createQueryBuilder('c')
->where('c.isActive = :isActive')
->orderBy('c.rank', 'ASC')
->getQuery();
$query->setParameter('isActive', true);
return $query->execute();
}
/**
* @param string $slug
*
* @return mixed
*/
public function retrieveActiveBySlug($slug)
{
$query = $this->createQueryBuilder('c')
->where('c.isActive = :isActive')
->andWhere('c.slug = :slug')
->orderBy('c.rank', 'ASC')
->getQuery();
$query->setParameter('isActive', true);
$query->setParameter('slug', $slug);
return $query->execute();
}
/**
* @param string $slug
*
* @return mixed
*/
public function getCategoryActiveBySlug($slug)
{
$query = $this->createQueryBuilder('c')
->join('c.translations', 't')
->where('c.isActive = :isActive')
->andWhere('t.slug = :slug')
->getQuery();
$query->setParameter('isActive', true);
$query->setParameter('slug', $slug);
return $query->getOneOrNullResult();
}
/**
* @return Category|null
*/
public function retrieveFirst()
{
$query = $this->createQueryBuilder('c')
->where('c.isActive = :isActive')
->orderBy('c.rank', 'ASC')
->setMaxResults(1)
->getQuery();
$query->setParameter('isActive', true);
return $query->getOneOrNullResult();
}
}

@ -15,6 +15,15 @@ use Knp\DoctrineBehaviors\Model as ORMBehaviors;
* name="faq_category_translation",
* options={"row_format":"DYNAMIC"}
* )
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="locale",
* column=@ORM\Column(
* name="locale",
* type="string",
* length=190
* )
* )
* })
*
* @package Chamilo\FaqBundle\Entity
*/
@ -38,6 +47,15 @@ class CategoryTranslation
*/
protected $slug;
/**
* @var string
* @ORM\Column(type="string", length=190, nullable=false)
*/
protected $locale;
/**
* @return string
*/
public function __toString()
{
return (string) $this->headline;

@ -10,7 +10,7 @@ use Knp\DoctrineBehaviors\Model as ORMBehaviors;
/**
* Class Question.
*
* @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Entity\QuestionRepository")
* @ORM\Entity(repositoryClass="Chamilo\FaqBundle\Repository\QuestionRepository")
* @ORM\Table(name="faq_question")
* *
*

@ -1,53 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\FaqBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* Class QuestionRepository.
*
* @package Genj\FaqBundle\Entity
*/
class QuestionRepository extends EntityRepository
{
/**
* @param string $categorySlug
*
* @return Question|null
*/
public function retrieveFirstByCategorySlug($categorySlug)
{
$query = $this->createQueryBuilder('q')
->join('q.category', 'c')
->join('c.translations', 't')
->where('t.slug = :categorySlug')
->orderBy('q.rank', 'ASC')
->setMaxResults(1)
->getQuery();
$query->setParameter('categorySlug', $categorySlug);
return $query->getOneOrNullResult();
}
/**
* @param string $slug
*
* @return Question|null
*/
public function getQuestionBySlug($slug)
{
$query = $this->createQueryBuilder('q')
->join('q.translations', 't')
->where('t.slug = :slug')
->orderBy('q.rank', 'ASC')
->setMaxResults(1)
->getQuery();
$query->setParameter('slug', $slug);
return $query->getOneOrNullResult();
}
}

@ -16,6 +16,16 @@ use Knp\DoctrineBehaviors\Model as ORMBehaviors;
* options={"row_format":"DYNAMIC"}
* )
*
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="locale",
* column=@ORM\Column(
* name="locale",
* type="string",
* length=190
* )
* )
* })
*
* @package Chamilo\FaqBundle\Entity
*/
class QuestionTranslation
@ -38,6 +48,12 @@ class QuestionTranslation
*/
protected $slug;
/**
* @var string
* @ORM\Column(type="string", length=190, nullable=false)
*/
protected $locale;
/**
* @return string
*/

Loading…
Cancel
Save