Update
This commit is contained in:
@ -107,7 +107,7 @@ function extractDomain(url: string): string | null {
|
||||
}
|
||||
|
||||
// Initialize database with proper error handling
|
||||
async function initializeDatabase(): Database {
|
||||
function initializeDatabase(): Database {
|
||||
// Ensure data directory exists
|
||||
if (!fs.existsSync(config.paths.dataDir)) {
|
||||
fs.mkdirSync(config.paths.dataDir, { recursive: true });
|
||||
@ -205,12 +205,20 @@ async function initializeDatabase(): Database {
|
||||
// Perform database integrity checks and fixes
|
||||
performDatabaseIntegrityFixes(db);
|
||||
|
||||
await migrateFeedsWithCategories(db);
|
||||
// ALTER
|
||||
// ALTER TABLE feeds ADD COLUMN category TEXT DEFAULT NULL;
|
||||
// Ensure the category column exists
|
||||
const infos = db.prepare("PRAGMA table_info(feeds);").all();
|
||||
const hasCategory = infos.some((col: any) => col.name === "category");
|
||||
|
||||
if (!hasCategory) {
|
||||
db.exec("ALTER TABLE feeds ADD COLUMN category TEXT DEFAULT NULL;");
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
const db = await initializeDatabase();
|
||||
const db = initializeDatabase();
|
||||
|
||||
export interface Feed {
|
||||
id: string;
|
||||
@ -1126,7 +1134,7 @@ export async function updateFeedRequestStatus(
|
||||
}
|
||||
|
||||
// Migration function to classify existing feeds without categories
|
||||
export async function migrateFeedsWithCategories(db: Database): void {
|
||||
export async function migrateFeedsWithCategories(): Promise<void> {
|
||||
try {
|
||||
console.log("🔄 Starting feed category migration...");
|
||||
|
||||
|
Reference in New Issue
Block a user