feat: 添加快捷指令的标签管理系统

Related to #5
This commit is contained in:
Baobhan Sith
2025-05-03 15:18:51 +08:00
parent 430aac8512
commit 026ed949fb
22 changed files with 1828 additions and 296 deletions
+34 -1
View File
@@ -73,8 +73,41 @@ const definedMigrations: Migration[] = [
-- UPDATE connections SET encrypted_passphrase = NULL WHERE encrypted_passphrase = ''; -- 示例
`
},
// --- Quick Command Tags Migrations ---
{
id: 2,
name: 'Create quick_command_tags table',
check: async (db: Database): Promise<boolean> => {
const tableAlreadyExists = await tableExists(db, 'quick_command_tags');
return !tableAlreadyExists; // Only run if the table does NOT exist
},
sql: `
CREATE TABLE IF NOT EXISTS quick_command_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
updated_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
);
`
},
{
id: 3,
name: 'Create quick_command_tag_associations table',
check: async (db: Database): Promise<boolean> => {
const tableAlreadyExists = await tableExists(db, 'quick_command_tag_associations');
return !tableAlreadyExists; // Only run if the table does NOT exist
},
sql: `
CREATE TABLE IF NOT EXISTS quick_command_tag_associations (
quick_command_id INTEGER NOT NULL,
tag_id INTEGER NOT NULL,
PRIMARY KEY (quick_command_id, tag_id),
FOREIGN KEY (quick_command_id) REFERENCES quick_commands(id) ON DELETE CASCADE,
FOREIGN KEY (tag_id) REFERENCES quick_command_tags(id) ON DELETE CASCADE
);
`
}
// --- 未来可以添加更多迁移 ---
// { id: 2, name: '...', sql: '...' },
];
/**
+24
View File
@@ -152,6 +152,30 @@ CREATE TABLE IF NOT EXISTS quick_commands (
);
`;
// --- Quick Command Tags ---
export const createQuickCommandTagsTableSQL = `
CREATE TABLE IF NOT EXISTS quick_command_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
updated_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
);
`;
export const createQuickCommandTagAssociationsTableSQL = `
CREATE TABLE IF NOT EXISTS quick_command_tag_associations (
quick_command_id INTEGER NOT NULL,
tag_id INTEGER NOT NULL,
PRIMARY KEY (quick_command_id, tag_id),
FOREIGN KEY (quick_command_id) REFERENCES quick_commands(id) ON DELETE CASCADE,
FOREIGN KEY (tag_id) REFERENCES quick_command_tags(id) ON DELETE CASCADE
);
`;
// --- End Quick Command Tags ---
// 从 database.ts 移动过来的,保持一致性
export const createTerminalThemesTableSQL = `
CREATE TABLE IF NOT EXISTS terminal_themes (