<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20221217123924 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add geolocation table';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE geolocation (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, country_id INT UNSIGNED DEFAULT NULL, creator_id BIGINT UNSIGNED NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, latitude DOUBLE PRECISION NOT NULL, longitude DOUBLE PRECISION NOT NULL, active TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_9DC0E5B4F92F3E70 (country_id), UNIQUE INDEX UNIQ_9DC0E5B461220EA6 (creator_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE geolocation ADD CONSTRAINT FK_9DC0E5B4F92F3E70 FOREIGN KEY (country_id) REFERENCES country (id)');
$this->addSql('ALTER TABLE geolocation ADD CONSTRAINT FK_9DC0E5B461220EA6 FOREIGN KEY (creator_id) REFERENCES creator (id)');
$this->addSql('ALTER TABLE creator ADD geolocation_id BIGINT UNSIGNED DEFAULT NULL');
$this->addSql('ALTER TABLE creator ADD CONSTRAINT FK_BC06EA631C7B5678 FOREIGN KEY (geolocation_id) REFERENCES geolocation (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_BC06EA631C7B5678 ON creator (geolocation_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE creator DROP FOREIGN KEY FK_BC06EA631C7B5678');
$this->addSql('DROP TABLE geolocation');
$this->addSql('DROP INDEX UNIQ_BC06EA631C7B5678 ON creator');
$this->addSql('ALTER TABLE creator DROP geolocation_id');
}
public function isTransactional(): bool
{
return false;
}
}