Skip to content

Commit a034528

Browse files
committed
add migration
1 parent eb8f21d commit a034528

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Migration;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20260618121357 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('CREATE TABLE author (name LONGTEXT NOT NULL, slug LONGTEXT NOT NULL, bio LONGTEXT DEFAULT NULL, email LONGTEXT NOT NULL, id UUID NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_BDAFD8C8989D9B62 (slug), UNIQUE INDEX UNIQ_BDAFD8C8E7927C74 (email), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
24+
$this->addSql('CREATE TABLE category (name LONGTEXT NOT NULL, slug LONGTEXT NOT NULL, isVisible TINYINT NOT NULL, id UUID NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
25+
$this->addSql('CREATE TABLE post (title LONGTEXT NOT NULL, slug LONGTEXT NOT NULL, post_date DATETIME NOT NULL, excerpt LONGTEXT NOT NULL, status ENUM(\'draft\', \'published\', \'private\') DEFAULT \'draft\' NOT NULL, id UUID NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, category_id UUID NOT NULL, author_id UUID NOT NULL, UNIQUE INDEX UNIQ_5A8A6C8D989D9B62 (slug), INDEX IDX_5A8A6C8D12469DE2 (category_id), INDEX IDX_5A8A6C8DF675F31B (author_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
26+
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8D12469DE2 FOREIGN KEY (category_id) REFERENCES category (id)');
27+
$this->addSql('ALTER TABLE post ADD CONSTRAINT FK_5A8A6C8DF675F31B FOREIGN KEY (author_id) REFERENCES author (id)');
28+
}
29+
30+
public function down(Schema $schema): void
31+
{
32+
// this down() migration is auto-generated, please modify it to your needs
33+
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8D12469DE2');
34+
$this->addSql('ALTER TABLE post DROP FOREIGN KEY FK_5A8A6C8DF675F31B');
35+
$this->addSql('DROP TABLE author');
36+
$this->addSql('DROP TABLE category');
37+
$this->addSql('DROP TABLE post');
38+
}
39+
}

0 commit comments

Comments
 (0)