Upgrade database schema to version 2 and remove unused meta_* columns
- Increment `SCHEMA_VERSION` to 2 in `schema.ts`. - Remove all `meta_*` columns from database tables. - Add migration logic to handle schema upgrades and clean up unused columns. - Modify database models and repository methods to exclude `meta_*` fields for stricter typings and improved structure. - Refactor and optimize query statements across repositories to align with new schema changes.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import sqlite3 from 'node-sqlite3-wasm';
|
||||
import path from 'path';
|
||||
import { app } from 'electron';
|
||||
import { initializeSchema } from './schema.js';
|
||||
import { initializeSchema, runMigrations } from './schema.js';
|
||||
|
||||
// Type alias for compatibility
|
||||
export type Database = sqlite3.Database;
|
||||
@@ -36,9 +36,12 @@ export class DatabaseService {
|
||||
this.userEncryptionKey = encryptionKey;
|
||||
this.userId = userId;
|
||||
|
||||
// Initialize schema
|
||||
// Initialize schema (creates tables if they don't exist)
|
||||
initializeSchema(this.db);
|
||||
|
||||
// Run migrations (updates existing tables if needed)
|
||||
runMigrations(this.db);
|
||||
|
||||
console.log(`Database initialized for user ${userId} at ${dbPath}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user