mirror of
https://github.com/mautrix/telegram.git
synced 2026-05-17 07:25:46 +03:00
legacymigrate: drop telegram_file table separately on sqlite (#28)
* legacymigrate: drop telegram_file table separately on sqlite * legacymigrate: check foreign keys after dropping table just to be safe
This commit is contained in:
@@ -265,6 +265,7 @@ DROP TABLE reaction_old;
|
||||
DROP TABLE portal_old;
|
||||
DROP TABLE puppet_old;
|
||||
DROP TABLE user_old;
|
||||
-- only: postgres (this is deleted separately for sqlite)
|
||||
DROP TABLE telegram_file_old;
|
||||
DROP TABLE telethon_entities_old;
|
||||
DROP TABLE telethon_sent_files_old;
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"go.mau.fi/util/dbutil/litestream"
|
||||
"go.mau.fi/util/exerrors"
|
||||
"maunium.net/go/mautrix/bridgev2/bridgeconfig"
|
||||
"maunium.net/go/mautrix/bridgev2/matrix/mxmain"
|
||||
|
||||
@@ -102,6 +104,15 @@ func main() {
|
||||
),
|
||||
true,
|
||||
)
|
||||
ctx := context.TODO()
|
||||
if exists, _ := m.DB.TableExists(ctx, "telegram_file_old"); exists {
|
||||
exerrors.Must(m.DB.Exec(ctx, `
|
||||
PRAGMA foreign_keys = 'OFF';
|
||||
DROP TABLE telegram_file_old;
|
||||
PRAGMA foreign_key_check;
|
||||
PRAGMA foreign_keys = 'ON';
|
||||
`))
|
||||
}
|
||||
}
|
||||
m.InitVersion(Tag, Commit, BuildTime)
|
||||
m.Run()
|
||||
|
||||
Reference in New Issue
Block a user