Some varchar fields altered to text. New migration.

This commit is contained in:
Alexey Skobkin 2016-03-27 00:33:55 +03:00
parent dd3733f75e
commit a36259dc34
5 changed files with 56 additions and 4 deletions

View File

@ -0,0 +1,52 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160326030437 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE posts.comments ALTER post_id TYPE TEXT');
$this->addSql('ALTER TABLE posts.posts ALTER id TYPE TEXT');
$this->addSql('ALTER TABLE posts.posts_files ALTER post_id TYPE TEXT');
$this->addSql('ALTER TABLE posts.tags ALTER text TYPE TEXT');
$this->addSql('ALTER TABLE posts.posts_tags ALTER post_id TYPE TEXT');
$this->addSql('ALTER TABLE posts.posts_tags ALTER text TYPE TEXT');
$this->addSql('DROP INDEX posts.uniq_744cc52c80445aea');
$this->addSql('ALTER TABLE posts.files ADD remote_url TEXT NOT NULL');
$this->addSql('ALTER TABLE posts.files DROP remoteurl');
$this->addSql('CREATE UNIQUE INDEX UNIQ_744CC52C68EA44FC ON posts.files (remote_url)');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE posts.comments ALTER post_id TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE posts.posts ALTER id TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE posts.tags ALTER text TYPE VARCHAR(128)');
$this->addSql('ALTER TABLE posts.posts_tags ALTER post_id TYPE VARCHAR(16)');
$this->addSql('ALTER TABLE posts.posts_tags ALTER text TYPE VARCHAR(128)');
$this->addSql('DROP INDEX posts.UNIQ_744CC52C68EA44FC');
$this->addSql('ALTER TABLE posts.files ADD remoteurl VARCHAR(128) NOT NULL');
$this->addSql('ALTER TABLE posts.files DROP remote_url');
$this->addSql('CREATE UNIQUE INDEX uniq_744cc52c80445aea ON posts.files (remoteurl)');
$this->addSql('ALTER TABLE posts.posts_files ALTER post_id TYPE VARCHAR(16)');
}
}

View File

@ -24,7 +24,7 @@ class File
/**
* @var string
*
* @ORM\Column(name="remoteUrl", type="string", length=128, unique=true)
* @ORM\Column(name="remote_url", type="text", unique=true)
*/
private $remoteUrl;

View File

@ -24,7 +24,7 @@ class Post
/**
* @var int
*
* @ORM\Column(name="id", type="string", length=16)
* @ORM\Column(name="id", type="text")
* @ORM\Id
*/
private $id;

View File

@ -40,7 +40,7 @@ class PostTag
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=128)
* @ORM\Column(name="text", type="text")
*/
private $text;

View File

@ -26,7 +26,7 @@ class Tag
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=128, unique=true)
* @ORM\Column(name="text", type="text", unique=true)
*/
private $text;