From fd7fde95159828960784a438c4b4da147e20ab18 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 2 May 2017 08:38:22 +0200 Subject: Force sequence creation for postgresql --- app/DoctrineMigrations/Version20161204115751.php | 56 ---------------------- app/DoctrineMigrations/Version20170501115751.php | 61 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 56 deletions(-) delete mode 100644 app/DoctrineMigrations/Version20161204115751.php create mode 100644 app/DoctrineMigrations/Version20170501115751.php diff --git a/app/DoctrineMigrations/Version20161204115751.php b/app/DoctrineMigrations/Version20161204115751.php deleted file mode 100644 index 97635fa7..00000000 --- a/app/DoctrineMigrations/Version20161204115751.php +++ /dev/null @@ -1,56 +0,0 @@ -container = $container; - } - - private function getTable($tableName) - { - return $this->container->getParameter('database_table_prefix').$tableName; - } - - /** - * @param Schema $schema - */ - public function up(Schema $schema) - { - $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.'); - - $table = $schema->createTable($this->getTable('site_credential')); - $table->addColumn('id', 'integer', ['autoincrement' => true]); - $table->addColumn('user_id', 'integer'); - $table->addColumn('host', 'string', ['length' => 255]); - $table->addColumn('username', 'string', ['length' => 255]); - $table->addColumn('password', 'string', ['length' => 255]); - $table->addColumn('createdAt', 'datetime'); - $table->addIndex(['user_id'], 'idx_user'); - $table->setPrimaryKey(['id']); - $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user'); - } - - /** - * @param Schema $schema - */ - public function down(Schema $schema) - { - $schema->dropTable($this->getTable('site_credential')); - } -} diff --git a/app/DoctrineMigrations/Version20170501115751.php b/app/DoctrineMigrations/Version20170501115751.php new file mode 100644 index 00000000..846a87b5 --- /dev/null +++ b/app/DoctrineMigrations/Version20170501115751.php @@ -0,0 +1,61 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix').$tableName; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.'); + + $table = $schema->createTable($this->getTable('site_credential')); + $table->addColumn('id', 'integer', ['autoincrement' => true]); + $table->addColumn('user_id', 'integer'); + $table->addColumn('host', 'string', ['length' => 255]); + $table->addColumn('username', 'string', ['length' => 255]); + $table->addColumn('password', 'string', ['length' => 255]); + $table->addColumn('createdAt', 'datetime'); + $table->addIndex(['user_id'], 'idx_user'); + $table->setPrimaryKey(['id']); + $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user'); + + if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { + $schema->dropSequence('site_credential_id_seq'); + $schema->createSequence('site_credential_id_seq'); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $schema->dropTable($this->getTable('site_credential')); + } +} -- cgit v1.2.3