Repos / pytaku / 1b75448974
commit 1b754489745fcb752ca20154356729f2f9e21d87
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Sat Aug 29 08:23:00 2020 +0700
drop unique chapter num_major/minor constraint
Because mangadex can have the same chapter uploaded by different groups.
diff --git a/pyproject.toml b/pyproject.toml
index 8b2a08f..dc48d86 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytaku"
-version = "0.3.6"
+version = "0.3.7"
description = "Self-hostable web-based manga reader"
authors = ["Bùi Thành Nhân <hi@imnhan.com>"]
license = "AGPL-3.0-only"
diff --git a/src/pytaku/database/migrations/latest_schema.sql b/src/pytaku/database/migrations/latest_schema.sql
index fc65604..894207d 100644
--- a/src/pytaku/database/migrations/latest_schema.sql
+++ b/src/pytaku/database/migrations/latest_schema.sql
@@ -34,22 +34,6 @@ CREATE TABLE keyval_store (
value text not null,
updated_at text default (datetime('now'))
);
-CREATE TABLE IF NOT EXISTS "chapter" (
- id text,
- title_id text,
- site text,
- num_major integer,
- num_minor integer,
- name text,
- pages text,
- groups text,
- updated_at text default (datetime('now')),
- is_webtoon boolean,
-
- foreign key (title_id, site) references title (id, site),
- unique(site, title_id, id),
- unique(site, title_id, num_major, num_minor)
-);
CREATE TABLE token (
user_id integer not null,
token text unique not null,
@@ -69,3 +53,18 @@ CREATE TABLE IF NOT EXISTS "read" (
foreign key (user_id) references user (id),
unique(user_id, site, title_id, chapter_id)
);
+CREATE TABLE IF NOT EXISTS "chapter"(
+ id text,
+ title_id text,
+ site text,
+ num_major integer,
+ num_minor integer,
+ name text,
+ pages text,
+ groups text,
+ updated_at text default (datetime('now')),
+ is_webtoon boolean,
+
+ foreign key (title_id, site) references title (id, site),
+ unique(site, title_id, id)
+);
diff --git a/src/pytaku/database/migrations/m0006.sql b/src/pytaku/database/migrations/m0006.sql
new file mode 100644
index 0000000..a1aa164
--- /dev/null
+++ b/src/pytaku/database/migrations/m0006.sql
@@ -0,0 +1,28 @@
+-- Remove unique num_major, num_minor unique constraint.
+-- Because mangadex can have the same chapter uploaded by different groups.
+
+pragma foreign_keys = off; -- to let us do anything at all
+begin transaction;
+
+create table new_chapter(
+ id text,
+ title_id text,
+ site text,
+ num_major integer,
+ num_minor integer,
+ name text,
+ pages text,
+ groups text,
+ updated_at text default (datetime('now')),
+ is_webtoon boolean,
+
+ foreign key (title_id, site) references title (id, site),
+ unique(site, title_id, id)
+);
+insert into new_chapter select * from chapter;
+drop table chapter;
+alter table new_chapter rename to chapter;
+
+pragma foreign_key_check;
+commit;
+pragma foreign_keys = on;