mirror of
https://github.com/mautrix/telegram.git
synced 2026-05-16 23:15:45 +03:00
legacymigrate: fix mx_room_state migration on sqlite
This commit is contained in:
@@ -262,6 +262,9 @@ CREATE TABLE new_mx_room_state (
|
||||
INSERT INTO new_mx_room_state (room_id, encryption, power_levels, create_event, members_fetched)
|
||||
SELECT room_id, encryption, power_levels, create_event, COALESCE(has_full_member_list, false)
|
||||
FROM mx_room_state;
|
||||
|
||||
DROP TABLE mx_room_state;
|
||||
ALTER TABLE new_mx_room_state RENAME TO mx_room_state;
|
||||
-- end only sqlite
|
||||
|
||||
ALTER TABLE mx_user_profile ADD COLUMN name_skeleton bytea;
|
||||
|
||||
40
pkg/connector/store/upgrades/09-legacy-migrate-fix.go
Normal file
40
pkg/connector/store/upgrades/09-legacy-migrate-fix.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// mautrix-telegram - A Matrix-Telegram puppeting bridge.
|
||||
// Copyright (C) 2026 Tulir Asokan
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package upgrades
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.mau.fi/util/dbutil"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Table.Register(-1, 9, 2, "Fix bug in legacy migration", dbutil.TxnModeOn, func(ctx context.Context, db *dbutil.Database) error {
|
||||
if db.Dialect != dbutil.SQLite {
|
||||
return nil
|
||||
}
|
||||
exists, err := db.TableExists(ctx, "new_mx_room_state")
|
||||
if !exists || err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = db.Exec(ctx, `
|
||||
DROP TABLE mx_room_state;
|
||||
ALTER TABLE new_mx_room_state RENAME TO mx_room_state;
|
||||
`)
|
||||
return err
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user