60 lines
6.7 KiB
PHP
60 lines
6.7 KiB
PHP
|
<?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 Version20230620171220 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->addSql('ALTER TABLE choice DROP FOREIGN KEY FK_C1AB5A923C947C0F');
|
||
|
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C7E3C61F9');
|
||
|
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C3C947C0F');
|
||
|
$this->addSql('ALTER TABLE poll DROP FOREIGN KEY FK_84BCFA457E3C61F9');
|
||
|
$this->addSql('ALTER TABLE stack_of_votes DROP FOREIGN KEY FK_4809A40D7E3C61F9');
|
||
|
$this->addSql('ALTER TABLE stack_of_votes DROP FOREIGN KEY FK_4809A40D3C947C0F');
|
||
|
$this->addSql('ALTER TABLE vote DROP FOREIGN KEY FK_5A108564998666D1');
|
||
|
$this->addSql('ALTER TABLE vote DROP FOREIGN KEY FK_5A1085643C947C0F');
|
||
|
$this->addSql('ALTER TABLE vote DROP FOREIGN KEY FK_5A1085649903A56B');
|
||
|
$this->addSql('DROP TABLE owner');
|
||
|
$this->addSql('DROP TABLE choice');
|
||
|
$this->addSql('DROP TABLE comment');
|
||
|
$this->addSql('DROP TABLE poll');
|
||
|
$this->addSql('DROP TABLE stack_of_votes');
|
||
|
$this->addSql('DROP TABLE vote');
|
||
|
}
|
||
|
|
||
|
public function down(Schema $schema): void
|
||
|
{
|
||
|
// this down() migration is auto-generated, please modify it to your needs
|
||
|
$this->addSql('CREATE TABLE owner (id INT AUTO_INCREMENT NOT NULL, pseudo VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, email VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, modifier_token VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, requested_polls_date DATETIME DEFAULT CURRENT_TIMESTAMP, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('CREATE TABLE choice (id INT AUTO_INCREMENT NOT NULL, poll_id INT DEFAULT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, url VARCHAR(1024) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_C1AB5A923C947C0F (poll_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, poll_id INT DEFAULT NULL, pseudo VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, text LONGTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_9474526C7E3C61F9 (owner_id), INDEX IDX_9474526C3C947C0F (poll_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('CREATE TABLE poll (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, title VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, custom_url VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, description VARCHAR(1000) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, expiracy_date DATETIME NOT NULL, kind VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, allowed_answers LONGTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:array)\', votes_allowed TINYINT(1) DEFAULT NULL, is_zero_knowledge TINYINT(1) DEFAULT NULL, votes_max SMALLINT DEFAULT NULL, choices_max SMALLINT DEFAULT NULL, comments_allowed TINYINT(1) DEFAULT NULL, modification_policy VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, mail_on_comment TINYINT(1) DEFAULT NULL, mail_on_vote TINYINT(1) DEFAULT NULL, hide_results TINYINT(1) DEFAULT NULL, show_result_even_if_passwords TINYINT(1) DEFAULT NULL, password VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, admin_key VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, UNIQUE INDEX UNIQ_84BCFA4559CFBEEF (custom_url), INDEX IDX_84BCFA457E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('CREATE TABLE stack_of_votes (id INT AUTO_INCREMENT NOT NULL, poll_id INT DEFAULT NULL, owner_id INT DEFAULT NULL, pseudo VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, ip VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_4809A40D3C947C0F (poll_id), INDEX IDX_4809A40D7E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('CREATE TABLE vote (id INT AUTO_INCREMENT NOT NULL, choice_id INT NOT NULL, poll_id INT NOT NULL, stacks_of_votes_id INT NOT NULL, value VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_5A108564998666D1 (choice_id), INDEX IDX_5A1085643C947C0F (poll_id), INDEX IDX_5A1085649903A56B (stacks_of_votes_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||
|
$this->addSql('ALTER TABLE choice ADD CONSTRAINT FK_C1AB5A923C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
|
||
|
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C7E3C61F9 FOREIGN KEY (owner_id) REFERENCES owner (id)');
|
||
|
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C3C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
|
||
|
$this->addSql('ALTER TABLE poll ADD CONSTRAINT FK_84BCFA457E3C61F9 FOREIGN KEY (owner_id) REFERENCES owner (id)');
|
||
|
$this->addSql('ALTER TABLE stack_of_votes ADD CONSTRAINT FK_4809A40D7E3C61F9 FOREIGN KEY (owner_id) REFERENCES owner (id)');
|
||
|
$this->addSql('ALTER TABLE stack_of_votes ADD CONSTRAINT FK_4809A40D3C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
|
||
|
$this->addSql('ALTER TABLE vote ADD CONSTRAINT FK_5A108564998666D1 FOREIGN KEY (choice_id) REFERENCES choice (id)');
|
||
|
$this->addSql('ALTER TABLE vote ADD CONSTRAINT FK_5A1085643C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
|
||
|
$this->addSql('ALTER TABLE vote ADD CONSTRAINT FK_5A1085649903A56B FOREIGN KEY (stacks_of_votes_id) REFERENCES stack_of_votes (id)');
|
||
|
}
|
||
|
}
|