current init
This commit is contained in:
35
backend/migrations/Version20260323230657.php
Normal file
35
backend/migrations/Version20260323230657.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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 Version20260323230657 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('CREATE TABLE category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, color VARCHAR(7) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, status VARCHAR(20) NOT NULL, task_type VARCHAR(20) NOT NULL, deadline DATE DEFAULT NULL, interval_type VARCHAR(20) DEFAULT NULL, start_date DATE DEFAULT NULL, end_date DATE DEFAULT NULL, weekdays JSON DEFAULT NULL, month_days JSON DEFAULT NULL, category_id INT DEFAULT NULL, INDEX IDX_527EDB2512469DE2 (category_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB2512469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB2512469DE2');
|
||||
$this->addSql('DROP TABLE category');
|
||||
$this->addSql('DROP TABLE task');
|
||||
}
|
||||
}
|
||||
33
backend/migrations/Version20260324141105.php
Normal file
33
backend/migrations/Version20260324141105.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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 Version20260324141105 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('CREATE TABLE task_completion (id INT AUTO_INCREMENT NOT NULL, date DATE NOT NULL, task_id INT NOT NULL, INDEX IDX_24C57CD18DB60186 (task_id), UNIQUE INDEX UNIQ_24C57CD18DB60186AA9E377A (task_id, date), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task_completion ADD CONSTRAINT FK_24C57CD18DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_completion DROP FOREIGN KEY FK_24C57CD18DB60186');
|
||||
$this->addSql('DROP TABLE task_completion');
|
||||
}
|
||||
}
|
||||
36
backend/migrations/Version20260324154816.php
Normal file
36
backend/migrations/Version20260324154816.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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 Version20260324154816 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('CREATE TABLE task_occurrence (id INT AUTO_INCREMENT NOT NULL, date DATE NOT NULL, status VARCHAR(20) NOT NULL, task_id INT NOT NULL, INDEX IDX_A2EECA5C8DB60186 (task_id), UNIQUE INDEX UNIQ_A2EECA5C8DB60186AA9E377A (task_id, date), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C8DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
$this->addSql("INSERT INTO task_occurrence (task_id, date, status) SELECT task_id, date, 'erledigt' FROM task_completion");
|
||||
$this->addSql('ALTER TABLE task_completion DROP FOREIGN KEY FK_24C57CD18DB60186');
|
||||
$this->addSql('DROP TABLE task_completion');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C8DB60186');
|
||||
$this->addSql('DROP TABLE task_occurrence');
|
||||
}
|
||||
}
|
||||
35
backend/migrations/Version20260325064344.php
Normal file
35
backend/migrations/Version20260325064344.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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 Version20260325064344 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 task_occurrence ADD name VARCHAR(255) DEFAULT NULL, ADD category_overridden TINYINT NOT NULL, ADD category_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C12469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
$this->addSql('CREATE INDEX IDX_A2EECA5C12469DE2 ON task_occurrence (category_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C12469DE2');
|
||||
$this->addSql('DROP INDEX IDX_A2EECA5C12469DE2 ON task_occurrence');
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP name, DROP category_overridden, DROP category_id');
|
||||
}
|
||||
}
|
||||
50
backend/migrations/Version20260326165702.php
Normal file
50
backend/migrations/Version20260326165702.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260326165702 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Rename task → task_schema, task_occurrence → task';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// 1. Drop FKs on task_occurrence that reference task
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C8DB60186');
|
||||
|
||||
// 2. Drop FK on task.category_id
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB2512469DE2');
|
||||
|
||||
// 3. Rename tables
|
||||
$this->addSql('RENAME TABLE task TO task_schema');
|
||||
$this->addSql('RENAME TABLE task_occurrence TO task');
|
||||
|
||||
// 4. Re-create FK: task.task_id → task_schema.id
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB258DB60186 FOREIGN KEY (task_id) REFERENCES task_schema (id) ON DELETE CASCADE');
|
||||
|
||||
// 5. Re-create FK: task_schema.category_id → category.id
|
||||
$this->addSql('ALTER TABLE task_schema ADD CONSTRAINT FK_8327C58112469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// Drop FKs
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB258DB60186');
|
||||
$this->addSql('ALTER TABLE task_schema DROP FOREIGN KEY FK_8327C58112469DE2');
|
||||
|
||||
// Rename back
|
||||
$this->addSql('RENAME TABLE task TO task_occurrence');
|
||||
$this->addSql('RENAME TABLE task_schema TO task');
|
||||
|
||||
// Re-create original FKs
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C8DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB2512469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user