Update table/column names in DBMS migration (#391)

This commit is contained in:
Benjamin Bouvier 2021-11-12 16:34:25 +01:00 committed by GitHub
parent 91de4fe70e
commit 83c2e1d698
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,23 +92,19 @@ func migrateTable(old *Database, new *Database, table string, columns ...string)
}
func Migrate(old *Database, new *Database) {
err := migrateTable(old, new, "portal", "jid", "receiver", "mxid", "name", "topic", "avatar", "avatar_url", "encrypted")
err := migrateTable(old, new, "portal", "jid", "receiver", "mxid", "name", "topic", "avatar", "avatar_url", "encrypted", "first_event_id", "next_batch_id", "relay_user_id")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "user", "mxid", "jid", "management_room", "client_id", "client_token", "server_token", "enc_key", "mac_key", "last_connection")
err = migrateTable(old, new, "user", "mxid", "management_room", "username", "agent", "device")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "puppet", "jid", "avatar", "displayname", "name_quality", "custom_mxid", "access_token", "next_batch", "avatar_url", "enable_presence", "enable_receipts")
err = migrateTable(old, new, "puppet", "username", "avatar", "displayname", "name_quality", "custom_mxid", "access_token", "next_batch", "avatar_url", "enable_presence", "enable_receipts")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "user_portal", "user_jid", "portal_jid", "portal_receiver", "in_community")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "message", "chat_jid", "chat_receiver", "jid", "mxid", "sender", "timestamp", "sent")
err = migrateTable(old, new, "message", "chat_jid", "chat_receiver", "jid", "mxid", "sender", "timestamp", "sent", "decryption_error")
if err != nil {
panic(err)
}
@ -152,4 +148,53 @@ func Migrate(old *Database, new *Database) {
if err != nil {
panic(err)
}
err = migrateTable(old, new, "crypto_cross_signing_keys", "user_id", "usage", "key")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "crypto_cross_signing_signatures", "signed_user_id", "signed_key", "signer_user_id", "signer_key", "signature")
if err != nil {
panic(err)
}
// Migrate whatsmeow tables.
err = migrateTable(old, new, "whatsmeow_device", "jid", "registration_id", "noise_key", "identity_key", "signed_pre_key", "signed_pre_key_id", "signed_pre_key_sig", "adv_key", "adv_details", "adv_account_sig", "adv_device_sig", "platform", "business_name", "push_name")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_identity_keys", "our_jid", "their_id", "identity")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_pre_keys", "jid", "key_id", "key", "uploaded")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_sessions", "our_jid", "their_id", "session")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_sender_keys", "our_jid", "chat_id", "sender_id", "sender_key")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_app_state_sync_keys", "jid", "key_id", "key_data", "timestamp", "fingerprint")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_app_state_version", "jid", "name", "version", "hash")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_app_state_mutation_macs", "jid", "name", "version", "index_mac", "value_mac")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_contacts", "our_jid", "their_jid", "first_name", "full_name", "push_name", "business_name")
if err != nil {
panic(err)
}
err = migrateTable(old, new, "whatsmeow_chat_settings", "our_jid", "chat_jid", "muted_until", "pinned", "archived")
if err != nil {
panic(err)
}
}