From a36259dc34767fbd89b83e2f53530683631739a4 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sun, 27 Mar 2016 00:33:55 +0300 Subject: [PATCH] Some varchar fields altered to text. New migration. --- .../Version20160326030437.php | 52 +++++++++++++++++++ .../PointToolsBundle/Entity/Blogs/File.php | 2 +- .../PointToolsBundle/Entity/Blogs/Post.php | 2 +- .../PointToolsBundle/Entity/Blogs/PostTag.php | 2 +- .../PointToolsBundle/Entity/Blogs/Tag.php | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 app/DoctrineMigrations/Version20160326030437.php diff --git a/app/DoctrineMigrations/Version20160326030437.php b/app/DoctrineMigrations/Version20160326030437.php new file mode 100644 index 0000000..4f0291d --- /dev/null +++ b/app/DoctrineMigrations/Version20160326030437.php @@ -0,0 +1,52 @@ +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)'); + } +} diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/File.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/File.php index f32ccbb..d1f9841 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/File.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/File.php @@ -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; diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php index 8ddf777..e068cdf 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Post.php @@ -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; diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/PostTag.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/PostTag.php index f66f3d2..a25027b 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/PostTag.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/PostTag.php @@ -40,7 +40,7 @@ class PostTag /** * @var string * - * @ORM\Column(name="text", type="string", length=128) + * @ORM\Column(name="text", type="text") */ private $text; diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Tag.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Tag.php index 2628b4a..91cdc8e 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Tag.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Tag.php @@ -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;