Pre alpha patch 5 (#928)

* fix: `default` category is added after id = 1 was deleted

* add new fields for Novel and Chapter table
This commit is contained in:
nyagami
2024-01-31 14:30:27 +07:00
committed by GitHub
parent 3f59bcf751
commit 6c20d1855d
5 changed files with 10 additions and 11 deletions
-2
View File
@@ -2,7 +2,6 @@ import * as SQLite from 'expo-sqlite';
import {
createCategoriesTableQuery,
createCategoryDefaultQuery,
createCategoryLocalQuery,
createCategoryTriggerQuery,
} from './tables/CategoryTable';
import { createNovelTableQuery } from './tables/NovelTable';
@@ -24,7 +23,6 @@ export const createTables = () => {
tx.executeSql(createNovelTableQuery);
tx.executeSql(createCategoriesTableQuery, [], () => {
tx.executeSql(createCategoryDefaultQuery);
tx.executeSql(createCategoryLocalQuery);
tx.executeSql(createCategoryTriggerQuery);
});
tx.executeSql(createNovelCategoryTableQuery);
+6 -7
View File
@@ -15,10 +15,9 @@ export const createCategoryTriggerQuery = `
END;
`;
export const createCategoryDefaultQuery = `INSERT OR IGNORE INTO Category (id, name, sort) VALUES (1, "${getString(
'categories.default',
)}", 1)`;
export const createCategoryLocalQuery = `INSERT OR IGNORE INTO Category (id, name, sort) VALUES (2, "${getString(
'categories.local',
)}", 2)`;
// if category with id = 2 exists, nothing in db.ts file is executed
export const createCategoryDefaultQuery = `
INSERT INTO Category (id, name, sort) VALUES
(1, "${getString('categories.default')}", 1),
(2, "${getString('categories.local')}", 2)
`;
+1
View File
@@ -11,6 +11,7 @@ export const createChapterTableQuery = `
isDownloaded INTEGER DEFAULT 0,
updatedTime TEXT,
chapterNumber REAL NULL,
page INTEGER DEFAULT 1,
FOREIGN KEY (novelId) REFERENCES Novel(id) ON DELETE CASCADE
)
`;
+2 -1
View File
@@ -11,6 +11,7 @@ export const createNovelTableQuery = `
status TEXT Default 'Unknown',
genres TEXT,
inLibrary INTEGER DEFAULT 0,
isLocal INTERGER DEFAULT 0
isLocal INTEGER DEFAULT 0,
totalPages INTEGER DEFAULT 1
);
`;