CREATE TABLE "balances" (
	"userId" integer,
	"guildId" integer,
	"balance" bigint DEFAULT 0::bigint,
	"lastMessageHour" integer,
	CONSTRAINT "balances_userId_guildId_pk" PRIMARY KEY("userId","guildId")
);
--> statement-breakpoint
CREATE TABLE "guilds" (
	"id" serial PRIMARY KEY NOT NULL,
	"discordId" bigint,
	"displayName" varchar(80),
	CONSTRAINT "guilds_discordId_unique" UNIQUE("discordId")
);
--> statement-breakpoint
CREATE TABLE "users" (
	"id" serial PRIMARY KEY NOT NULL,
	"discordId" bigint,
	"username" varchar(34),
	"displayName" varchar(64),
	"reputation" smallint DEFAULT 0,
	CONSTRAINT "users_discordId_unique" UNIQUE("discordId")
);
--> statement-breakpoint
ALTER TABLE "balances" ADD CONSTRAINT "balances_userId_users_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "balances" ADD CONSTRAINT "balances_guildId_guilds_id_fk" FOREIGN KEY ("guildId") REFERENCES "public"."guilds"("id") ON DELETE no action ON UPDATE no action;