Merge pull request #3466 from lcubas/2807
WIP: Migrations: Change relationships in entities Course and CourseCategoRy and create migration course_rel_categorypull/3464/head
commit
0d12296e6a
@ -0,0 +1,45 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace DoctrineMigrations; |
||||
|
||||
use Doctrine\DBAL\Schema\Schema; |
||||
use Doctrine\Migrations\AbstractMigration; |
||||
|
||||
/** |
||||
* Auto-generated Migration: Please modify to your needs! |
||||
*/ |
||||
final class Version20200821224242 extends AbstractMigration |
||||
{ |
||||
public function getDescription() : string |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function up(Schema $schema) : void |
||||
{ |
||||
// this up() migration is auto-generated, please modify it to your needs |
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
||||
|
||||
$this->addSql('CREATE TABLE course_rel_category (course_id INT NOT NULL, course_category_id INT NOT NULL, INDEX IDX_8EB34CC5591CC992 (course_id), INDEX IDX_8EB34CC56628AD36 (course_category_id), PRIMARY KEY(course_id, course_category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'); |
||||
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC5591CC992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE'); |
||||
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC56628AD36 FOREIGN KEY (course_category_id) REFERENCES course_category (id) ON DELETE CASCADE'); |
||||
$this->addSql('DROP TABLE version'); |
||||
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB912469DE2'); |
||||
$this->addSql('DROP INDEX IDX_169E6FB912469DE2 ON course'); |
||||
$this->addSql('ALTER TABLE course DROP category_id'); |
||||
} |
||||
|
||||
public function down(Schema $schema) : void |
||||
{ |
||||
// this down() migration is auto-generated, please modify it to your needs |
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
||||
|
||||
$this->addSql('CREATE TABLE version (id INT UNSIGNED AUTO_INCREMENT NOT NULL, version VARCHAR(20) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, UNIQUE INDEX version (version), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); |
||||
$this->addSql('DROP TABLE course_rel_category'); |
||||
$this->addSql('ALTER TABLE course ADD category_id INT DEFAULT NULL'); |
||||
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB912469DE2 FOREIGN KEY (category_id) REFERENCES course_category (id)'); |
||||
$this->addSql('CREATE INDEX IDX_169E6FB912469DE2 ON course (category_id)'); |
||||
} |
||||
} |
Loading…
Reference in new issue