|
94 | 94 | logger = logging.getLogger("synapse_port_db") |
95 | 95 |
|
96 | 96 |
|
| 97 | +# SQLite doesn't have a dedicated boolean type (it stores True/False as 1/0). This means |
| 98 | +# portdb will read sqlite bools as integers, then try to insert them into postgres |
| 99 | +# boolean columns---which fails. Lacking some Python-parseable metaschema, we must |
| 100 | +# specify which integer columns should be inserted as booleans into postgres. |
97 | 101 | BOOLEAN_COLUMNS = { |
98 | | - "events": ["processed", "outlier", "contains_url"], |
99 | | - "rooms": ["is_public", "has_auth_chain_index"], |
| 102 | + "access_tokens": ["used"], |
| 103 | + "account_validity": ["email_sent"], |
| 104 | + "device_lists_changes_in_room": ["converted_to_destinations"], |
| 105 | + "device_lists_outbound_pokes": ["sent"], |
| 106 | + "devices": ["hidden"], |
| 107 | + "e2e_fallback_keys_json": ["used"], |
| 108 | + "e2e_room_keys": ["is_verified"], |
100 | 109 | "event_edges": ["is_state"], |
| 110 | + "events": ["processed", "outlier", "contains_url"], |
| 111 | + "local_media_repository": ["safe_from_quarantine"], |
101 | 112 | "presence_list": ["accepted"], |
102 | 113 | "presence_stream": ["currently_active"], |
103 | 114 | "public_room_list_stream": ["visibility"], |
104 | | - "devices": ["hidden"], |
105 | | - "device_lists_outbound_pokes": ["sent"], |
106 | | - "users_who_share_rooms": ["share_private"], |
107 | | - "e2e_room_keys": ["is_verified"], |
108 | | - "account_validity": ["email_sent"], |
| 115 | + "pushers": ["enabled"], |
109 | 116 | "redactions": ["have_censored"], |
110 | 117 | "room_stats_state": ["is_federatable"], |
111 | | - "local_media_repository": ["safe_from_quarantine"], |
| 118 | + "rooms": ["is_public", "has_auth_chain_index"], |
112 | 119 | "users": ["shadow_banned", "approved"], |
113 | | - "e2e_fallback_keys_json": ["used"], |
114 | | - "access_tokens": ["used"], |
115 | | - "device_lists_changes_in_room": ["converted_to_destinations"], |
116 | | - "pushers": ["enabled"], |
| 120 | + "un_partial_stated_event_stream": ["rejection_status_changed"], |
| 121 | + "users_who_share_rooms": ["share_private"], |
117 | 122 | } |
118 | 123 |
|
119 | 124 |
|
| 125 | +# These tables are never deleted from in normal operation [*], so we can resume porting |
| 126 | +# over rows from a previous attempt rather than starting from scratch. |
| 127 | +# |
| 128 | +# [*]: We do delete from many of these tables when purging a room, and |
| 129 | +# presumably when purging old events. So we might e.g. |
| 130 | +# |
| 131 | +# 1. Run portdb and port half of some table. |
| 132 | +# 2. Stop portdb. |
| 133 | +# 3. Purge something, deleting some of the rows we've ported over. |
| 134 | +# 4. Restart portdb. The rows deleted from sqlite are still present in postgres. |
| 135 | +# |
| 136 | +# But this isn't the end of the world: we should be able to repeat the purge |
| 137 | +# on the postgres DB when porting completes. |
120 | 138 | APPEND_ONLY_TABLES = [ |
| 139 | + "cache_invalidation_stream_by_instance", |
| 140 | + "event_auth", |
| 141 | + "event_edges", |
| 142 | + "event_json", |
121 | 143 | "event_reference_hashes", |
| 144 | + "event_search", |
| 145 | + "event_to_state_groups", |
122 | 146 | "events", |
123 | | - "event_json", |
124 | | - "state_events", |
125 | | - "room_memberships", |
126 | | - "topics", |
127 | | - "room_names", |
128 | | - "rooms", |
| 147 | + "ex_outlier_stream", |
129 | 148 | "local_media_repository", |
130 | 149 | "local_media_repository_thumbnails", |
| 150 | + "presence_stream", |
| 151 | + "public_room_list_stream", |
| 152 | + "push_rules_stream", |
| 153 | + "received_transactions", |
| 154 | + "redactions", |
| 155 | + "rejections", |
131 | 156 | "remote_media_cache", |
132 | 157 | "remote_media_cache_thumbnails", |
133 | | - "redactions", |
134 | | - "event_edges", |
135 | | - "event_auth", |
136 | | - "received_transactions", |
| 158 | + "room_memberships", |
| 159 | + "room_names", |
| 160 | + "rooms", |
137 | 161 | "sent_transactions", |
138 | | - "transaction_id_to_pdu", |
139 | | - "users", |
| 162 | + "state_events", |
| 163 | + "state_group_edges", |
140 | 164 | "state_groups", |
141 | 165 | "state_groups_state", |
142 | | - "event_to_state_groups", |
143 | | - "rejections", |
144 | | - "event_search", |
145 | | - "presence_stream", |
146 | | - "push_rules_stream", |
147 | | - "ex_outlier_stream", |
148 | | - "cache_invalidation_stream_by_instance", |
149 | | - "public_room_list_stream", |
150 | | - "state_group_edges", |
151 | 166 | "stream_ordering_to_exterm", |
| 167 | + "topics", |
| 168 | + "transaction_id_to_pdu", |
| 169 | + "un_partial_stated_event_stream", |
| 170 | + "users", |
152 | 171 | ] |
153 | 172 |
|
154 | 173 |
|
|
0 commit comments