Files
CubeAdmin/drizzle/0000_overjoyed_thundra.sql
2026-03-08 15:49:34 +01:00

181 lines
5.5 KiB
SQL

CREATE TABLE `accounts` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`account_id` text NOT NULL,
`provider_id` text NOT NULL,
`access_token` text,
`refresh_token` text,
`expires_at` integer,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `audit_logs` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text,
`action` text NOT NULL,
`target` text,
`target_id` text,
`details` text,
`ip_address` text,
`created_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `backups` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`type` text NOT NULL,
`size` integer,
`path` text,
`created_at` integer NOT NULL,
`status` text DEFAULT 'pending' NOT NULL,
`triggered_by` text,
FOREIGN KEY (`triggered_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `invitations` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`role` text DEFAULT 'moderator' NOT NULL,
`invited_by` text NOT NULL,
`token` text NOT NULL,
`expires_at` integer NOT NULL,
`accepted_at` integer,
`created_at` integer NOT NULL,
FOREIGN KEY (`invited_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `invitations_token_unique` ON `invitations` (`token`);--> statement-breakpoint
CREATE TABLE `mc_players` (
`id` text PRIMARY KEY NOT NULL,
`uuid` text NOT NULL,
`username` text NOT NULL,
`first_seen` integer,
`last_seen` integer,
`is_online` integer DEFAULT false NOT NULL,
`play_time` integer DEFAULT 0 NOT NULL,
`role` text,
`is_banned` integer DEFAULT false NOT NULL,
`notes` text
);
--> statement-breakpoint
CREATE UNIQUE INDEX `mc_players_uuid_idx` ON `mc_players` (`uuid`);--> statement-breakpoint
CREATE TABLE `player_bans` (
`id` text PRIMARY KEY NOT NULL,
`player_id` text NOT NULL,
`reason` text,
`banned_by` text,
`banned_at` integer NOT NULL,
`expires_at` integer,
`is_active` integer DEFAULT true NOT NULL,
`unbanned_by` text,
`unbanned_at` integer,
FOREIGN KEY (`player_id`) REFERENCES `mc_players`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`banned_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`unbanned_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE TABLE `player_chat_history` (
`id` text PRIMARY KEY NOT NULL,
`player_id` text NOT NULL,
`message` text NOT NULL,
`channel` text,
`timestamp` integer NOT NULL,
`server_id` text,
FOREIGN KEY (`player_id`) REFERENCES `mc_players`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `player_spawn_points` (
`id` text PRIMARY KEY NOT NULL,
`player_id` text NOT NULL,
`name` text NOT NULL,
`world` text NOT NULL,
`x` real NOT NULL,
`y` real NOT NULL,
`z` real NOT NULL,
`created_at` integer NOT NULL,
FOREIGN KEY (`player_id`) REFERENCES `mc_players`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `plugins` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`version` text,
`description` text,
`is_enabled` integer DEFAULT true NOT NULL,
`jar_file` text,
`config` text,
`installed_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `scheduled_tasks` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`description` text,
`cron_expression` text NOT NULL,
`command` text NOT NULL,
`is_enabled` integer DEFAULT true NOT NULL,
`last_run` integer,
`next_run` integer,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `server_settings` (
`id` integer PRIMARY KEY DEFAULT 1 NOT NULL,
`minecraft_path` text,
`server_jar` text,
`server_version` text,
`server_type` text,
`max_ram` integer DEFAULT 4096,
`min_ram` integer DEFAULT 1024,
`rcon_enabled` integer DEFAULT false NOT NULL,
`rcon_port` integer DEFAULT 25575,
`rcon_password` text,
`java_args` text,
`auto_start` integer DEFAULT false NOT NULL,
`restart_on_crash` integer DEFAULT false NOT NULL,
`backup_enabled` integer DEFAULT false NOT NULL,
`backup_schedule` text,
`bluemap_enabled` integer DEFAULT false NOT NULL,
`bluemap_url` text,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE TABLE `sessions` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`token` text NOT NULL,
`expires_at` integer NOT NULL,
`ip_address` text,
`user_agent` text,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `sessions_token_unique` ON `sessions` (`token`);--> statement-breakpoint
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`email` text NOT NULL,
`email_verified` integer DEFAULT false NOT NULL,
`image` text,
`role` text DEFAULT 'moderator' NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
CREATE TABLE `verifications` (
`id` text PRIMARY KEY NOT NULL,
`identifier` text NOT NULL,
`value` text NOT NULL,
`expires_at` integer NOT NULL,
`created_at` integer NOT NULL,
`updated_at` integer NOT NULL
);