aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>2013-08-07 15:46:17 +0200
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>2013-08-07 15:46:17 +0200
commit580d60b9416b3445300f37fc0ecc160254ed0676 (patch)
tree13cde22f34e0da3f097badfe4141754be419c746
parent68857cea8c08aab54c632d63f4526d0bb16f80d4 (diff)
downloadwallabag-580d60b9416b3445300f37fc0ecc160254ed0676.tar.gz
wallabag-580d60b9416b3445300f37fc0ecc160254ed0676.tar.zst
wallabag-580d60b9416b3445300f37fc0ecc160254ed0676.zip
file to update from 0.x to 1.x \o/
-rw-r--r--inc/poche/Database.class.php1
-rw-r--r--install/mysql.sql34
-rwxr-xr-xinstall/poche.sqlite.in (renamed from db/poche.sqlite.in)bin294912 -> 294912 bytes
-rw-r--r--install/postgres.sql30
-rw-r--r--install/update_sqlite_from_0_to_1.php64
5 files changed, 129 insertions, 0 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 034b1003..8da7a994 100644
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -29,6 +29,7 @@ class Database {
29 } 29 }
30 30
31 $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 31 $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
32 Tools::logm('storage type ' . STORAGE);
32 } 33 }
33 34
34 private function getHandle() { 35 private function getHandle() {
diff --git a/install/mysql.sql b/install/mysql.sql
new file mode 100644
index 00000000..cb232a84
--- /dev/null
+++ b/install/mysql.sql
@@ -0,0 +1,34 @@
1CREATE TABLE IF NOT EXISTS `config` (
2 `id` int(11) NOT NULL AUTO_INCREMENT,
3 `name` varchar(255) NOT NULL,
4 `value` varchar(255) NOT NULL,
5 PRIMARY KEY (`id`)
6) ENGINE=InnoDB DEFAULT CHARSET=latin1;
7
8CREATE TABLE IF NOT EXISTS `entries` (
9 `id` int(11) NOT NULL AUTO_INCREMENT,
10 `title` varchar(255) NOT NULL,
11 `url` varchar(255) NOT NULL,
12 `is_read` tinyint(1) NOT NULL,
13 `is_fav` tinyint(1) NOT NULL,
14 `content` blob NOT NULL,
15 `user_id` int(11) NOT NULL,
16 PRIMARY KEY (`id`)
17) ENGINE=InnoDB DEFAULT CHARSET=latin1;
18
19CREATE TABLE IF NOT EXISTS `users` (
20 `id` int(11) NOT NULL AUTO_INCREMENT,
21 `username` varchar(255) NOT NULL,
22 `password` varchar(255) NOT NULL,
23 `name` int(255) NOT NULL,
24 `email` varchar(255) NOT NULL,
25 PRIMARY KEY (`id`)
26) ENGINE=InnoDB DEFAULT CHARSET=latin1;
27
28CREATE TABLE IF NOT EXISTS `users_config` (
29 `id` int(11) NOT NULL AUTO_INCREMENT,
30 `user_id` int(11) NOT NULL,
31 `name` varchar(255) NOT NULL,
32 `value` varchar(255) NOT NULL,
33 PRIMARY KEY (`id`)
34) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file
diff --git a/db/poche.sqlite.in b/install/poche.sqlite.in
index 45add0d7..45add0d7 100755
--- a/db/poche.sqlite.in
+++ b/install/poche.sqlite.in
Binary files differ
diff --git a/install/postgres.sql b/install/postgres.sql
new file mode 100644
index 00000000..9e0e8276
--- /dev/null
+++ b/install/postgres.sql
@@ -0,0 +1,30 @@
1CREATE TABLE config (
2 id bigserial primary key,
3 name varchar(255) NOT NULL,
4 value varchar(255) NOT NULL
5);
6
7CREATE TABLE entries (
8 id bigserial primary key,
9 title varchar(255) NOT NULL,
10 url varchar(255) NOT NULL,
11 is_read boolean DEFAULT false,
12 is_fav boolean DEFAULT false,
13 content TEXT,
14 user_id integer NOT NULL
15);
16
17CREATE TABLE users (
18 id bigserial primary key,
19 username varchar(255) NOT NULL,
20 password varchar(255) NOT NULL,
21 name varchar(255) NOT NULL,
22 email varchar(255) NOT NULL
23);
24
25CREATE TABLE users_config (
26 id bigserial primary key,
27 user_id integer NOT NULL,
28 name varchar(255) NOT NULL,
29 value varchar(255) NOT NULL
30); \ No newline at end of file
diff --git a/install/update_sqlite_from_0_to_1.php b/install/update_sqlite_from_0_to_1.php
new file mode 100644
index 00000000..2ee65522
--- /dev/null
+++ b/install/update_sqlite_from_0_to_1.php
@@ -0,0 +1,64 @@
1<?php
2
3$db_path = 'sqlite:../db/poche.sqlite';
4$handle = new PDO($db_path);
5$handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
6
7# Requêtes à exécuter pour mettre à jour poche.sqlite en 1.x
8
9# ajout d'un champ user_id sur la table entries
10$sql = 'ALTER TABLE entries RENAME TO tempEntries;';
11$query = $handle->prepare($sql);
12$query->execute();
13
14$sql = 'CREATE TABLE entries (id INTEGER PRIMARY KEY, title TEXT, url TEXT, is_read NUMERIC, is_fav NUMERIC, content BLOB, user_id NUMERIC);';
15$query = $handle->prepare($sql);
16$query->execute();
17
18$sql = 'INSERT INTO entries (id, title, url, is_read, is_fav, content) SELECT id, title, url, is_read, is_fav, content FROM tempEntries;';
19$query = $handle->prepare($sql);
20$query->execute();
21
22# Update tout pour mettre user_id = 1
23$sql = 'UPDATE entries SET user_id = 1;';
24$query = $handle->prepare($sql);
25$query->execute();
26
27# Changement des flags pour les lus / favoris
28$sql = 'UPDATE entries SET is_read = 1 WHERE is_read = -1;';
29$query = $handle->prepare($sql);
30$query->execute();
31
32$sql = 'UPDATE entries SET is_fav = 1 WHERE is_fav = -1;';
33$query = $handle->prepare($sql);
34$query->execute();
35
36# Création de la table users
37$sql = 'CREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT, password TEXT, name TEXT, email TEXT);';
38$query = $handle->prepare($sql);
39$query->execute();
40
41$sql = 'INSERT INTO users (username) SELECT value FROM config WHERE name = "login";';
42$query = $handle->prepare($sql);
43$query->execute();
44
45$sql = "UPDATE users SET password = (SELECT value FROM config WHERE name = 'password')";
46$query = $handle->prepare($sql);
47$query->execute();
48
49# Création de la table users_config
50$sql = 'CREATE TABLE users_config (id INTEGER PRIMARY KEY, user_id NUMERIC, name TEXT, value TEXT);';
51$query = $handle->prepare($sql);
52$query->execute();
53
54# Suppression de la table temporaire
55$sql = 'DROP TABLE tempEntries;';
56$query = $handle->prepare($sql);
57$query->execute();
58
59# Vidage de la table de config
60$sql = 'DELETE FROM config;';
61$query = $handle->prepare($sql);
62$query->execute();
63
64echo 'welcome to poche 1.0 !'; \ No newline at end of file