aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-06-23 11:52:05 +0200
committerThomas Citharel <tcit@tcit.fr>2017-07-09 19:05:48 +0200
commit314ff292f012b879c2b43deed48a1c82be9edfd6 (patch)
tree34c47c4a8fe1a424a29eb4e4240899d1245135e1
parent378aaefbbf60698c7b8faafc20f6b8cb22357e31 (diff)
downloadwallabag-314ff292f012b879c2b43deed48a1c82be9edfd6.tar.gz
wallabag-314ff292f012b879c2b43deed48a1c82be9edfd6.tar.zst
wallabag-314ff292f012b879c2b43deed48a1c82be9edfd6.zip
Add migration
-rw-r--r--app/DoctrineMigrations/Version20170623092923.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20170623092923.php b/app/DoctrineMigrations/Version20170623092923.php
new file mode 100644
index 00000000..5c6eafa7
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170623092923.php
@@ -0,0 +1,63 @@
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 Notifications table
12 */
13class Version20170623092923 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('notification')), 'It seems that you already played this migration.');
36
37 $table = $schema->createTable($this->getTable('notification'));
38 $table->addColumn('id', 'integer', ['autoincrement' => true]);
39 $table->addColumn('user_id', 'integer');
40 $table->addColumn('timestamp', 'datetime');
41 $table->addColumn('title', 'text');
42 $table->addColumn('description', 'text');
43 $table->addColumn('read', 'boolean');
44 $table->addColumn('actions', 'text');
45 $table->addColumn('parameter', 'text');
46 $table->addIndex(['user_id'], 'idx_user');
47 $table->setPrimaryKey(['id']);
48 $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user');
49
50 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
51 $schema->dropSequence('notification_id_seq');
52 $schema->createSequence('notification_id_seq');
53 }
54 }
55
56 /**
57 * @param Schema $schema
58 */
59 public function down(Schema $schema)
60 {
61 $schema->dropTable($this->getTable('notification'));
62 }
63}