1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/drizzle/0000_aromatic_night_nurse.sql
roxwize e3c09d7f0d
this is the initial commit for my AWESOME website
Signed-off-by: roxwize <rae@roxwize.xyz>
2024-11-13 22:51:08 -05:00

34 lines
1.3 KiB
SQL

CREATE TABLE IF NOT EXISTS "updates" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "updates_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"user" integer NOT NULL,
"mood" integer DEFAULT 0,
"description" varchar(2048)
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "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(26) NOT NULL,
"pass" varchar(255) NOT NULL,
"registered" timestamp NOT NULL,
"bio" varchar(2048) DEFAULT '',
"moderator" boolean DEFAULT false,
"banned" boolean DEFAULT false,
CONSTRAINT "users_name_unique" UNIQUE("name")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "updates" ADD CONSTRAINT "updates_user_users_id_fk" FOREIGN KEY ("user") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
CREATE TABLE "session" (
"sid" varchar NOT NULL COLLATE "default",
"sess" json NOT NULL,
"expire" timestamp(6) NOT NULL
)
WITH (OIDS=FALSE);
ALTER TABLE "session" ADD CONSTRAINT "session_pkey" PRIMARY KEY ("sid") NOT DEFERRABLE INITIALLY IMMEDIATE;
CREATE INDEX "IDX_session_expire" ON "session" ("expire");