aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160401000000.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20160401000000.php')
-rw-r--r--app/DoctrineMigrations/Version20160401000000.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/app/DoctrineMigrations/Version20160401000000.php b/app/DoctrineMigrations/Version20160401000000.php
index a8603abf..a88d2dc0 100644
--- a/app/DoctrineMigrations/Version20160401000000.php
+++ b/app/DoctrineMigrations/Version20160401000000.php
@@ -4,21 +4,30 @@ namespace Application\Migrations;
4 4
5use Doctrine\DBAL\Migrations\AbstractMigration; 5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema; 6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
7 9
8/** 10/**
9 * Initial database structure. 11 * Initial database structure.
10 */ 12 */
11class Version20160401000000 extends AbstractMigration 13class Version20160401000000 extends AbstractMigration implements ContainerAwareInterface
12{ 14{
13 /** 15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
14 * @param Schema $schema 26 * @param Schema $schema
15 */ 27 */
16 public function up(Schema $schema) 28 public function up(Schema $schema)
17 { 29 {
18 if ($this->version->getConfiguration()->getNumberOfExecutedMigrations() > 0) { 30 $this->skipIf($schema->hasTable($this->getTable('entry')), 'Database already initialized');
19 $this->version->markMigrated();
20 $this->skipIf(true, 'Database already initialized');
21 }
22 31
23 switch ($this->connection->getDatabasePlatform()->getName()) { 32 switch ($this->connection->getDatabasePlatform()->getName()) {
24 case 'sqlite': 33 case 'sqlite':
@@ -160,7 +169,7 @@ ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FO
160ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; 169ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE;
161ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; 170ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE;
162ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; 171ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE;
163ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; 172ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE;
164SQL 173SQL
165 ; 174 ;
166 foreach (explode("\n", $sql) as $query) { 175 foreach (explode("\n", $sql) as $query) {
@@ -188,4 +197,9 @@ SQL
188 $this->addSql('DROP TABLE "wallabag_user"'); 197 $this->addSql('DROP TABLE "wallabag_user"');
189 $this->addSql('DROP TABLE wallabag_annotation'); 198 $this->addSql('DROP TABLE wallabag_annotation');
190 } 199 }
200
201 private function getTable($tableName)
202 {
203 return $this->container->getParameter('database_table_prefix') . $tableName;
204 }
191} 205}