<?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 Version20240226132403 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 v2_currencies (id UUID NOT NULL, short_name VARCHAR(4) NOT NULL, full_name VARCHAR(100) NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN v2_currencies.id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE v2_exchange_rates (id UUID NOT NULL, reporting_period_id UUID NOT NULL, from_currency UUID NOT NULL, to_currency UUID NOT NULL, rate NUMERIC(10, 2) NOT NULL, custom_rate NUMERIC(10, 2) NOT NULL, edited_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_2D9E515A2832EB1C ON v2_exchange_rates (reporting_period_id)');
$this->addSql('CREATE INDEX IDX_2D9E515A2FB968A5 ON v2_exchange_rates (from_currency)');
$this->addSql('CREATE INDEX IDX_2D9E515AA40F1691 ON v2_exchange_rates (to_currency)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2D9E515A2832EB1C2FB968A5A40F1691 ON v2_exchange_rates (reporting_period_id, from_currency, to_currency)');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.reporting_period_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.from_currency IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.to_currency IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.edited_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN v2_exchange_rates.updated_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE v2_exchange_rates ADD CONSTRAINT FK_2D9E515A2832EB1C FOREIGN KEY (reporting_period_id) REFERENCES v2_reporting_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE v2_exchange_rates ADD CONSTRAINT FK_2D9E515A2FB968A5 FOREIGN KEY (from_currency) REFERENCES v2_currencies (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE v2_exchange_rates ADD CONSTRAINT FK_2D9E515AA40F1691 FOREIGN KEY (to_currency) REFERENCES v2_currencies (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE v2_exchange_rates DROP CONSTRAINT FK_2D9E515A2FB968A5');
$this->addSql('ALTER TABLE v2_exchange_rates DROP CONSTRAINT FK_2D9E515AA40F1691');
$this->addSql('DROP TABLE v2_currencies');
$this->addSql('DROP TABLE v2_exchange_rates');
}
}