kekrozsak/app/DoctrineMigrations/Version20120826132126.php

40 lines
2.3 KiB
PHP

<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20120826132126 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
$this->addSql("CREATE TABLE upload_namespaces (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, slug VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_32D9781A5E237E06 (name), UNIQUE INDEX UNIQ_32D9781A989D9B62 (slug), PRIMARY KEY(id)) ENGINE = InnoDB");
$this->addSql("CREATE TABLE uploaded_files (id INT AUTO_INCREMENT NOT NULL, upload_namespace_id INT NOT NULL, filename VARCHAR(100) NOT NULL, mimeType VARCHAR(50) NOT NULL, description LONGTEXT DEFAULT NULL, INDEX IDX_E60EFB5609DE9D8 (upload_namespace_id), UNIQUE INDEX UNIQ_E60EFB5609DE9D83C0BE965 (upload_namespace_id, filename), PRIMARY KEY(id)) ENGINE = InnoDB");
$this->addSql("ALTER TABLE uploaded_files ADD CONSTRAINT FK_E60EFB5609DE9D8 FOREIGN KEY (upload_namespace_id) REFERENCES upload_namespaces (id)");
$this->addSql("ALTER TABLE user_data ADD avatar_image_id INT DEFAULT NULL");
$this->addSql("ALTER TABLE user_data ADD CONSTRAINT FK_D772BFAA5C18B4B1 FOREIGN KEY (avatar_image_id) REFERENCES uploaded_files (id)");
$this->addSql("CREATE INDEX IDX_D772BFAA5C18B4B1 ON user_data (avatar_image_id)");
}
public function down(Schema $schema)
{
// this down() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
$this->addSql("ALTER TABLE uploaded_files DROP FOREIGN KEY FK_E60EFB5609DE9D8");
$this->addSql("ALTER TABLE user_data DROP FOREIGN KEY FK_D772BFAA5C18B4B1");
$this->addSql("DROP TABLE upload_namespaces");
$this->addSql("DROP TABLE uploaded_files");
$this->addSql("ALTER TABLE user_data DROP FOREIGN KEY FK_D772BFAA5C18B4B1");
$this->addSql("DROP INDEX IDX_D772BFAA5C18B4B1 ON user_data");
$this->addSql("ALTER TABLE user_data DROP avatar_image_id");
}
}