diff options
-rw-r--r-- | .travis.yml | 6 | ||||
-rwxr-xr-x | Makefile | 13 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20160401000000.php | 191 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20160812120952.php | 28 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20170824113337.php | 7 | ||||
-rw-r--r-- | data/sql/mysql_base.sql | 25 | ||||
-rw-r--r-- | data/sql/pgsql_base.sql | 62 | ||||
-rw-r--r-- | data/sql/sqlite_base.sql | 33 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 31 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | 8 |
10 files changed, 237 insertions, 167 deletions
diff --git a/.travis.yml b/.travis.yml index 42fbb966..c6c03dc3 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -70,11 +70,9 @@ before_install: | |||
70 | 70 | ||
71 | script: | 71 | script: |
72 | - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist | 72 | - travis_wait bash composer install -o --no-interaction --no-progress --prefer-dist |
73 | - echo "travis_fold:start:prepare" | ||
73 | - make prepare DB=$DB | 74 | - make prepare DB=$DB |
74 | 75 | - echo "travis_fold:end:prepare" | |
75 | - echo "travis_fold:start:migrations" | ||
76 | - php bin/console doctrine:migrations:migrate --no-interaction --env=test | ||
77 | - echo "travis_fold:end:migrations" | ||
78 | 76 | ||
79 | - echo "travis_fold:start:fixtures" | 77 | - echo "travis_fold:start:fixtures" |
80 | - php bin/console doctrine:fixtures:load --no-interaction --env=test | 78 | - php bin/console doctrine:fixtures:load --no-interaction --env=test |
@@ -30,18 +30,7 @@ ifdef DB | |||
30 | endif | 30 | endif |
31 | -php bin/console doctrine:database:drop --force --env=test | 31 | -php bin/console doctrine:database:drop --force --env=test |
32 | php bin/console doctrine:database:create --env=test | 32 | php bin/console doctrine:database:create --env=test |
33 | ifndef DB ## make test does not define DB | 33 | php bin/console doctrine:migrations:migrate --no-interaction --env=test |
34 | php bin/console doctrine:schema:create --env=test | ||
35 | endif | ||
36 | ifeq ($(DB), sqlite) | ||
37 | php bin/console doctrine:schema:create --env=test | ||
38 | endif | ||
39 | ifeq ($(DB), mysql) | ||
40 | php bin/console doctrine:database:import data/sql/mysql_base.sql --env=test | ||
41 | endif | ||
42 | ifeq ($(DB), pgsql) | ||
43 | psql -h localhost -d wallabag_test -U travis -f data/sql/pgsql_base.sql | ||
44 | endif | ||
45 | 34 | ||
46 | fixtures: ## Load fixtures into database | 35 | fixtures: ## Load fixtures into database |
47 | php bin/console doctrine:fixtures:load --no-interaction --env=test | 36 | php bin/console doctrine:fixtures:load --no-interaction --env=test |
diff --git a/app/DoctrineMigrations/Version20160401000000.php b/app/DoctrineMigrations/Version20160401000000.php new file mode 100644 index 00000000..a8603abf --- /dev/null +++ b/app/DoctrineMigrations/Version20160401000000.php | |||
@@ -0,0 +1,191 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | |||
8 | /** | ||
9 | * Initial database structure. | ||
10 | */ | ||
11 | class Version20160401000000 extends AbstractMigration | ||
12 | { | ||
13 | /** | ||
14 | * @param Schema $schema | ||
15 | */ | ||
16 | public function up(Schema $schema) | ||
17 | { | ||
18 | if ($this->version->getConfiguration()->getNumberOfExecutedMigrations() > 0) { | ||
19 | $this->version->markMigrated(); | ||
20 | $this->skipIf(true, 'Database already initialized'); | ||
21 | } | ||
22 | |||
23 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
24 | case 'sqlite': | ||
25 | $sql = <<<'SQL' | ||
26 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name)); | ||
27 | CREATE UNIQUE INDEX UNIQ_5D9649505E237E06 ON wallabag_craue_config_setting (name); | ||
28 | CREATE TABLE "wallabag_tagging_rule" (id INTEGER NOT NULL, config_id INTEGER DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags CLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES "wallabag_config" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
29 | CREATE INDEX IDX_2D9B3C5424DB0683 ON "wallabag_tagging_rule" (config_id); | ||
30 | CREATE TABLE "wallabag_tag" (id INTEGER NOT NULL, label CLOB NOT NULL, slug VARCHAR(128) NOT NULL, PRIMARY KEY(id)); | ||
31 | CREATE UNIQUE INDEX UNIQ_4CA58A8C989D9B62 ON "wallabag_tag" (slug); | ||
32 | CREATE TABLE "wallabag_entry" (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, title CLOB DEFAULT NULL, url CLOB DEFAULT NULL, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL, language CLOB DEFAULT NULL, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL, preview_picture CLOB DEFAULT NULL, is_public BOOLEAN DEFAULT '0', PRIMARY KEY(id), CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
33 | CREATE INDEX IDX_F4D18282A76ED395 ON "wallabag_entry" (user_id); | ||
34 | CREATE TABLE wallabag_entry_tag (entry_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, PRIMARY KEY(entry_id, tag_id), CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES "wallabag_tag" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
35 | CREATE INDEX IDX_C9F0DD7CBA364942 ON wallabag_entry_tag (entry_id); | ||
36 | CREATE INDEX IDX_C9F0DD7CBAD26311 ON wallabag_entry_tag (tag_id); | ||
37 | CREATE TABLE "wallabag_config" (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INTEGER NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INTEGER DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
38 | CREATE UNIQUE INDEX UNIQ_87E64C53A76ED395 ON "wallabag_config" (user_id); | ||
39 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
40 | CREATE UNIQUE INDEX UNIQ_20C9FB245F37A13B ON wallabag_oauth2_refresh_tokens (token); | ||
41 | CREATE INDEX IDX_20C9FB2419EB6921 ON wallabag_oauth2_refresh_tokens (client_id); | ||
42 | CREATE INDEX IDX_20C9FB24A76ED395 ON wallabag_oauth2_refresh_tokens (user_id); | ||
43 | CREATE TABLE wallabag_oauth2_access_tokens (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
44 | CREATE UNIQUE INDEX UNIQ_368A42095F37A13B ON wallabag_oauth2_access_tokens (token); | ||
45 | CREATE INDEX IDX_368A420919EB6921 ON wallabag_oauth2_access_tokens (client_id); | ||
46 | CREATE INDEX IDX_368A4209A76ED395 ON wallabag_oauth2_access_tokens (user_id); | ||
47 | CREATE TABLE wallabag_oauth2_auth_codes (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri CLOB NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
48 | CREATE UNIQUE INDEX UNIQ_EE52E3FA5F37A13B ON wallabag_oauth2_auth_codes (token); | ||
49 | CREATE INDEX IDX_EE52E3FA19EB6921 ON wallabag_oauth2_auth_codes (client_id); | ||
50 | CREATE INDEX IDX_EE52E3FAA76ED395 ON wallabag_oauth2_auth_codes (user_id); | ||
51 | CREATE TABLE wallabag_oauth2_clients (id INTEGER NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris CLOB NOT NULL, secret VARCHAR(255) NOT NULL, allowed_grant_types CLOB NOT NULL, PRIMARY KEY(id)); | ||
52 | CREATE TABLE "wallabag_user" (id INTEGER NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, locked BOOLEAN NOT NULL, expired BOOLEAN NOT NULL, expires_at DATETIME DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, roles CLOB NOT NULL, credentials_expired BOOLEAN NOT NULL, credentials_expire_at DATETIME DEFAULT NULL, name CLOB DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INTEGER DEFAULT NULL, twoFactorAuthentication BOOLEAN NOT NULL, trusted CLOB DEFAULT NULL, PRIMARY KEY(id)); | ||
53 | CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON "wallabag_user" (username_canonical); | ||
54 | CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON "wallabag_user" (email_canonical); | ||
55 | CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON "wallabag_user" (confirmation_token); | ||
56 | CREATE TABLE wallabag_annotation (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, entry_id INTEGER DEFAULT NULL, text CLOB NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, quote VARCHAR(255) NOT NULL, ranges CLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
57 | CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); | ||
58 | CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); | ||
59 | SQL | ||
60 | ; | ||
61 | |||
62 | foreach (explode("\n", $sql) as $query) { | ||
63 | $this->addSql($query); | ||
64 | } | ||
65 | |||
66 | break; | ||
67 | case 'mysql': | ||
68 | $sql = <<<'SQL' | ||
69 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_5D9649505E237E06 (name), PRIMARY KEY(name)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
70 | CREATE TABLE `wallabag_entry` (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, title LONGTEXT DEFAULT NULL, url LONGTEXT DEFAULT NULL, is_archived TINYINT(1) NOT NULL, is_starred TINYINT(1) NOT NULL, content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype LONGTEXT DEFAULT NULL, language LONGTEXT DEFAULT NULL, reading_time INT DEFAULT NULL, domain_name LONGTEXT DEFAULT NULL, preview_picture LONGTEXT DEFAULT NULL, is_public TINYINT(1) DEFAULT '0', INDEX IDX_F4D18282A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
71 | CREATE TABLE wallabag_entry_tag (entry_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_C9F0DD7CBA364942 (entry_id), INDEX IDX_C9F0DD7CBAD26311 (tag_id), PRIMARY KEY(entry_id, tag_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
72 | CREATE TABLE `wallabag_config` (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INT NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INT DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, UNIQUE INDEX UNIQ_87E64C53A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
73 | CREATE TABLE `wallabag_tagging_rule` (id INT AUTO_INCREMENT NOT NULL, config_id INT DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags LONGTEXT NOT NULL COMMENT '(DC2Type:simple_array)', INDEX IDX_2D9B3C5424DB0683 (config_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
74 | CREATE TABLE `wallabag_tag` (id INT AUTO_INCREMENT NOT NULL, `label` LONGTEXT NOT NULL, slug VARCHAR(128) NOT NULL, UNIQUE INDEX UNIQ_4CA58A8C989D9B62 (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
75 | CREATE TABLE wallabag_oauth2_clients (id INT AUTO_INCREMENT NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris LONGTEXT NOT NULL COMMENT '(DC2Type:array)', secret VARCHAR(255) NOT NULL, allowed_grant_types LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
76 | CREATE TABLE wallabag_oauth2_access_tokens (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_368A42095F37A13B (token), INDEX IDX_368A420919EB6921 (client_id), INDEX IDX_368A4209A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
77 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_20C9FB245F37A13B (token), INDEX IDX_20C9FB2419EB6921 (client_id), INDEX IDX_20C9FB24A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
78 | CREATE TABLE wallabag_oauth2_auth_codes (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri LONGTEXT NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_EE52E3FA5F37A13B (token), INDEX IDX_EE52E3FA19EB6921 (client_id), INDEX IDX_EE52E3FAA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
79 | CREATE TABLE `wallabag_user` (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled TINYINT(1) NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, locked TINYINT(1) NOT NULL, expired TINYINT(1) NOT NULL, expires_at DATETIME DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)', credentials_expired TINYINT(1) NOT NULL, credentials_expire_at DATETIME DEFAULT NULL, name LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INT DEFAULT NULL, twoFactorAuthentication TINYINT(1) NOT NULL, trusted LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json_array)', UNIQUE INDEX UNIQ_1D63E7E592FC23A8 (username_canonical), UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF (email_canonical), UNIQUE INDEX UNIQ_1D63E7E5C05FB297 (confirmation_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
80 | CREATE TABLE wallabag_annotation (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, entry_id INT DEFAULT NULL, text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, quote VARCHAR(255) NOT NULL, ranges LONGTEXT NOT NULL COMMENT '(DC2Type:array)', INDEX IDX_A7AED006A76ED395 (user_id), INDEX IDX_A7AED006BA364942 (entry_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
81 | ALTER TABLE `wallabag_entry` ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
82 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES `wallabag_entry` (id); | ||
83 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES `wallabag_tag` (id); | ||
84 | ALTER TABLE `wallabag_config` ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
85 | ALTER TABLE `wallabag_tagging_rule` ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES `wallabag_config` (id); | ||
86 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
87 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
88 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
89 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
90 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
91 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
92 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
93 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES `wallabag_entry` (id); | ||
94 | SQL | ||
95 | ; | ||
96 | foreach (explode("\n", $sql) as $query) { | ||
97 | $this->addSql($query); | ||
98 | } | ||
99 | break; | ||
100 | case 'postgresql': | ||
101 | $sql = <<<'SQL' | ||
102 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name)); | ||
103 | CREATE UNIQUE INDEX UNIQ_5D9649505E237E06 ON wallabag_craue_config_setting (name); | ||
104 | CREATE TABLE "wallabag_entry" (id INT NOT NULL, user_id INT DEFAULT NULL, title TEXT DEFAULT NULL, url TEXT DEFAULT NULL, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, mimetype TEXT DEFAULT NULL, language TEXT DEFAULT NULL, reading_time INT DEFAULT NULL, domain_name TEXT DEFAULT NULL, preview_picture TEXT DEFAULT NULL, is_public BOOLEAN DEFAULT 'false', PRIMARY KEY(id)); | ||
105 | CREATE INDEX IDX_F4D18282A76ED395 ON "wallabag_entry" (user_id); | ||
106 | CREATE TABLE wallabag_entry_tag (entry_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(entry_id, tag_id)); | ||
107 | CREATE INDEX IDX_C9F0DD7CBA364942 ON wallabag_entry_tag (entry_id); | ||
108 | CREATE INDEX IDX_C9F0DD7CBAD26311 ON wallabag_entry_tag (tag_id); | ||
109 | CREATE TABLE "wallabag_config" (id INT NOT NULL, user_id INT DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INT NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INT DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, PRIMARY KEY(id)); | ||
110 | CREATE UNIQUE INDEX UNIQ_87E64C53A76ED395 ON "wallabag_config" (user_id); | ||
111 | CREATE TABLE "wallabag_tagging_rule" (id INT NOT NULL, config_id INT DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags TEXT NOT NULL, PRIMARY KEY(id)); | ||
112 | CREATE INDEX IDX_2D9B3C5424DB0683 ON "wallabag_tagging_rule" (config_id); | ||
113 | COMMENT ON COLUMN "wallabag_tagging_rule".tags IS '(DC2Type:simple_array)'; | ||
114 | CREATE TABLE "wallabag_tag" (id INT NOT NULL, label TEXT NOT NULL, slug VARCHAR(128) NOT NULL, PRIMARY KEY(id)); | ||
115 | CREATE UNIQUE INDEX UNIQ_4CA58A8C989D9B62 ON "wallabag_tag" (slug); | ||
116 | CREATE TABLE wallabag_oauth2_clients (id INT NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris TEXT NOT NULL, secret VARCHAR(255) NOT NULL, allowed_grant_types TEXT NOT NULL, PRIMARY KEY(id)); | ||
117 | COMMENT ON COLUMN wallabag_oauth2_clients.redirect_uris IS '(DC2Type:array)'; | ||
118 | COMMENT ON COLUMN wallabag_oauth2_clients.allowed_grant_types IS '(DC2Type:array)'; | ||
119 | CREATE TABLE wallabag_oauth2_access_tokens (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
120 | CREATE UNIQUE INDEX UNIQ_368A42095F37A13B ON wallabag_oauth2_access_tokens (token); | ||
121 | CREATE INDEX IDX_368A420919EB6921 ON wallabag_oauth2_access_tokens (client_id); | ||
122 | CREATE INDEX IDX_368A4209A76ED395 ON wallabag_oauth2_access_tokens (user_id); | ||
123 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
124 | CREATE UNIQUE INDEX UNIQ_20C9FB245F37A13B ON wallabag_oauth2_refresh_tokens (token); | ||
125 | CREATE INDEX IDX_20C9FB2419EB6921 ON wallabag_oauth2_refresh_tokens (client_id); | ||
126 | CREATE INDEX IDX_20C9FB24A76ED395 ON wallabag_oauth2_refresh_tokens (user_id); | ||
127 | CREATE TABLE wallabag_oauth2_auth_codes (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri TEXT NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
128 | CREATE UNIQUE INDEX UNIQ_EE52E3FA5F37A13B ON wallabag_oauth2_auth_codes (token); | ||
129 | CREATE INDEX IDX_EE52E3FA19EB6921 ON wallabag_oauth2_auth_codes (client_id); | ||
130 | CREATE INDEX IDX_EE52E3FAA76ED395 ON wallabag_oauth2_auth_codes (user_id); | ||
131 | CREATE TABLE "wallabag_user" (id INT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, locked BOOLEAN NOT NULL, expired BOOLEAN NOT NULL, expires_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, roles TEXT NOT NULL, credentials_expired BOOLEAN NOT NULL, credentials_expire_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, name TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, authCode INT DEFAULT NULL, twoFactorAuthentication BOOLEAN NOT NULL, trusted TEXT DEFAULT NULL, PRIMARY KEY(id)); | ||
132 | CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON "wallabag_user" (username_canonical); | ||
133 | CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON "wallabag_user" (email_canonical); | ||
134 | CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON "wallabag_user" (confirmation_token); | ||
135 | COMMENT ON COLUMN "wallabag_user".roles IS '(DC2Type:array)'; | ||
136 | COMMENT ON COLUMN "wallabag_user".trusted IS '(DC2Type:json_array)'; | ||
137 | CREATE TABLE wallabag_annotation (id INT NOT NULL, user_id INT DEFAULT NULL, entry_id INT DEFAULT NULL, text TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, quote VARCHAR(255) NOT NULL, ranges TEXT NOT NULL, PRIMARY KEY(id)); | ||
138 | CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); | ||
139 | CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); | ||
140 | COMMENT ON COLUMN wallabag_annotation.ranges IS '(DC2Type:array)'; | ||
141 | CREATE SEQUENCE "entry_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
142 | CREATE SEQUENCE "config_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
143 | CREATE SEQUENCE "tagging_rule_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
144 | CREATE SEQUENCE "tag_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
145 | CREATE SEQUENCE oauth2_clients_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
146 | CREATE SEQUENCE oauth2_access_tokens_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
147 | CREATE SEQUENCE oauth2_refresh_tokens_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
148 | CREATE SEQUENCE oauth2_auth_codes_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
149 | CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
150 | CREATE SEQUENCE annotation_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
151 | ALTER TABLE "wallabag_entry" ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
152 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
153 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES "wallabag_tag" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
154 | ALTER TABLE "wallabag_config" ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
155 | ALTER TABLE "wallabag_tagging_rule" ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES "wallabag_config" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
156 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
157 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
158 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
159 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
160 | 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; | ||
162 | 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; | ||
164 | SQL | ||
165 | ; | ||
166 | foreach (explode("\n", $sql) as $query) { | ||
167 | $this->addSql($query); | ||
168 | } | ||
169 | break; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * @param Schema $schema | ||
175 | */ | ||
176 | public function down(Schema $schema) | ||
177 | { | ||
178 | $this->addSql('DROP TABLE wallabag_craue_config_setting'); | ||
179 | $this->addSql('DROP TABLE "wallabag_tagging_rule"'); | ||
180 | $this->addSql('DROP TABLE "wallabag_config"'); | ||
181 | $this->addSql('DROP TABLE "wallabag_entry"'); | ||
182 | $this->addSql('DROP TABLE wallabag_entry_tag'); | ||
183 | $this->addSql('DROP TABLE "wallabag_tag"'); | ||
184 | $this->addSql('DROP TABLE wallabag_oauth2_refresh_tokens'); | ||
185 | $this->addSql('DROP TABLE wallabag_oauth2_access_tokens'); | ||
186 | $this->addSql('DROP TABLE wallabag_oauth2_clients'); | ||
187 | $this->addSql('DROP TABLE wallabag_oauth2_auth_codes'); | ||
188 | $this->addSql('DROP TABLE "wallabag_user"'); | ||
189 | $this->addSql('DROP TABLE wallabag_annotation'); | ||
190 | } | ||
191 | } | ||
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php index 677f30c3..d28f3a71 100644 --- a/app/DoctrineMigrations/Version20160812120952.php +++ b/app/DoctrineMigrations/Version20160812120952.php | |||
@@ -30,7 +30,20 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI | |||
30 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); | 30 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); |
31 | $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.'); | 31 | $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.'); |
32 | 32 | ||
33 | $clientsTable->addColumn('name', 'blob'); | 33 | if ('sqlite' === $this->connection->getDatabasePlatform()->getName()) { |
34 | // Can't use $clientsTable->addColumn('name', 'blob'); | ||
35 | // because of the error: | ||
36 | // SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL | ||
37 | $databaseTablePrefix = $this->container->getParameter('database_table_prefix'); | ||
38 | $this->addSql('CREATE TEMPORARY TABLE __temp__' . $databaseTablePrefix . 'oauth2_clients AS SELECT id, random_id, redirect_uris, secret, allowed_grant_types FROM ' . $databaseTablePrefix . 'oauth2_clients'); | ||
39 | $this->addSql('DROP TABLE ' . $databaseTablePrefix . 'oauth2_clients'); | ||
40 | $this->addSql('CREATE TABLE ' . $databaseTablePrefix . 'oauth2_clients (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, random_id VARCHAR(255) NOT NULL COLLATE BINARY, secret VARCHAR(255) NOT NULL COLLATE BINARY, redirect_uris CLOB NOT NULL, allowed_grant_types CLOB NOT NULL, name CLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_635D765EA76ED395 FOREIGN KEY (user_id) REFERENCES "' . $databaseTablePrefix . 'user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); | ||
41 | $this->addSql('INSERT INTO ' . $databaseTablePrefix . 'oauth2_clients (id, random_id, redirect_uris, secret, allowed_grant_types) SELECT id, random_id, redirect_uris, secret, allowed_grant_types FROM __temp__' . $databaseTablePrefix . 'oauth2_clients'); | ||
42 | $this->addSql('DROP TABLE __temp__' . $databaseTablePrefix . 'oauth2_clients'); | ||
43 | $this->addSql('CREATE INDEX IDX_635D765EA76ED395 ON ' . $databaseTablePrefix . 'oauth2_clients (user_id)'); | ||
44 | } else { | ||
45 | $clientsTable->addColumn('name', 'blob'); | ||
46 | } | ||
34 | } | 47 | } |
35 | 48 | ||
36 | /** | 49 | /** |
@@ -39,7 +52,18 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI | |||
39 | public function down(Schema $schema) | 52 | public function down(Schema $schema) |
40 | { | 53 | { |
41 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); | 54 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); |
42 | $clientsTable->dropColumn('name'); | 55 | |
56 | if ('sqlite' === $this->connection->getDatabasePlatform()->getName()) { | ||
57 | $databaseTablePrefix = $this->container->getParameter('database_table_prefix'); | ||
58 | $this->addSql('DROP INDEX IDX_635D765EA76ED395'); | ||
59 | $this->addSql('CREATE TEMPORARY TABLE __temp__' . $databaseTablePrefix . 'oauth2_clients AS SELECT id, random_id, redirect_uris, secret, allowed_grant_types FROM ' . $databaseTablePrefix . 'oauth2_clients'); | ||
60 | $this->addSql('DROP TABLE ' . $databaseTablePrefix . 'oauth2_clients'); | ||
61 | $this->addSql('CREATE TABLE ' . $databaseTablePrefix . 'oauth2_clients (id INTEGER NOT NULL, random_id VARCHAR(255) NOT NULL, secret VARCHAR(255) NOT NULL, redirect_uris CLOB NOT NULL COLLATE BINARY, allowed_grant_types CLOB NOT NULL COLLATE BINARY, PRIMARY KEY(id))'); | ||
62 | $this->addSql('INSERT INTO ' . $databaseTablePrefix . 'oauth2_clients (id, random_id, redirect_uris, secret, allowed_grant_types) SELECT id, random_id, redirect_uris, secret, allowed_grant_types FROM __temp__' . $databaseTablePrefix . 'oauth2_clients'); | ||
63 | $this->addSql('DROP TABLE __temp__' . $databaseTablePrefix . 'oauth2_clients'); | ||
64 | } else { | ||
65 | $clientsTable->dropColumn('name'); | ||
66 | } | ||
43 | } | 67 | } |
44 | 68 | ||
45 | private function getTable($tableName) | 69 | private function getTable($tableName) |
diff --git a/app/DoctrineMigrations/Version20170824113337.php b/app/DoctrineMigrations/Version20170824113337.php index 7393d683..e54a9bcf 100644 --- a/app/DoctrineMigrations/Version20170824113337.php +++ b/app/DoctrineMigrations/Version20170824113337.php | |||
@@ -41,7 +41,12 @@ class Version20170824113337 extends AbstractMigration implements ContainerAwareI | |||
41 | $entryTable = $schema->getTable($this->getTable('entry')); | 41 | $entryTable = $schema->getTable($this->getTable('entry')); |
42 | $this->skipIf(!$entryTable->hasColumn('starred_at'), 'Unable to add starred_at colum'); | 42 | $this->skipIf(!$entryTable->hasColumn('starred_at'), 'Unable to add starred_at colum'); |
43 | 43 | ||
44 | $this->connection->executeQuery('UPDATE ' . $this->getTable('entry') . ' SET starred_at = updated_at WHERE is_starred = true'); | 44 | $this->connection->executeQuery( |
45 | 'UPDATE ' . $this->getTable('entry') . ' SET starred_at = updated_at WHERE is_starred = :is_starred', | ||
46 | [ | ||
47 | 'is_starred' => true, | ||
48 | ] | ||
49 | ); | ||
45 | } | 50 | } |
46 | 51 | ||
47 | /** | 52 | /** |
diff --git a/data/sql/mysql_base.sql b/data/sql/mysql_base.sql deleted file mode 100644 index 13fa6302..00000000 --- a/data/sql/mysql_base.sql +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_5D9649505E237E06 (name), PRIMARY KEY(name)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
2 | CREATE TABLE `wallabag_entry` (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, title LONGTEXT DEFAULT NULL, url LONGTEXT DEFAULT NULL, is_archived TINYINT(1) NOT NULL, is_starred TINYINT(1) NOT NULL, content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype LONGTEXT DEFAULT NULL, language LONGTEXT DEFAULT NULL, reading_time INT DEFAULT NULL, domain_name LONGTEXT DEFAULT NULL, preview_picture LONGTEXT DEFAULT NULL, is_public TINYINT(1) DEFAULT '0', INDEX IDX_F4D18282A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
3 | CREATE TABLE wallabag_entry_tag (entry_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_C9F0DD7CBA364942 (entry_id), INDEX IDX_C9F0DD7CBAD26311 (tag_id), PRIMARY KEY(entry_id, tag_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
4 | CREATE TABLE `wallabag_config` (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INT NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INT DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, UNIQUE INDEX UNIQ_87E64C53A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
5 | CREATE TABLE `wallabag_tagging_rule` (id INT AUTO_INCREMENT NOT NULL, config_id INT DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags LONGTEXT NOT NULL COMMENT '(DC2Type:simple_array)', INDEX IDX_2D9B3C5424DB0683 (config_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
6 | CREATE TABLE `wallabag_tag` (id INT AUTO_INCREMENT NOT NULL, `label` LONGTEXT NOT NULL, slug VARCHAR(128) NOT NULL, UNIQUE INDEX UNIQ_4CA58A8C989D9B62 (slug), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
7 | CREATE TABLE wallabag_oauth2_clients (id INT AUTO_INCREMENT NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris LONGTEXT NOT NULL COMMENT '(DC2Type:array)', secret VARCHAR(255) NOT NULL, allowed_grant_types LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
8 | CREATE TABLE wallabag_oauth2_access_tokens (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_368A42095F37A13B (token), INDEX IDX_368A420919EB6921 (client_id), INDEX IDX_368A4209A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
9 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_20C9FB245F37A13B (token), INDEX IDX_20C9FB2419EB6921 (client_id), INDEX IDX_20C9FB24A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
10 | CREATE TABLE wallabag_oauth2_auth_codes (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri LONGTEXT NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_EE52E3FA5F37A13B (token), INDEX IDX_EE52E3FA19EB6921 (client_id), INDEX IDX_EE52E3FAA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
11 | CREATE TABLE `wallabag_user` (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled TINYINT(1) NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, locked TINYINT(1) NOT NULL, expired TINYINT(1) NOT NULL, expires_at DATETIME DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)', credentials_expired TINYINT(1) NOT NULL, credentials_expire_at DATETIME DEFAULT NULL, name LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INT DEFAULT NULL, twoFactorAuthentication TINYINT(1) NOT NULL, trusted LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json_array)', UNIQUE INDEX UNIQ_1D63E7E592FC23A8 (username_canonical), UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF (email_canonical), UNIQUE INDEX UNIQ_1D63E7E5C05FB297 (confirmation_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
12 | CREATE TABLE wallabag_annotation (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, entry_id INT DEFAULT NULL, text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, quote VARCHAR(255) NOT NULL, ranges LONGTEXT NOT NULL COMMENT '(DC2Type:array)', INDEX IDX_A7AED006A76ED395 (user_id), INDEX IDX_A7AED006BA364942 (entry_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; | ||
13 | ALTER TABLE `wallabag_entry` ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
14 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES `wallabag_entry` (id); | ||
15 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES `wallabag_tag` (id); | ||
16 | ALTER TABLE `wallabag_config` ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
17 | ALTER TABLE `wallabag_tagging_rule` ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES `wallabag_config` (id); | ||
18 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
19 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
20 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
21 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
22 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id); | ||
23 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
24 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES `wallabag_user` (id); | ||
25 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES `wallabag_entry` (id); | ||
diff --git a/data/sql/pgsql_base.sql b/data/sql/pgsql_base.sql deleted file mode 100644 index 6688fe83..00000000 --- a/data/sql/pgsql_base.sql +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name)); | ||
2 | CREATE UNIQUE INDEX UNIQ_5D9649505E237E06 ON wallabag_craue_config_setting (name); | ||
3 | CREATE TABLE "wallabag_entry" (id INT NOT NULL, user_id INT DEFAULT NULL, title TEXT DEFAULT NULL, url TEXT DEFAULT NULL, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, mimetype TEXT DEFAULT NULL, language TEXT DEFAULT NULL, reading_time INT DEFAULT NULL, domain_name TEXT DEFAULT NULL, preview_picture TEXT DEFAULT NULL, is_public BOOLEAN DEFAULT 'false', PRIMARY KEY(id)); | ||
4 | CREATE INDEX IDX_F4D18282A76ED395 ON "wallabag_entry" (user_id); | ||
5 | CREATE TABLE wallabag_entry_tag (entry_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY(entry_id, tag_id)); | ||
6 | CREATE INDEX IDX_C9F0DD7CBA364942 ON wallabag_entry_tag (entry_id); | ||
7 | CREATE INDEX IDX_C9F0DD7CBAD26311 ON wallabag_entry_tag (tag_id); | ||
8 | CREATE TABLE "wallabag_config" (id INT NOT NULL, user_id INT DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INT NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INT DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, PRIMARY KEY(id)); | ||
9 | CREATE UNIQUE INDEX UNIQ_87E64C53A76ED395 ON "wallabag_config" (user_id); | ||
10 | CREATE TABLE "wallabag_tagging_rule" (id INT NOT NULL, config_id INT DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags TEXT NOT NULL, PRIMARY KEY(id)); | ||
11 | CREATE INDEX IDX_2D9B3C5424DB0683 ON "wallabag_tagging_rule" (config_id); | ||
12 | COMMENT ON COLUMN "wallabag_tagging_rule".tags IS '(DC2Type:simple_array)'; | ||
13 | CREATE TABLE "wallabag_tag" (id INT NOT NULL, label TEXT NOT NULL, slug VARCHAR(128) NOT NULL, PRIMARY KEY(id)); | ||
14 | CREATE UNIQUE INDEX UNIQ_4CA58A8C989D9B62 ON "wallabag_tag" (slug); | ||
15 | CREATE TABLE wallabag_oauth2_clients (id INT NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris TEXT NOT NULL, secret VARCHAR(255) NOT NULL, allowed_grant_types TEXT NOT NULL, PRIMARY KEY(id)); | ||
16 | COMMENT ON COLUMN wallabag_oauth2_clients.redirect_uris IS '(DC2Type:array)'; | ||
17 | COMMENT ON COLUMN wallabag_oauth2_clients.allowed_grant_types IS '(DC2Type:array)'; | ||
18 | CREATE TABLE wallabag_oauth2_access_tokens (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
19 | CREATE UNIQUE INDEX UNIQ_368A42095F37A13B ON wallabag_oauth2_access_tokens (token); | ||
20 | CREATE INDEX IDX_368A420919EB6921 ON wallabag_oauth2_access_tokens (client_id); | ||
21 | CREATE INDEX IDX_368A4209A76ED395 ON wallabag_oauth2_access_tokens (user_id); | ||
22 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
23 | CREATE UNIQUE INDEX UNIQ_20C9FB245F37A13B ON wallabag_oauth2_refresh_tokens (token); | ||
24 | CREATE INDEX IDX_20C9FB2419EB6921 ON wallabag_oauth2_refresh_tokens (client_id); | ||
25 | CREATE INDEX IDX_20C9FB24A76ED395 ON wallabag_oauth2_refresh_tokens (user_id); | ||
26 | CREATE TABLE wallabag_oauth2_auth_codes (id INT NOT NULL, client_id INT NOT NULL, user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri TEXT NOT NULL, expires_at INT DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)); | ||
27 | CREATE UNIQUE INDEX UNIQ_EE52E3FA5F37A13B ON wallabag_oauth2_auth_codes (token); | ||
28 | CREATE INDEX IDX_EE52E3FA19EB6921 ON wallabag_oauth2_auth_codes (client_id); | ||
29 | CREATE INDEX IDX_EE52E3FAA76ED395 ON wallabag_oauth2_auth_codes (user_id); | ||
30 | CREATE TABLE "wallabag_user" (id INT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, locked BOOLEAN NOT NULL, expired BOOLEAN NOT NULL, expires_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, roles TEXT NOT NULL, credentials_expired BOOLEAN NOT NULL, credentials_expire_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, name TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, authCode INT DEFAULT NULL, twoFactorAuthentication BOOLEAN NOT NULL, trusted TEXT DEFAULT NULL, PRIMARY KEY(id)); | ||
31 | CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON "wallabag_user" (username_canonical); | ||
32 | CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON "wallabag_user" (email_canonical); | ||
33 | CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON "wallabag_user" (confirmation_token); | ||
34 | COMMENT ON COLUMN "wallabag_user".roles IS '(DC2Type:array)'; | ||
35 | COMMENT ON COLUMN "wallabag_user".trusted IS '(DC2Type:json_array)'; | ||
36 | CREATE TABLE wallabag_annotation (id INT NOT NULL, user_id INT DEFAULT NULL, entry_id INT DEFAULT NULL, text TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, quote VARCHAR(255) NOT NULL, ranges TEXT NOT NULL, PRIMARY KEY(id)); | ||
37 | CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); | ||
38 | CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); | ||
39 | COMMENT ON COLUMN wallabag_annotation.ranges IS '(DC2Type:array)'; | ||
40 | CREATE SEQUENCE "entry_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
41 | CREATE SEQUENCE "config_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
42 | CREATE SEQUENCE "tagging_rule_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
43 | CREATE SEQUENCE "tag_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
44 | CREATE SEQUENCE oauth2_clients_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
45 | CREATE SEQUENCE oauth2_access_tokens_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
46 | CREATE SEQUENCE oauth2_refresh_tokens_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
47 | CREATE SEQUENCE oauth2_auth_codes_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
48 | CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1; | ||
49 | CREATE SEQUENCE annotation_id_seq INCREMENT BY 1 MINVALUE 1 START 1; | ||
50 | ALTER TABLE "wallabag_entry" ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
51 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
52 | ALTER TABLE wallabag_entry_tag ADD CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES "wallabag_tag" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
53 | ALTER TABLE "wallabag_config" ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
54 | ALTER TABLE "wallabag_tagging_rule" ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES "wallabag_config" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
55 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
56 | ALTER TABLE wallabag_oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
57 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
58 | ALTER TABLE wallabag_oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
59 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
60 | ALTER TABLE wallabag_oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
61 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
62 | ALTER TABLE wallabag_annotation ADD CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE; | ||
diff --git a/data/sql/sqlite_base.sql b/data/sql/sqlite_base.sql deleted file mode 100644 index d2780d96..00000000 --- a/data/sql/sqlite_base.sql +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | CREATE TABLE wallabag_craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, PRIMARY KEY(name)); | ||
2 | CREATE UNIQUE INDEX UNIQ_5D9649505E237E06 ON wallabag_craue_config_setting (name); | ||
3 | CREATE TABLE "wallabag_tagging_rule" (id INTEGER NOT NULL, config_id INTEGER DEFAULT NULL, rule VARCHAR(255) NOT NULL, tags CLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES "wallabag_config" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
4 | CREATE INDEX IDX_2D9B3C5424DB0683 ON "wallabag_tagging_rule" (config_id); | ||
5 | CREATE TABLE "wallabag_tag" (id INTEGER NOT NULL, label CLOB NOT NULL, slug VARCHAR(128) NOT NULL, PRIMARY KEY(id)); | ||
6 | CREATE UNIQUE INDEX UNIQ_4CA58A8C989D9B62 ON "wallabag_tag" (slug); | ||
7 | CREATE TABLE "wallabag_entry" (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, title CLOB DEFAULT NULL, url CLOB DEFAULT NULL, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL, language CLOB DEFAULT NULL, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL, preview_picture CLOB DEFAULT NULL, is_public BOOLEAN DEFAULT '0', PRIMARY KEY(id), CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
8 | CREATE INDEX IDX_F4D18282A76ED395 ON "wallabag_entry" (user_id); | ||
9 | CREATE TABLE wallabag_entry_tag (entry_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, PRIMARY KEY(entry_id, tag_id), CONSTRAINT FK_C9F0DD7CBA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_C9F0DD7CBAD26311 FOREIGN KEY (tag_id) REFERENCES "wallabag_tag" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
10 | CREATE INDEX IDX_C9F0DD7CBA364942 ON wallabag_entry_tag (entry_id); | ||
11 | CREATE INDEX IDX_C9F0DD7CBAD26311 ON wallabag_entry_tag (tag_id); | ||
12 | CREATE TABLE "wallabag_config" (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, theme VARCHAR(255) NOT NULL, items_per_page INTEGER NOT NULL, language VARCHAR(255) NOT NULL, rss_token VARCHAR(255) DEFAULT NULL, rss_limit INTEGER DEFAULT NULL, reading_speed DOUBLE PRECISION DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
13 | CREATE UNIQUE INDEX UNIQ_87E64C53A76ED395 ON "wallabag_config" (user_id); | ||
14 | CREATE TABLE wallabag_oauth2_refresh_tokens (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
15 | CREATE UNIQUE INDEX UNIQ_20C9FB245F37A13B ON wallabag_oauth2_refresh_tokens (token); | ||
16 | CREATE INDEX IDX_20C9FB2419EB6921 ON wallabag_oauth2_refresh_tokens (client_id); | ||
17 | CREATE INDEX IDX_20C9FB24A76ED395 ON wallabag_oauth2_refresh_tokens (user_id); | ||
18 | CREATE TABLE wallabag_oauth2_access_tokens (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
19 | CREATE UNIQUE INDEX UNIQ_368A42095F37A13B ON wallabag_oauth2_access_tokens (token); | ||
20 | CREATE INDEX IDX_368A420919EB6921 ON wallabag_oauth2_access_tokens (client_id); | ||
21 | CREATE INDEX IDX_368A4209A76ED395 ON wallabag_oauth2_access_tokens (user_id); | ||
22 | CREATE TABLE wallabag_oauth2_auth_codes (id INTEGER NOT NULL, client_id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, token VARCHAR(255) NOT NULL, redirect_uri CLOB NOT NULL, expires_at INTEGER DEFAULT NULL, scope VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id), CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES wallabag_oauth2_clients (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
23 | CREATE UNIQUE INDEX UNIQ_EE52E3FA5F37A13B ON wallabag_oauth2_auth_codes (token); | ||
24 | CREATE INDEX IDX_EE52E3FA19EB6921 ON wallabag_oauth2_auth_codes (client_id); | ||
25 | CREATE INDEX IDX_EE52E3FAA76ED395 ON wallabag_oauth2_auth_codes (user_id); | ||
26 | CREATE TABLE wallabag_oauth2_clients (id INTEGER NOT NULL, random_id VARCHAR(255) NOT NULL, redirect_uris CLOB NOT NULL, secret VARCHAR(255) NOT NULL, allowed_grant_types CLOB NOT NULL, PRIMARY KEY(id)); | ||
27 | CREATE TABLE "wallabag_user" (id INTEGER NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, locked BOOLEAN NOT NULL, expired BOOLEAN NOT NULL, expires_at DATETIME DEFAULT NULL, confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, roles CLOB NOT NULL, credentials_expired BOOLEAN NOT NULL, credentials_expire_at DATETIME DEFAULT NULL, name CLOB DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INTEGER DEFAULT NULL, twoFactorAuthentication BOOLEAN NOT NULL, trusted CLOB DEFAULT NULL, PRIMARY KEY(id)); | ||
28 | CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON "wallabag_user" (username_canonical); | ||
29 | CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON "wallabag_user" (email_canonical); | ||
30 | CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON "wallabag_user" (confirmation_token); | ||
31 | CREATE TABLE wallabag_annotation (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, entry_id INTEGER DEFAULT NULL, text CLOB NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, quote VARCHAR(255) NOT NULL, ranges CLOB NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES "wallabag_user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES "wallabag_entry" (id) NOT DEFERRABLE INITIALLY IMMEDIATE); | ||
32 | CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); | ||
33 | CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); | ||
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 877dbfa2..dec2bf9c 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -61,7 +61,6 @@ class InstallCommand extends ContainerAwareCommand | |||
61 | ->setupDatabase() | 61 | ->setupDatabase() |
62 | ->setupAdmin() | 62 | ->setupAdmin() |
63 | ->setupConfig() | 63 | ->setupConfig() |
64 | ->runMigrations() | ||
65 | ; | 64 | ; |
66 | 65 | ||
67 | $this->io->success('Wallabag has been successfully installed.'); | 66 | $this->io->success('Wallabag has been successfully installed.'); |
@@ -70,7 +69,7 @@ class InstallCommand extends ContainerAwareCommand | |||
70 | 69 | ||
71 | protected function checkRequirements() | 70 | protected function checkRequirements() |
72 | { | 71 | { |
73 | $this->io->section('Step 1 of 5: Checking system requirements.'); | 72 | $this->io->section('Step 1 of 4: Checking system requirements.'); |
74 | 73 | ||
75 | $doctrineManager = $this->getContainer()->get('doctrine')->getManager(); | 74 | $doctrineManager = $this->getContainer()->get('doctrine')->getManager(); |
76 | 75 | ||
@@ -169,7 +168,7 @@ class InstallCommand extends ContainerAwareCommand | |||
169 | 168 | ||
170 | protected function setupDatabase() | 169 | protected function setupDatabase() |
171 | { | 170 | { |
172 | $this->io->section('Step 2 of 5: Setting up database.'); | 171 | $this->io->section('Step 2 of 4: Setting up database.'); |
173 | 172 | ||
174 | // user want to reset everything? Don't care about what is already here | 173 | // user want to reset everything? Don't care about what is already here |
175 | if (true === $this->defaultInput->getOption('reset')) { | 174 | if (true === $this->defaultInput->getOption('reset')) { |
@@ -178,7 +177,7 @@ class InstallCommand extends ContainerAwareCommand | |||
178 | $this | 177 | $this |
179 | ->runCommand('doctrine:database:drop', ['--force' => true]) | 178 | ->runCommand('doctrine:database:drop', ['--force' => true]) |
180 | ->runCommand('doctrine:database:create') | 179 | ->runCommand('doctrine:database:create') |
181 | ->runCommand('doctrine:schema:create') | 180 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]) |
182 | ->runCommand('cache:clear') | 181 | ->runCommand('cache:clear') |
183 | ; | 182 | ; |
184 | 183 | ||
@@ -192,7 +191,7 @@ class InstallCommand extends ContainerAwareCommand | |||
192 | 191 | ||
193 | $this | 192 | $this |
194 | ->runCommand('doctrine:database:create') | 193 | ->runCommand('doctrine:database:create') |
195 | ->runCommand('doctrine:schema:create') | 194 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]) |
196 | ->runCommand('cache:clear') | 195 | ->runCommand('cache:clear') |
197 | ; | 196 | ; |
198 | 197 | ||
@@ -207,7 +206,7 @@ class InstallCommand extends ContainerAwareCommand | |||
207 | $this | 206 | $this |
208 | ->runCommand('doctrine:database:drop', ['--force' => true]) | 207 | ->runCommand('doctrine:database:drop', ['--force' => true]) |
209 | ->runCommand('doctrine:database:create') | 208 | ->runCommand('doctrine:database:create') |
210 | ->runCommand('doctrine:schema:create') | 209 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]) |
211 | ; | 210 | ; |
212 | } elseif ($this->isSchemaPresent()) { | 211 | } elseif ($this->isSchemaPresent()) { |
213 | if ($this->io->confirm('Seems like your database contains schema. Do you want to reset it?', false)) { | 212 | if ($this->io->confirm('Seems like your database contains schema. Do you want to reset it?', false)) { |
@@ -215,14 +214,14 @@ class InstallCommand extends ContainerAwareCommand | |||
215 | 214 | ||
216 | $this | 215 | $this |
217 | ->runCommand('doctrine:schema:drop', ['--force' => true]) | 216 | ->runCommand('doctrine:schema:drop', ['--force' => true]) |
218 | ->runCommand('doctrine:schema:create') | 217 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]) |
219 | ; | 218 | ; |
220 | } | 219 | } |
221 | } else { | 220 | } else { |
222 | $this->io->text('Creating schema...'); | 221 | $this->io->text('Creating schema...'); |
223 | 222 | ||
224 | $this | 223 | $this |
225 | ->runCommand('doctrine:schema:create') | 224 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]) |
226 | ; | 225 | ; |
227 | } | 226 | } |
228 | 227 | ||
@@ -237,7 +236,7 @@ class InstallCommand extends ContainerAwareCommand | |||
237 | 236 | ||
238 | protected function setupAdmin() | 237 | protected function setupAdmin() |
239 | { | 238 | { |
240 | $this->io->section('Step 3 of 5: Administration setup.'); | 239 | $this->io->section('Step 3 of 4: Administration setup.'); |
241 | 240 | ||
242 | if (!$this->io->confirm('Would you like to create a new admin user (recommended)?', true)) { | 241 | if (!$this->io->confirm('Would you like to create a new admin user (recommended)?', true)) { |
243 | return $this; | 242 | return $this; |
@@ -272,7 +271,7 @@ class InstallCommand extends ContainerAwareCommand | |||
272 | 271 | ||
273 | protected function setupConfig() | 272 | protected function setupConfig() |
274 | { | 273 | { |
275 | $this->io->section('Step 4 of 5: Config setup.'); | 274 | $this->io->section('Step 4 of 4: Config setup.'); |
276 | $em = $this->getContainer()->get('doctrine.orm.entity_manager'); | 275 | $em = $this->getContainer()->get('doctrine.orm.entity_manager'); |
277 | 276 | ||
278 | // cleanup before insert new stuff | 277 | // cleanup before insert new stuff |
@@ -293,18 +292,6 @@ class InstallCommand extends ContainerAwareCommand | |||
293 | return $this; | 292 | return $this; |
294 | } | 293 | } |
295 | 294 | ||
296 | protected function runMigrations() | ||
297 | { | ||
298 | $this->io->section('Step 5 of 5: Run migrations.'); | ||
299 | |||
300 | $this | ||
301 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]); | ||
302 | |||
303 | $this->io->text('<info>Migrations successfully executed.</info>'); | ||
304 | |||
305 | return $this; | ||
306 | } | ||
307 | |||
308 | /** | 295 | /** |
309 | * Run a command. | 296 | * Run a command. |
310 | * | 297 | * |
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index f684a206..bd351b18 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | |||
@@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\Command; | |||
5 | use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; | 5 | use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; |
6 | use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; | 6 | use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; |
7 | use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; | 7 | use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; |
8 | use Doctrine\Bundle\MigrationsBundle\Command\MigrationsMigrateDoctrineCommand; | ||
8 | use Doctrine\DBAL\Platforms\PostgreSqlPlatform; | 9 | use Doctrine\DBAL\Platforms\PostgreSqlPlatform; |
9 | use Doctrine\DBAL\Platforms\SqlitePlatform; | 10 | use Doctrine\DBAL\Platforms\SqlitePlatform; |
10 | use Symfony\Bundle\FrameworkBundle\Console\Application; | 11 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
@@ -98,7 +99,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
98 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 99 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
99 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 100 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
100 | $this->assertContains('Config setup.', $tester->getDisplay()); | 101 | $this->assertContains('Config setup.', $tester->getDisplay()); |
101 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | public function testRunInstallCommandWithReset() | 104 | public function testRunInstallCommandWithReset() |
@@ -125,7 +125,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
126 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 126 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
127 | $this->assertContains('Config setup.', $tester->getDisplay()); | 127 | $this->assertContains('Config setup.', $tester->getDisplay()); |
128 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
129 | 128 | ||
130 | // we force to reset everything | 129 | // we force to reset everything |
131 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 130 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -171,7 +170,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
171 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 170 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
172 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 171 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
173 | $this->assertContains('Config setup.', $tester->getDisplay()); | 172 | $this->assertContains('Config setup.', $tester->getDisplay()); |
174 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
175 | 173 | ||
176 | // the current database doesn't already exist | 174 | // the current database doesn't already exist |
177 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); | 175 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -198,7 +196,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
198 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 196 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
199 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 197 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
200 | $this->assertContains('Config setup.', $tester->getDisplay()); | 198 | $this->assertContains('Config setup.', $tester->getDisplay()); |
201 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
202 | 199 | ||
203 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); | 200 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); |
204 | } | 201 | } |
@@ -209,6 +206,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
209 | $application->add(new InstallCommand()); | 206 | $application->add(new InstallCommand()); |
210 | $application->add(new DropDatabaseDoctrineCommand()); | 207 | $application->add(new DropDatabaseDoctrineCommand()); |
211 | $application->add(new CreateDatabaseDoctrineCommand()); | 208 | $application->add(new CreateDatabaseDoctrineCommand()); |
209 | $application->add(new MigrationsMigrateDoctrineCommand()); | ||
212 | 210 | ||
213 | // drop database first, so the install command won't ask to reset things | 211 | // drop database first, so the install command won't ask to reset things |
214 | $command = new DropDatabaseDoctrineCommand(); | 212 | $command = new DropDatabaseDoctrineCommand(); |
@@ -242,7 +240,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
242 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 240 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
243 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 241 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
244 | $this->assertContains('Config setup.', $tester->getDisplay()); | 242 | $this->assertContains('Config setup.', $tester->getDisplay()); |
245 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
246 | 243 | ||
247 | $this->assertContains('Creating schema', $tester->getDisplay()); | 244 | $this->assertContains('Creating schema', $tester->getDisplay()); |
248 | } | 245 | } |
@@ -265,6 +262,5 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
265 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 262 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
266 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 263 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
267 | $this->assertContains('Config setup.', $tester->getDisplay()); | 264 | $this->assertContains('Config setup.', $tester->getDisplay()); |
268 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
269 | } | 265 | } |
270 | } | 266 | } |