aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-12-04 13:51:58 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-06-20 16:03:08 +0200
commitf92fcb53ca78cc8822962e676b0db117e1a08aa5 (patch)
tree80e4b828a6d96fe610728c1b60db4625767a5dd9 /app
parent873f6b8e03079d11fab541aa5b0bc6f8fe2d645e (diff)
downloadwallabag-f92fcb53ca78cc8822962e676b0db117e1a08aa5.tar.gz
wallabag-f92fcb53ca78cc8822962e676b0db117e1a08aa5.tar.zst
wallabag-f92fcb53ca78cc8822962e676b0db117e1a08aa5.zip
Add CRUD for site credentials
Diffstat (limited to 'app')
-rw-r--r--app/DoctrineMigrations/Version20161204115751.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20161204115751.php b/app/DoctrineMigrations/Version20161204115751.php
new file mode 100644
index 00000000..97635fa7
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161204115751.php
@@ -0,0 +1,56 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add site credential table to store username & password for some website (behind authentication or paywall)
12 */
13class Version20161204115751 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /**
31 * @param Schema $schema
32 */
33 public function up(Schema $schema)
34 {
35 $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.');
36
37 $table = $schema->createTable($this->getTable('site_credential'));
38 $table->addColumn('id', 'integer', ['autoincrement' => true]);
39 $table->addColumn('user_id', 'integer');
40 $table->addColumn('host', 'string', ['length' => 255]);
41 $table->addColumn('username', 'string', ['length' => 255]);
42 $table->addColumn('password', 'string', ['length' => 255]);
43 $table->addColumn('createdAt', 'datetime');
44 $table->addIndex(['user_id'], 'idx_user');
45 $table->setPrimaryKey(['id']);
46 $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user');
47 }
48
49 /**
50 * @param Schema $schema
51 */
52 public function down(Schema $schema)
53 {
54 $schema->dropTable($this->getTable('site_credential'));
55 }
56}