@@ -761,14 +761,18 @@ def alter_table(txn: LoggingTransaction) -> None:
761
761
762
762
# Step 2. Set up sequences
763
763
#
764
- # We do this before porting the tables so that event if we fail half
764
+ # We do this before porting the tables so that even if we fail half
765
765
# way through the postgres DB always have sequences that are greater
766
766
# than their respective tables. If we don't then creating the
767
767
# `DataStore` object will fail due to the inconsistency.
768
768
self .progress .set_state ("Setting up sequence generators" )
769
769
await self ._setup_state_group_id_seq ()
770
770
await self ._setup_user_id_seq ()
771
771
await self ._setup_events_stream_seqs ()
772
+ await self ._setup_sequence (
773
+ "un_partial_stated_event_stream_sequence" ,
774
+ ("un_partial_stated_event_stream" ,),
775
+ )
772
776
await self ._setup_sequence (
773
777
"device_inbox_sequence" , ("device_inbox" , "device_federation_outbox" )
774
778
)
@@ -779,6 +783,11 @@ def alter_table(txn: LoggingTransaction) -> None:
779
783
await self ._setup_sequence ("receipts_sequence" , ("receipts_linearized" ,))
780
784
await self ._setup_sequence ("presence_stream_sequence" , ("presence_stream" ,))
781
785
await self ._setup_auth_chain_sequence ()
786
+ await self ._setup_sequence (
787
+ "application_services_txn_id_seq" ,
788
+ ("application_services_txns" ,),
789
+ "txn_id" ,
790
+ )
782
791
783
792
# Step 3. Get tables.
784
793
self .progress .set_state ("Fetching tables" )
@@ -1083,7 +1092,10 @@ def _setup_events_stream_seqs_set_pos(txn: LoggingTransaction) -> None:
1083
1092
)
1084
1093
1085
1094
async def _setup_sequence (
1086
- self , sequence_name : str , stream_id_tables : Iterable [str ]
1095
+ self ,
1096
+ sequence_name : str ,
1097
+ stream_id_tables : Iterable [str ],
1098
+ column_name : str = "stream_id" ,
1087
1099
) -> None :
1088
1100
"""Set a sequence to the correct value."""
1089
1101
current_stream_ids = []
@@ -1093,7 +1105,7 @@ async def _setup_sequence(
1093
1105
await self .sqlite_store .db_pool .simple_select_one_onecol (
1094
1106
table = stream_id_table ,
1095
1107
keyvalues = {},
1096
- retcol = "COALESCE(MAX(stream_id ), 1)" ,
1108
+ retcol = f "COALESCE(MAX({ column_name } ), 1)" ,
1097
1109
allow_none = True ,
1098
1110
),
1099
1111
)
0 commit comments