CREATE TABLE "Payment" (
	"id" serial PRIMARY KEY NOT NULL,
	"userId" integer NOT NULL,
	"type" text NOT NULL,
	"amount" integer NOT NULL,
	"currency" text NOT NULL,
	"orderId" text NOT NULL,
	"paymentUrl" text,
	"status" text DEFAULT 'pending',
	"paymentId" text,
	"createdAt" timestamp DEFAULT now(),
	CONSTRAINT "Payment_orderId_unique" UNIQUE("orderId")
);
--> statement-breakpoint
CREATE TABLE "Test" (
	"id" serial PRIMARY KEY NOT NULL,
	"userId" integer NOT NULL,
	"answers" jsonb NOT NULL,
	"currentStep" integer DEFAULT 0 NOT NULL,
	"completedAt" timestamp,
	"result" text,
	"createdAt" timestamp DEFAULT now()
);
--> statement-breakpoint
CREATE TABLE "User" (
	"id" serial PRIMARY KEY NOT NULL,
	"telegramId" text NOT NULL,
	"username" text,
	"firstName" text,
	"isPremium" boolean DEFAULT false,
	"createdAt" timestamp DEFAULT now(),
	CONSTRAINT "User_telegramId_unique" UNIQUE("telegramId")
);
--> statement-breakpoint
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_userId_User_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "Test" ADD CONSTRAINT "Test_userId_User_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;