feat: implement TASK-WP1-05 account deletion
This commit is contained in:
@@ -184,6 +184,7 @@ export class ManagedStorage {
|
||||
CREATE TABLE IF NOT EXISTS managed_files (
|
||||
file_id TEXT PRIMARY KEY,
|
||||
file_kind TEXT NOT NULL CHECK (file_kind IN ('reference', 'generated', 'export', 'derived', 'sticker_original', 'sticker_thumbnail')),
|
||||
owner_ref TEXT,
|
||||
relative_path TEXT NOT NULL UNIQUE,
|
||||
byte_size INTEGER NOT NULL CHECK (byte_size > 0),
|
||||
mime_type TEXT NOT NULL,
|
||||
@@ -242,6 +243,10 @@ export class ManagedStorage {
|
||||
CREATE TRIGGER IF NOT EXISTS admin_operation_logs_no_delete
|
||||
BEFORE DELETE ON admin_operation_logs BEGIN SELECT RAISE(ABORT, 'admin_operation_logs_immutable'); END;
|
||||
`);
|
||||
const managedFileColumns = this.database.prepare("PRAGMA table_info(managed_files)").all() as Array<{ name: string }>;
|
||||
if (!managedFileColumns.some((column) => column.name === "owner_ref")) {
|
||||
this.database.exec("ALTER TABLE managed_files ADD COLUMN owner_ref TEXT");
|
||||
}
|
||||
this.migrateLegacyAdminOperationLogs();
|
||||
const initial = classifyCapacity(0, 0);
|
||||
this.database.prepare(`
|
||||
@@ -479,9 +484,9 @@ export class ManagedStorage {
|
||||
|
||||
const commit = this.database.transaction(() => {
|
||||
this.database.prepare(`
|
||||
INSERT INTO managed_files (file_id, file_kind, relative_path, byte_size, mime_type, sha256, status, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, 'committed', ?)
|
||||
`).run(fileId, input.fileKind, destination.relativePath, byteSize, input.expectedMimeType, sha256, now());
|
||||
INSERT INTO managed_files (file_id, file_kind, owner_ref, relative_path, byte_size, mime_type, sha256, status, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, 'committed', ?)
|
||||
`).run(fileId, input.fileKind, input.ownerRef, destination.relativePath, byteSize, input.expectedMimeType, sha256, now());
|
||||
this.database.prepare(`
|
||||
UPDATE local_backend_storage_state SET managed_content_bytes = managed_content_bytes + ? WHERE singleton = 1
|
||||
`).run(byteSize);
|
||||
|
||||
Reference in New Issue
Block a user