CREATE TYPE "public"."roles" AS ENUM('admin', 'guest', 'pro');--> statement-breakpoint
CREATE TABLE "deck" (
	"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "deck_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
	"deckname" varchar NOT NULL,
	"bildname" varchar,
	"bildid" varchar,
	"x1" real,
	"x2" real,
	"y1" real,
	"y2" real,
	"due" integer,
	"ivl" real,
	"factor" real,
	"reps" integer,
	"lapses" integer,
	"isgraduated" integer,
	"user" varchar NOT NULL,
	"inserted" timestamp DEFAULT now(),
	"updated" timestamp DEFAULT now()
);
--> statement-breakpoint
CREATE TABLE "users" (
	"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
	"name" varchar(256),
	"email" varchar NOT NULL,
	"role" "roles" DEFAULT 'guest',
	"sign_in_provider" varchar(50),
	"lastLogin" timestamp DEFAULT now(),
	"numberOfLogins" integer DEFAULT 1
);
--> statement-breakpoint
CREATE UNIQUE INDEX "deck_idx" ON "deck" USING btree ("id");--> statement-breakpoint
CREATE UNIQUE INDEX "users_idx" ON "users" USING btree ("id");