Skip to content

Commit d44b88a

Browse files
committed
feat: create DB schemata for APObjects and Activities
1 parent e7c946c commit d44b88a

File tree

10 files changed

+502
-7
lines changed

10 files changed

+502
-7
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
DO $$ BEGIN
2+
CREATE TYPE "activityPubActivityType" AS ENUM('Create', 'Update', 'Delete', 'Follow', 'Like');
3+
EXCEPTION
4+
WHEN duplicate_object THEN null;
5+
END $$;
6+
--> statement-breakpoint
7+
DO $$ BEGIN
8+
CREATE TYPE "activityPubObjectType" AS ENUM('Note');
9+
EXCEPTION
10+
WHEN duplicate_object THEN null;
11+
END $$;
12+
--> statement-breakpoint
13+
CREATE TABLE IF NOT EXISTS "activityPubActivity" (
14+
"id" text PRIMARY KEY NOT NULL,
15+
"receivedOn" timestamp NOT NULL,
16+
"type" "activityPubActivityType" NOT NULL,
17+
"actor" text NOT NULL,
18+
"object" text NOT NULL
19+
);
20+
--> statement-breakpoint
21+
CREATE TABLE IF NOT EXISTS "activityPubObject" (
22+
"id" text PRIMARY KEY NOT NULL,
23+
"receivedOn" timestamp NOT NULL,
24+
"type" "activityPubObjectType" NOT NULL,
25+
"published" timestamp NOT NULL,
26+
"attributedTo" text NOT NULL,
27+
"content" text NOT NULL,
28+
"inReplyTo" text,
29+
"to" text DEFAULT 'https://www.w3.org/ns/activitystreams#Public' NOT NULL
30+
);
31+
--> statement-breakpoint
32+
DO $$ BEGIN
33+
ALTER TABLE "activityPubActivity" ADD CONSTRAINT "activityPubActivity_object_activityPubObject_id_fk" FOREIGN KEY ("object") REFERENCES "activityPubObject"("id") ON DELETE no action ON UPDATE no action;
34+
EXCEPTION
35+
WHEN duplicate_object THEN null;
36+
END $$;

0 commit comments

Comments
 (0)