<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Ramsey\Uuid\Uuid;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221229182400 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 position (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, sort_order INT DEFAULT NULL, created_at DATETIME NOT NULL, modified_at DATETIME NOT NULL, INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE user ADD position VARCHAR(255) DEFAULT NULL, ADD bio LONGTEXT DEFAULT NULL, ADD twitter_username VARCHAR(255) DEFAULT NULL, ADD linked_in_username VARCHAR(255) DEFAULT NULL, ADD location VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE workspace ADD website VARCHAR(255) DEFAULT NULL, ADD body LONGTEXT DEFAULT NULL');
foreach ($this->getPositions() as $index => $position) {
$now = (new \DateTime())->format('Y-m-d H:i:s');
$this->addSql('INSERT INTO position (id, name, sort_order, created_at, modified_at) VALUES (:id, :name, :sort_order, :created_at, :modified_at)', [
'id' => Uuid::uuid4(),
'name' => $position,
'sort_order' => $index + 1,
'created_at' => $now,
'modified_at' => $now,
]);
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE position');
$this->addSql('ALTER TABLE user DROP position, DROP bio, DROP twitter_username, DROP linked_in_username, DROP location');
$this->addSql('ALTER TABLE workspace DROP website, DROP body');
}
private function getPositions(): array
{
return [
'CEO/Founder',
'Leadership',
'Management',
'Operations',
'Marketing',
'Development',
'Freelance',
'Finance',
'Legal',
'Sales',
'HR',
'Other',
];
}
}