Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .pgschemaignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# pgschema reads this file from its working directory; every caller runs it
# from the repository root.
#
# The relay's partition manager creates dated `events` / `delivery_log`
# monthlies at runtime (see crates/buzz-db/src/store/partition/). They are not
# declared in schema/partitions/, so without this file re-applying pgschema to a
# database a relay has used drops them, and their rows, with
# `DROP TABLE IF EXISTS ... CASCADE`. Only the monthlies schema/partitions/
# The relay's partition manager creates dated `events` monthlies at runtime
# (see crates/buzz-db/src/store/partition/). Older relays also created
# `delivery_log` monthlies; their pattern stays until a migration drops that
# table. These monthlies are not declared in schema/partitions/, so without
# this file re-applying pgschema to a database a relay has used drops them, and
# their rows, with `DROP TABLE IF EXISTS ... CASCADE`. Only the monthlies schema/partitions/
# declares stay managed by pgschema; keep the `!` exemptions below in sync with
# them.
[tables]
Expand Down
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ All database access. Uses `sqlx::query()` (runtime, not compile-time macros) —
| `channel.rs` | Channel CRUD, membership management, role enforcement (transactional) |
| `feed.rs` | `query_mentions` (INNER JOIN event_mentions), `query_needs_action`, `query_activity` |
| `workflow.rs` | Full workflow/run/approval CRUD; SHA-256 hashed approval tokens |
| `partition.rs` | Monthly range partitioning for `events` and `delivery_log` tables: read-only catalog audit plus advisory-locked, time-bounded maintenance that creates uncovered months and advances an empty catch-all (`partition/maintenance.rs`) |
| `partition.rs` | Monthly range partitioning for the `events` table: read-only catalog audit plus advisory-locked, time-bounded maintenance that creates uncovered months and advances an empty catch-all (`partition/maintenance.rs`) |
| `dm.rs` | DM channel management |
| `reaction.rs` | Reaction storage and retrieval |
| `thread.rs` | Thread/reply tracking |
Expand Down
19 changes: 14 additions & 5 deletions crates/buzz-db/src/runtime/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ mod postgres_tests {
];
for table in crate::deletion::EXPECTED_SCOPED_TABLES
.iter()
.chain(crate::deletion::RETIRING_SCOPED_TABLES)
.filter(|table| !never_fenced.contains(table))
{
assert!(
Expand Down Expand Up @@ -3424,8 +3425,9 @@ mod postgres_tests {
"reconcile did not attach both catch-alls: {declared_bounds:?}"
);

// The relay's default startup pass advances each catch-all into dated
// monthlies schema/partitions/ does not declare.
// The relay's default startup pass advances the `events` catch-all into
// dated monthlies schema/partitions/ does not declare. `delivery_log` is
// retired from partition management, so its catch-all stays as declared.
maintain_partitions(
&pool,
PARTITION_MANAGER_MONTHS_AHEAD,
Expand All @@ -3442,13 +3444,17 @@ mod postgres_tests {
"maintenance dropped or detached a catch-all: {advanced_bounds:?}"
);
for (declared, advanced) in declared_bounds.iter().zip(&advanced_bounds) {
assert_ne!(declared, advanced, "catch-all did not advance");
if declared.0 == "events_p_future" {
assert_ne!(declared, advanced, "catch-all did not advance");
} else {
assert_eq!(declared, advanced, "retired table was partition-managed");
}
}
let children: Vec<(String, String)> = sqlx::query_as(
"SELECT p.relname::text, c.relname::text FROM pg_inherits i \
JOIN pg_class c ON c.oid = i.inhrelid \
JOIN pg_class p ON p.oid = i.inhparent \
WHERE p.relname IN ('events', 'delivery_log')",
WHERE p.relname = 'events'",
)
.fetch_all(&pool)
.await
Expand All @@ -3460,7 +3466,10 @@ mod postgres_tests {
child.starts_with(&format!("{parent}_p2")) && !declared.contains(child)
})
.collect();
for (catch_all, bound) in &declared_bounds {
for (catch_all, bound) in declared_bounds
.iter()
.filter(|(catch_all, _)| catch_all == "events_p_future")
{
// The first month the declared catch-all served, from its
// `FOR VALUES FROM ('YYYY-MM-01 ...')` lower bound.
let parent = catch_all
Expand Down
Loading
Loading