cgk-rooster-streamen/migrations/Version20231120113913.php

47 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20231120113913 extends AbstractMigration
{
public function getDescription(): string
{
return 'Initial schema with user and roster tables';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE "user" (
id SERIAL PRIMARY KEY,
full_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
token VARCHAR(255) NOT NULL,
role VARCHAR(255) DEFAULT NULL
)');
$this->addSql('CREATE TABLE roster (
id SERIAL PRIMARY KEY,
user_id INT DEFAULT NULL,
date DATE NOT NULL,
time TIME NOT NULL,
description VARCHAR(255) DEFAULT NULL,
CONSTRAINT fk_roster_user FOREIGN KEY (user_id) REFERENCES "user" (id)
)');
$this->addSql('CREATE INDEX idx_roster_user_id ON roster (user_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE roster DROP CONSTRAINT fk_roster_user');
$this->addSql('DROP INDEX IF EXISTS idx_roster_user_id');
$this->addSql('DROP TABLE IF EXISTS roster');
$this->addSql('DROP TABLE IF EXISTS "user"');
}
}