Files
lbf-bot/packages/database/drizzle/0000_tan_justin_hammer.sql
2025-12-04 22:18:57 +01:00

21 lines
869 B
SQL

CREATE TABLE "accounts" (
"player_id" uuid PRIMARY KEY NOT NULL,
"balance" integer DEFAULT 0 NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "tracked_players" (
"player_id" uuid PRIMARY KEY NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "username_history" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"player_id" uuid NOT NULL,
"username" text NOT NULL,
"first_seen_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "username_history" ADD CONSTRAINT "username_history_player_id_tracked_players_player_id_fk" FOREIGN KEY ("player_id") REFERENCES "public"."tracked_players"("player_id") ON DELETE cascade ON UPDATE no action;