Merge pull request #776 from ZacharyZcR/feat/per-user-shared-host-credentials

feat: support per-user credentials on shared hosts
This commit is contained in:
ZacharyZcR
2026-05-18 04:36:33 +08:00
committed by GitHub
4 changed files with 117 additions and 1 deletions
+13
View File
@@ -1008,6 +1008,19 @@ const migrateSchema = () => {
}
}
try {
sqlite.prepare("SELECT override_credential_id FROM host_access LIMIT 1").get();
} catch {
try {
sqlite.exec("ALTER TABLE host_access ADD COLUMN override_credential_id INTEGER REFERENCES ssh_credentials(id) ON DELETE SET NULL");
} catch (alterError) {
databaseLogger.warn("Failed to add override_credential_id column", {
operation: "schema_migration",
error: alterError,
});
}
}
try {
sqlite.prepare("SELECT sudo_password FROM ssh_data LIMIT 1").get();
} catch {
+4
View File
@@ -462,6 +462,10 @@ export const hostAccess = sqliteTable("host_access", {
.default(sql`CURRENT_TIMESTAMP`),
lastAccessedAt: text("last_accessed_at"),
accessCount: integer("access_count").notNull().default(0),
overrideCredentialId: integer("override_credential_id").references(
() => sshCredentials.id,
{ onDelete: "set null" },
),
});
export const sharedCredentials = sqliteTable("shared_credentials", {