Skip to content

Commit 9587648

Browse files
Merge upstream develop
2 parents 2b1d2cb + c23a06e commit 9587648

3 files changed

Lines changed: 94 additions & 3 deletions

File tree

.gitlab/ci/deploy_docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ docs-review-stop:
7171
variables:
7272
CF_PAGES_PROJECT: polycentric-docs
7373
CF_PAGES_BRANCH: mr-$CI_MERGE_REQUEST_IID
74-
# Needs a git checkout for the cleanup script below
75-
GIT_STRATEGY: none
7674
environment:
7775
name: review/docs/$CI_MERGE_REQUEST_IID
7876
action: stop

services/server/migration/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod m20260617_000002_drop_push_token_table;
1616
mod m20260618_000001_timestamps_to_timestamptz;
1717
mod m20260625_000001_add_event_key_indices;
1818
mod m20260630_000001_add_verification_tables;
19+
mod m20260707_164130_add_indices_for_sorting;
1920

2021
pub struct Migrator;
2122

@@ -32,13 +33,14 @@ impl MigratorTrait for Migrator {
3233
Box::new(m20260526_000002_add_content_repost_table::Migration),
3334
Box::new(m20260528_000001_reaction_opinion_to_positive::Migration),
3435
Box::new(m20260601_000001_add_content_report_table::Migration),
35-
Box::new(m20260604_000001_add_content_label_table::Migration),
3636
Box::new(m20260601_000001_add_follower_lookup_indexes::Migration),
37+
Box::new(m20260604_000001_add_content_label_table::Migration),
3738
Box::new(m20260617_000001_add_notification_table::Migration),
3839
Box::new(m20260617_000002_drop_push_token_table::Migration),
3940
Box::new(m20260618_000001_timestamps_to_timestamptz::Migration),
4041
Box::new(m20260625_000001_add_event_key_indices::Migration),
4142
Box::new(m20260630_000001_add_verification_tables::Migration),
43+
Box::new(m20260707_164130_add_indices_for_sorting::Migration),
4244
]
4345
}
4446
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
use ::entity::{event_model, notification};
2+
use sea_orm_migration::prelude::*;
3+
4+
/// `notification_to_identity_id_idx`: `list_notifications` grabs the notifications
5+
/// for an identity reverse sorted by the primary key.
6+
///
7+
/// `events_collection_created_at_id_idx`: feeds are sorted in reverse-chronological
8+
/// order, with the primary key as a fallback to keep the sort order stable.
9+
///
10+
/// `events_identity_heads_idx`: `list_heads` gets only the head for each "event stream"
11+
/// for efficient syncing.
12+
#[derive(DeriveMigrationName)]
13+
pub struct Migration;
14+
15+
#[async_trait::async_trait]
16+
impl MigrationTrait for Migration {
17+
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
18+
manager
19+
.create_index(
20+
Index::create()
21+
.if_not_exists()
22+
.name("notification_to_identity_id_idx")
23+
.table(notification::Entity)
24+
.col(notification::Column::ToIdentity)
25+
.col(notification::Column::Id)
26+
.to_owned(),
27+
)
28+
.await?;
29+
30+
manager
31+
.create_index(
32+
Index::create()
33+
.if_not_exists()
34+
.name("events_collection_created_at_id_idx")
35+
.table(event_model::Entity)
36+
.col(event_model::Column::Collection)
37+
.col(event_model::Column::CreatedAt)
38+
.col(event_model::Column::Id)
39+
.to_owned(),
40+
)
41+
.await?;
42+
43+
manager
44+
.create_index(
45+
Index::create()
46+
.if_not_exists()
47+
.name("events_identity_heads_idx")
48+
.table(event_model::Entity)
49+
.col(event_model::Column::Identity)
50+
.col(event_model::Column::PublicKeyType)
51+
.col(event_model::Column::PublicKey)
52+
.col(event_model::Column::Collection)
53+
.col(event_model::Column::Sequence)
54+
.to_owned(),
55+
)
56+
.await?;
57+
58+
Ok(())
59+
}
60+
61+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
62+
manager
63+
.drop_index(
64+
Index::drop()
65+
.name("events_identity_heads_idx")
66+
.table(event_model::Entity)
67+
.to_owned(),
68+
)
69+
.await?;
70+
71+
manager
72+
.drop_index(
73+
Index::drop()
74+
.name("events_collection_created_at_id_idx")
75+
.table(event_model::Entity)
76+
.to_owned(),
77+
)
78+
.await?;
79+
80+
manager
81+
.drop_index(
82+
Index::drop()
83+
.name("notification_to_identity_id_idx")
84+
.table(notification::Entity)
85+
.to_owned(),
86+
)
87+
.await?;
88+
89+
Ok(())
90+
}
91+
}

0 commit comments

Comments
 (0)