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:
Tulir Asokan
2024-09-02 20:21:59 +03:00
committed by GitHub
parent 60fe2e07c2
commit afd9850c4b
2 changed files with 12 additions and 0 deletions

View File

@@ -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;

View File

@@ -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()