diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-12-12 20:20:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 20:20:31 +0100 |
commit | 1f198256edd057abe110687e5049c0a904eb3c17 (patch) | |
tree | 83d5551fc228906a9c457f65a5fa4d0a81c7a91a | |
parent | f209798368de66b4acd8b892fe71018ebb30c2da (diff) | |
parent | 3fadf42a1c177fc41748c7732cbb4b13cbee4a14 (diff) | |
download | wallabag-1f198256edd057abe110687e5049c0a904eb3c17.tar.gz wallabag-1f198256edd057abe110687e5049c0a904eb3c17.tar.zst wallabag-1f198256edd057abe110687e5049c0a904eb3c17.zip |
Merge pull request #3487 from wallabag/initial-migration
Change the way to check for initial migration
-rw-r--r-- | app/DoctrineMigrations/Version20160401000000.php | 26 |
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 | ||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | 5 | use Doctrine\DBAL\Migrations\AbstractMigration; |
6 | use Doctrine\DBAL\Schema\Schema; | 6 | use Doctrine\DBAL\Schema\Schema; |
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * Initial database structure. | 11 | * Initial database structure. |
10 | */ | 12 | */ |
11 | class Version20160401000000 extends AbstractMigration | 13 | class 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 | |||
160 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | 169 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; |
161 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | 170 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; |
162 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | 171 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; |
163 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | 172 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; |
164 | SQL | 173 | SQL |
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 | } |