feat(database): run migration

This commit is contained in:
Pihkaal
2025-12-04 22:18:57 +01:00
parent b007f0a892
commit 56b2312f51
7 changed files with 194 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
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;