♻️ (db): Fold the two follow migrations into a single V9
Changes
3 files changed, +31 -22
DELETE
src/main/resources/db/migration/V10__received_pushes.sql
+0 -12
@@ -1,15 +0,0 @@
1
-create table received_pushes
2
-(
3
- id uuid primary key,
4
- remote_actor_id text not null,
5
- activity_id text not null unique,
6
- summary text,
7
- target text,
8
- payload text not null,
9
- received_at timestamptz not null default now()
10
-);
11
-
12
-create index idx_received_pushes_actor on received_pushes (remote_actor_id, received_at);
ADD
src/main/resources/db/migration/V9__federation_following.sql
+31 -0
@@ -0,0 +1,31 @@
1
+-- Outbound federation following (issue #3).
2
+
3
+-- Outbound follows: a local user following a repository on a remote instance.
4
+-- follow_activity_id is the id of the Follow activity we sent; the inbound Accept
5
+-- references it to confirm the follow (state PENDING -> ACCEPTED).
6
+create table remote_follows
7
+(
8
+ id uuid primary key,
9
+ user_id uuid not null references users (id) on delete cascade,
10
+ remote_actor_id text not null,
11
+ follow_activity_id text not null unique,
12
+ state varchar(16) not null default 'PENDING' check (state in ('PENDING', 'ACCEPTED')),
13
+ created_at timestamptz not null default now(),
14
+ unique (user_id, remote_actor_id)
15
+);
16
+
17
+-- Follower-side feed: Push activities received from followed remote repositories.
18
+-- remote_actor_id is the sending repository's actor id; rows are only stored while
19
+-- at least one local user follows that actor.
20
+create table received_pushes
21
+(
22
+ id uuid primary key,
23
+ remote_actor_id text not null,
24
+ activity_id text not null unique,
25
+ summary text,
26
+ target text,
27
+ payload text not null,
28
+ received_at timestamptz not null default now()
29
+);
30
+
31
+create index idx_received_pushes_actor on received_pushes (remote_actor_id, received_at);
DELETE
src/main/resources/db/migration/V9__remote_follows.sql
+0 -10
@@ -1,13 +0,0 @@
1
-create table remote_follows
2
-(
3
- id uuid primary key,
4
- user_id uuid not null references users (id) on delete cascade,
5
- remote_actor_id text not null,
6
- follow_activity_id text not null unique,
7
- state varchar(16) not null default 'PENDING' check (state in ('PENDING', 'ACCEPTED')),
8
- created_at timestamptz not null default now(),
9
- unique (user_id, remote_actor_id)
10
-);