feat: 添加历史路径功能
This commit is contained in:
@@ -227,13 +227,12 @@ const definedMigrations: Migration[] = [
|
||||
ANALYZE; -- 重新分析数据库模式
|
||||
`
|
||||
},
|
||||
// --- 未来可以添加更多迁移 ---
|
||||
{
|
||||
id: 6,
|
||||
name: 'Create passkeys table for WebAuthn credentials',
|
||||
check: async (db: Database): Promise<boolean> => {
|
||||
const passkeysTableAlreadyExists = await tableExists(db, 'passkeys');
|
||||
return !passkeysTableAlreadyExists; // Only run if the table does NOT exist
|
||||
return !passkeysTableAlreadyExists;
|
||||
},
|
||||
sql: `
|
||||
CREATE TABLE IF NOT EXISTS passkeys (
|
||||
@@ -251,6 +250,21 @@ const definedMigrations: Migration[] = [
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
`
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Create path_history table',
|
||||
check: async (db: Database): Promise<boolean> => {
|
||||
const tableAlreadyExists = await tableExists(db, 'path_history');
|
||||
return !tableAlreadyExists;
|
||||
},
|
||||
sql: `
|
||||
CREATE TABLE IF NOT EXISTS path_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path TEXT NOT NULL,
|
||||
timestamp INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||
);
|
||||
`
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ export const tableDefinitions: TableDefinition[] = [
|
||||
// Other utilities
|
||||
{ name: 'ip_blacklist', sql: schemaSql.createIpBlacklistTableSQL },
|
||||
{ name: 'command_history', sql: schemaSql.createCommandHistoryTableSQL },
|
||||
{ name: 'path_history', sql: schemaSql.createPathHistoryTableSQL },
|
||||
{ name: 'quick_commands', sql: schemaSql.createQuickCommandsTableSQL },
|
||||
|
||||
// Appearance related tables (often depend on others or have init logic)
|
||||
|
||||
@@ -158,6 +158,14 @@ CREATE TABLE IF NOT EXISTS command_history (
|
||||
);
|
||||
`;
|
||||
|
||||
export const createPathHistoryTableSQL = `
|
||||
CREATE TABLE IF NOT EXISTS path_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path TEXT NOT NULL,
|
||||
timestamp INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||
);
|
||||
`;
|
||||
|
||||
export const createQuickCommandsTableSQL = `
|
||||
CREATE TABLE IF NOT EXISTS quick_commands (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
||||
Reference in New Issue
Block a user