|
| 1 | +CREATE EXTENSION IF NOT EXISTS citext;--> statement-breakpoint |
| 2 | + |
| 3 | +-- this is a table to hold the phoenix schema migrations |
| 4 | +-- these migrations are currently handled by drizzle. |
| 5 | +-- we insert the relevant data inside the table so phoenix is happy |
| 6 | +CREATE TABLE "schema_migrations" ( |
| 7 | + "version" bigint PRIMARY KEY NOT NULL, |
| 8 | + "inserted_at" timestamp (0) |
| 9 | +); |
| 10 | +--> statement-breakpoint |
| 11 | +INSERT INTO "schema_migrations" ("version", "inserted_at") VALUES |
| 12 | +('20250806110912', '2025-08-27 10:28:02'), -- users and tokens table |
| 13 | +('20250807113759', '2025-08-27 10:28:02'), -- published items table |
| 14 | +('20250818111736', '2025-08-27 10:28:02'), -- removal notices table |
| 15 | +('20250819070000', '2025-08-27 10:28:02'); -- apps and publishers table |
| 16 | +--> statement-breakpoint |
| 17 | + |
| 18 | +CREATE TABLE "admins" ( |
| 19 | + "id" uuid PRIMARY KEY NOT NULL, |
| 20 | + "email" "citext" NOT NULL, |
| 21 | + "hashed_password" varchar(255), |
| 22 | + "confirmed_at" timestamp (0), |
| 23 | + "created_at" timestamp (0) NOT NULL, |
| 24 | + "updated_at" timestamp (0) NOT NULL, |
| 25 | + CONSTRAINT "admins_email_unique" UNIQUE("email") |
| 26 | +); |
| 27 | +--> statement-breakpoint |
| 28 | +CREATE INDEX "admins_email_index" ON "admins" USING btree ("email");--> statement-breakpoint |
| 29 | + |
| 30 | +CREATE TABLE "publication_removal_notices" ( |
| 31 | + "id" uuid PRIMARY KEY NOT NULL, |
| 32 | + "publication_name" varchar(255), |
| 33 | + "reason" text, |
| 34 | + "item_id" uuid, |
| 35 | + "creator_id" uuid, |
| 36 | + "created_at" timestamp (0) NOT NULL |
| 37 | +); |
| 38 | +ALTER TABLE "publication_removal_notices" ADD CONSTRAINT "publication_removal_notices_item_id_item_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."item"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint |
| 39 | +ALTER TABLE "publication_removal_notices" ADD CONSTRAINT "publication_removal_notices_creator_id_users_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."admins"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint |
| 40 | +CREATE INDEX "publication_removal_notices_item_id_index" ON "publication_removal_notices" USING btree ("item_id" uuid_ops);--> statement-breakpoint |
| 41 | + |
| 42 | + |
| 43 | +CREATE TABLE "admins_tokens" ( |
| 44 | + "id" uuid PRIMARY KEY NOT NULL, |
| 45 | + "user_id" uuid NOT NULL, |
| 46 | + "token" "bytea" NOT NULL, |
| 47 | + "context" varchar(255) NOT NULL, |
| 48 | + "sent_to" varchar(255), |
| 49 | + "authenticated_at" timestamp (0), |
| 50 | + "created_at" timestamp (0) NOT NULL, |
| 51 | + CONSTRAINT "admins_tokens_context_token_index" UNIQUE("context","token") |
| 52 | +); |
| 53 | +--> statement-breakpoint |
| 54 | +ALTER TABLE "admins_tokens" ADD CONSTRAINT "admins_tokens_user_id_admins_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."admins"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint |
| 55 | +CREATE INDEX "admins_tokens_user_id_index" ON "admins_tokens" USING btree ("user_id" uuid_ops); |
0 commit comments