Skip to content

Commit a4f602d

Browse files
committed
Merge main and reconcile embedded migration count
Signed-off-by: Tom Brow <[email protected]>
2 parents 12f1d1e + 1e80066 commit a4f602d

31 files changed

Lines changed: 1604 additions & 2763 deletions

‎crates/buzz-db/src/runtime/migration.rs‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,9 @@ mod postgres_tests {
705705
let mut migrations: Vec<_> = MIGRATOR.iter().collect();
706706
migrations.sort_by_key(|migration| migration.version);
707707

708-
assert_eq!(migrations.len(), 58);
709-
// 0058 is reserved by the independently reviewed trigger retirement.
710-
assert_eq!(migrations[57].version, 59);
711-
assert!(migrations[57].sql.as_str().contains("buzz.push_enabled"));
708+
assert_eq!(migrations.len(), 59);
709+
assert_eq!(migrations[58].version, 59);
710+
assert!(migrations[58].sql.as_str().contains("buzz.push_enabled"));
712711
assert_eq!(migrations[55].version, 56);
713712
assert!(migrations[55]
714713
.sql
@@ -719,6 +718,11 @@ mod postgres_tests {
719718
.sql
720719
.as_str()
721720
.contains("ALTER TABLE personal_read_accounts ADD COLUMN started_at"));
721+
assert_eq!(migrations[57].version, 58);
722+
assert!(migrations[57]
723+
.sql
724+
.as_str()
725+
.contains("ADD COLUMN through_message_id"));
722726
assert_eq!(migrations[48].version, 49);
723727
assert_eq!(migrations[49].version, 50);
724728
assert_eq!(migrations[50].version, 51);
@@ -2232,6 +2236,18 @@ mod postgres_tests {
22322236
.get("personal_read_accounts")
22332237
.expect("schema.sql personal read accounts")
22342238
.contains(started_at_column));
2239+
// 0058 replaces the frontier's whole-channel cut with its anchor ID.
2240+
let threads_through_column = "threads_through_timestamp timestamptz \
2241+
check (threads_through_timestamp is null or root_id = ''::bytea), ";
2242+
let through_message_column =
2243+
"through_message_id bytea check (octet_length(through_message_id) = 32), ";
2244+
let through_message = MIGRATOR
2245+
.iter()
2246+
.find(|m| m.version == 58)
2247+
.expect("personal read anchor migration")
2248+
.sql
2249+
.as_str();
2250+
assert!(through_message.contains("DROP COLUMN threads_through_timestamp"));
22352251
for (table, definition) in personal.tables {
22362252
let in_schema = schema.tables.get(&table).map(|schema_definition| {
22372253
if table == "personal_read_accounts" {
@@ -2240,6 +2256,11 @@ mod postgres_tests {
22402256
schema_definition.clone()
22412257
}
22422258
});
2259+
let definition = if table == "personal_read_frontiers" {
2260+
definition.replacen(threads_through_column, through_message_column, 1)
2261+
} else {
2262+
definition
2263+
};
22432264
assert_eq!(
22442265
in_schema.as_ref(),
22452266
Some(&definition),

0 commit comments

Comments
 (0)