mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-16 18:01:38 +00:00
Added hardcoded SQL for migration to 2.2
This commit is contained in:
parent
b87f171233
commit
4acbeb9371
7 changed files with 840 additions and 17 deletions
|
@ -6,6 +6,7 @@ use Doctrine\DBAL\Migrations\AbstractMigration;
|
|||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\DBAL\Migrations\SkipMigrationException;
|
||||
|
||||
/**
|
||||
* Added pocket_consumer_key field on wallabag_config
|
||||
|
|
|
@ -17,6 +17,8 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
|||
*/
|
||||
private $container;
|
||||
|
||||
private $constraintName = 'IDX_user_oauth_client';
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
@ -36,13 +38,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
|||
|
||||
$this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
|
||||
|
||||
$clientsTable->addColumn('user_id', 'integer');
|
||||
$clientsTable->addColumn('user_id', 'integer', ['notnull' => false]);
|
||||
|
||||
$clientsTable->addForeignKeyConstraint(
|
||||
$this->getTable('user'),
|
||||
['user_id'],
|
||||
['id'],
|
||||
['onDelete' => 'CASCADE']
|
||||
['onDelete' => 'CASCADE'],
|
||||
$this->constraintName
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -51,5 +54,14 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
|||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
|
||||
|
||||
$this->skipIf(!$clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
|
||||
|
||||
$clientsTable->dropColumn('user_id', 'integer');
|
||||
|
||||
if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') {
|
||||
$clientsTable->removeForeignKey($this->constraintName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
|
|||
public function down(Schema $schema)
|
||||
{
|
||||
$configTable = $schema->getTable($this->getTable('config'));
|
||||
$userTable->dropColumn('action_mark_as_read');
|
||||
|
||||
$this->skipIf(!$configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.');
|
||||
|
||||
$configTable->dropColumn('action_mark_as_read');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,10 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
|
|||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$userTable = $schema->getTable($this->getTable('entry'));
|
||||
$userTable->dropColumn('http_status');
|
||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||
|
||||
$this->skipIf(!$entryTable->hasColumn('http_status'), 'It seems that you already played this migration.');
|
||||
|
||||
$entryTable->dropColumn('http_status');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,10 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
|
|||
public function down(Schema $schema)
|
||||
{
|
||||
$userTable = $schema->getTable($this->getTable('user'));
|
||||
$userTable->addColumn('expired', 'smallint');
|
||||
$userTable->addColumn('credentials_expired', 'smallint');
|
||||
|
||||
$this->skipIf(true === $userTable->hasColumn('expired') || true === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
|
||||
|
||||
$userTable->addColumn('expired', 'smallint', ['notnull' => false]);
|
||||
$userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class Version20161128131503 extends AbstractMigration implements ContainerAwareI
|
|||
|
||||
foreach ($this->fields as $field => $type) {
|
||||
$this->skipIf($userTable->hasColumn($field), 'It seems that you already played this migration.');
|
||||
$userTable->addColumn($field, $type);
|
||||
$userTable->addColumn($field, $type, ['notnull' => false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue