30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { BaseMigration } from './base-migration.ts';
|
|
import type { TQueryFunction } from '../types.ts';
|
|
|
|
export class Migration009BackupSystem extends BaseMigration {
|
|
readonly version = 9;
|
|
readonly description = 'Backup system tables';
|
|
|
|
up(query: TQueryFunction): void {
|
|
query(`ALTER TABLE services ADD COLUMN include_image_in_backup INTEGER DEFAULT 1`);
|
|
|
|
query(`
|
|
CREATE TABLE backups (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
service_id INTEGER NOT NULL,
|
|
service_name TEXT NOT NULL,
|
|
filename TEXT NOT NULL,
|
|
size_bytes INTEGER NOT NULL,
|
|
created_at REAL NOT NULL,
|
|
includes_image INTEGER NOT NULL,
|
|
platform_resources TEXT NOT NULL DEFAULT '[]',
|
|
checksum TEXT NOT NULL,
|
|
FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE
|
|
)
|
|
`);
|
|
|
|
query('CREATE INDEX IF NOT EXISTS idx_backups_service ON backups(service_id)');
|
|
query('CREATE INDEX IF NOT EXISTS idx_backups_created ON backups(created_at DESC)');
|
|
}
|
|
}
|