File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /*
6
+ * This file is part of the Explicit Architecture POC,
7
+ * which is created on top of the Symfony Demo application.
8
+ *
9
+ * (c) Herberto Graça <[email protected] >
10
+ *
11
+ * For the full copyright and license information, please view the LICENSE
12
+ * file that was distributed with this source code.
13
+ */
14
+
15
+ namespace Acme \App \Build \Migration \Version ;
16
+
17
+ use Acme \App \Build \Migration \ConfigurationAwareMigration ;
18
+ use Acme \App \Build \Migration \MigrationHelperTrait ;
19
+ use Doctrine \DBAL \Schema \Schema ;
20
+
21
+ final class Version20180118095302 extends ConfigurationAwareMigration
22
+ {
23
+ use MigrationHelperTrait;
24
+
25
+ /**
26
+ * @throws \Doctrine\DBAL\DBALException
27
+ * @throws \Doctrine\DBAL\Migrations\AbortMigrationException
28
+ */
29
+ public function up (Schema $ schema ): void
30
+ {
31
+ $ engine = $ this ->connection ->getDatabasePlatform ()->getName ();
32
+ switch ($ engine ) {
33
+ case 'mysql ' :
34
+ $ this ->addSql (
35
+ 'CREATE TABLE KeyValueStorage (`key` VARCHAR(255) PRIMARY KEY, `value` VARCHAR(255) DEFAULT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB '
36
+ );
37
+ break ;
38
+ case 'sqlite ' :
39
+ $ this ->addSql ('CREATE TABLE KeyValueStorage (`key` TEXT PRIMARY KEY, `value` TEXT DEFAULT NULL) ' );
40
+ break ;
41
+ default :
42
+ $ this ->abortIf (true , "Unknown engine type ' $ engine'. " );
43
+ }
44
+ }
45
+
46
+ public function down (Schema $ schema ): void
47
+ {
48
+ $ this ->addSql ('DROP TABLE KeyValueStorage ' );
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments