]>
Commit | Line | Data |
---|---|---|
f92fcb53 JB |
1 | <?php |
2 | ||
3 | namespace Application\Migrations; | |
4 | ||
f92fcb53 | 5 | use Doctrine\DBAL\Schema\Schema; |
bfe7a692 | 6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; |
f92fcb53 JB |
7 | |
8 | /** | |
f808b016 | 9 | * Add site credential table to store username & password for some website (behind authentication or paywall). |
f92fcb53 | 10 | */ |
bfe7a692 | 11 | class Version20170501115751 extends WallabagMigration |
f92fcb53 | 12 | { |
f92fcb53 JB |
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]); | |
bead8b42 | 21 | $table->addColumn('username', 'text'); |
906424c1 | 22 | $table->addColumn('password', 'text'); |
f92fcb53 JB |
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'); | |
fd7fde95 JB |
27 | |
28 | if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { | |
29 | $schema->dropSequence('site_credential_id_seq'); | |
30 | $schema->createSequence('site_credential_id_seq'); | |
31 | } | |
f92fcb53 JB |
32 | } |
33 | ||
f92fcb53 JB |
34 | public function down(Schema $schema) |
35 | { | |
36 | $schema->dropTable($this->getTable('site_credential')); | |
37 | } | |
38 | } |