Files
award/drizzle/0002_nervous_layla_miller.sql
Joerg fc44fef91a feat: add migration for admin actions and role fields
Adds new tables and columns for admin functionality:

- Create admin_actions table for audit logging
- Create qso_changes table for sync job rollback support
- Add role column to users (default: 'user')
- Add is_admin column to users (default: false)

No data loss - uses ALTER TABLE with safe defaults.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-21 10:37:05 +01:00

25 lines
1.0 KiB
SQL

CREATE TABLE `admin_actions` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`admin_id` integer NOT NULL,
`action_type` text NOT NULL,
`target_user_id` integer,
`details` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`admin_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`target_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `qso_changes` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`job_id` integer NOT NULL,
`qso_id` integer,
`change_type` text NOT NULL,
`before_data` text,
`after_data` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`job_id`) REFERENCES `sync_jobs`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`qso_id`) REFERENCES `qsos`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
ALTER TABLE `users` ADD `role` text DEFAULT 'user' NOT NULL;--> statement-breakpoint
ALTER TABLE `users` ADD `is_admin` integer DEFAULT false NOT NULL;