]>
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 | /** |
14 | * @param Schema $schema | |
15 | */ | |
16 | public function up(Schema $schema) | |
17 | { | |
18 | $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.'); | |
19 | ||
20 | $table = $schema->createTable($this->getTable('site_credential')); | |
21 | $table->addColumn('id', 'integer', ['autoincrement' => true]); | |
22 | $table->addColumn('user_id', 'integer'); | |
23 | $table->addColumn('host', 'string', ['length' => 255]); | |
bead8b42 | 24 | $table->addColumn('username', 'text'); |
906424c1 | 25 | $table->addColumn('password', 'text'); |
f92fcb53 JB |
26 | $table->addColumn('createdAt', 'datetime'); |
27 | $table->addIndex(['user_id'], 'idx_user'); | |
28 | $table->setPrimaryKey(['id']); | |
29 | $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user'); | |
fd7fde95 JB |
30 | |
31 | if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { | |
32 | $schema->dropSequence('site_credential_id_seq'); | |
33 | $schema->createSequence('site_credential_id_seq'); | |
34 | } | |
f92fcb53 JB |
35 | } |
36 | ||
37 | /** | |
38 | * @param Schema $schema | |
39 | */ | |
40 | public function down(Schema $schema) | |
41 | { | |
42 | $schema->dropTable($this->getTable('site_credential')); | |
43 | } | |
44 | } |