Files
discord-rpg-concept/app/drizzle/0000_big_obadiah_stane.sql

22 lines
1.0 KiB
SQL

CREATE TABLE "transactions" (
"transaction_id" serial PRIMARY KEY NOT NULL,
"from_user_id" text,
"to_user_id" text,
"amount" integer NOT NULL,
"occured_at" timestamp DEFAULT now(),
"type" text NOT NULL,
"description" text,
CONSTRAINT "transactions_transaction_id_unique" UNIQUE("transaction_id")
);
--> statement-breakpoint
CREATE TABLE "users" (
"user_id" text PRIMARY KEY NOT NULL,
"balance" integer DEFAULT 0 NOT NULL,
"last_daily" timestamp,
"daily_streak" integer DEFAULT 0 NOT NULL,
"created_at" timestamp DEFAULT now(),
CONSTRAINT "users_user_id_unique" UNIQUE("user_id")
);
--> statement-breakpoint
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_from_user_id_users_user_id_fk" FOREIGN KEY ("from_user_id") REFERENCES "public"."users"("user_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_to_user_id_users_user_id_fk" FOREIGN KEY ("to_user_id") REFERENCES "public"."users"("user_id") ON DELETE no action ON UPDATE no action;