about summary refs log tree commit diff stats
path: root/sql
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-02-18 12:34:17 +0300
committerAndrew Dolgov <fox@fakecake.org>2024-02-18 12:34:56 +0300
commiteb52a7da8e2cafa1892d3f8810a69435b7a9b854 (patch)
tree286a54c4ea0d153fb31ce69edb0b8233e8046934 /sql
parent19b3e7fff80d430a9f287138f9cf84a1faa681fd (diff)
downloadthe-epube-eb52a7da8e2cafa1892d3f8810a69435b7a9b854.tar.gz
the-epube-eb52a7da8e2cafa1892d3f8810a69435b7a9b854.tar.xz
add pgsql support
Diffstat (limited to 'sql')
-rw-r--r--sql/pgsql/migrations/1.sql1
-rw-r--r--sql/pgsql/schema.sql23
-rw-r--r--sql/sqlite/migrations/1.sql1
-rw-r--r--sql/sqlite/schema.sql10
4 files changed, 30 insertions, 5 deletions
diff --git a/sql/pgsql/migrations/1.sql b/sql/pgsql/migrations/1.sql
new file mode 100644
index 0000000..e0298b7
--- /dev/null
+++ b/sql/pgsql/migrations/1.sql
@@ -0,0 +1 @@
+select true;
diff --git a/sql/pgsql/schema.sql b/sql/pgsql/schema.sql
new file mode 100644
index 0000000..3616f06
--- /dev/null
+++ b/sql/pgsql/schema.sql
@@ -0,0 +1,23 @@
+create table if not exists epube_users (
+	id serial not null primary key,
+	username varchar(100) not null unique,
+	pass varchar(200) not null);
+
+create table if not exists epube_pagination (
+	id serial not null primary key,
+	bookid bigint not null,
+	total_pages bigint not null,
+	pagination text not null);
+
+create table if not exists epube_books (
+	id serial not null primary key,
+	bookid bigint not null,
+	owner varchar(200) not null not null references epube_users(username) on delete cascade,
+	lastts bigint not null,
+	lastcfi text not null,
+	lastread bigint not null);
+
+create table if not exists epube_favorites(
+	id serial not null primary key,
+	bookid bigint not null,
+	owner varchar(200) not null references epube_users(username) on delete cascade);
diff --git a/sql/sqlite/migrations/1.sql b/sql/sqlite/migrations/1.sql
new file mode 100644
index 0000000..198131a
--- /dev/null
+++ b/sql/sqlite/migrations/1.sql
@@ -0,0 +1 @@
+alter table epube_users RENAME COLUMN user to username;
diff --git a/sql/sqlite/schema.sql b/sql/sqlite/schema.sql
index a0daf61..eeab2f9 100644
--- a/sql/sqlite/schema.sql
+++ b/sql/sqlite/schema.sql
@@ -4,6 +4,11 @@ create table if not exists epube_pagination (
 	total_pages integer not null,
 	pagination text not null);
 
+create table if not exists epube_users (
+	id integer not null primary key autoincrement,
+	username varchar(100) not null,
+	pass varchar(200) not null);
+
 create table if not exists epube_books (
 	id integer not null primary key autoincrement,
 	bookid integer not null,
@@ -12,11 +17,6 @@ create table if not exists epube_books (
 	lastcfi varchar(200) not null,
 	lastread integer not null);
 
-create table if not exists epube_users (
-	id integer not null primary key autoincrement,
-	user varchar(100) not null,
-	pass varchar(200) not null);
-
 create table if not exists epube_favorites(
 	id integer not null primary key autoincrement,
 	bookid integer not null,