-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak database table and view schema
- Loading branch information
Showing
13 changed files
with
346 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
CREATE TABLE categories( | ||
_id INTEGER NOT NULL PRIMARY KEY, | ||
id INTEGER NOT NULL PRIMARY KEY, | ||
name TEXT NOT NULL, | ||
sort INTEGER NOT NULL, | ||
flags INTEGER NOT NULL | ||
`order` INTEGER NOT NULL, | ||
flags INTEGER NOT NULL, | ||
UNIQUE(`order`) ON CONFLICT ABORT | ||
); | ||
|
||
-- Insert system category | ||
INSERT OR IGNORE INTO categories(_id, name, sort, flags) VALUES (0, "", -1, 0); | ||
INSERT OR IGNORE INTO categories(id, name, `order`, flags) VALUES (0, "", -1, 0); | ||
-- Disallow deletion of default category | ||
CREATE TRIGGER IF NOT EXISTS system_category_delete_trigger BEFORE DELETE | ||
ON categories | ||
BEGIN SELECT CASE | ||
WHEN old._id <= 0 THEN | ||
WHEN old.id <= 0 THEN | ||
RAISE(ABORT, "System category can't be deleted") | ||
END; | ||
END; | ||
|
||
getCategory: | ||
SELECT * | ||
FROM categories | ||
WHERE _id = :id | ||
LIMIT 1; | ||
WHERE id = :id; | ||
|
||
getCategories: | ||
SELECT | ||
_id AS id, | ||
id, | ||
name, | ||
sort AS `order`, | ||
`order`, | ||
flags | ||
FROM categories | ||
ORDER BY sort; | ||
ORDER BY `order`; | ||
|
||
getCategoriesByMangaId: | ||
SELECT | ||
C._id AS id, | ||
C.id, | ||
C.name, | ||
C.sort AS `order`, | ||
C.`order`, | ||
C.flags | ||
FROM categories C | ||
JOIN mangas_categories MC | ||
ON C._id = MC.category_id | ||
ON C.id = MC.category_id | ||
WHERE MC.manga_id = :mangaId; | ||
|
||
insert: | ||
INSERT INTO categories(name, sort, flags) | ||
INSERT INTO categories(name, `order`, flags) | ||
VALUES (:name, :order, :flags); | ||
|
||
delete: | ||
DELETE FROM categories | ||
WHERE _id = :categoryId; | ||
WHERE id = :categoryId; | ||
|
||
update: | ||
UPDATE categories | ||
SET name = coalesce(:name, name), | ||
sort = coalesce(:order, sort), | ||
`order` = coalesce(:order, `order`), | ||
flags = coalesce(:flags, flags) | ||
WHERE _id = :categoryId; | ||
WHERE id = :categoryId; | ||
|
||
updateAllFlags: | ||
UPDATE categories SET | ||
flags = coalesce(?, flags); | ||
|
||
selectLastInsertedRowId: | ||
SELECT last_insert_rowid(); | ||
SELECT last_insert_rowid(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
data/src/main/sqldelight/tachiyomi/data/excluded_scanlators.sq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.