]> git.immae.eu Git - github/wallabag/wallabag.git/blob - app/DoctrineMigrations/Version20170501115751.php
Update deps
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20170501115751.php
1 <?php
2
3 namespace Application\Migrations;
4
5 use Doctrine\DBAL\Schema\Schema;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8 /**
9 * Add site credential table to store username & password for some website (behind authentication or paywall).
10 */
11 class Version20170501115751 extends WallabagMigration
12 {
13 public function up(Schema $schema)
14 {
15 $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.');
16
17 $table = $schema->createTable($this->getTable('site_credential'));
18 $table->addColumn('id', 'integer', ['autoincrement' => true]);
19 $table->addColumn('user_id', 'integer');
20 $table->addColumn('host', 'string', ['length' => 255]);
21 $table->addColumn('username', 'text');
22 $table->addColumn('password', 'text');
23 $table->addColumn('createdAt', 'datetime');
24 $table->addIndex(['user_id'], 'idx_user');
25 $table->setPrimaryKey(['id']);
26 $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user');
27
28 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
29 $schema->dropSequence('site_credential_id_seq');
30 $schema->createSequence('site_credential_id_seq');
31 }
32 }
33
34 public function down(Schema $schema)
35 {
36 $schema->dropTable($this->getTable('site_credential'));
37 }
38 }