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 portal_old;
|
||||||
DROP TABLE puppet_old;
|
DROP TABLE puppet_old;
|
||||||
DROP TABLE user_old;
|
DROP TABLE user_old;
|
||||||
|
-- only: postgres (this is deleted separately for sqlite)
|
||||||
DROP TABLE telegram_file_old;
|
DROP TABLE telegram_file_old;
|
||||||
DROP TABLE telethon_entities_old;
|
DROP TABLE telethon_entities_old;
|
||||||
DROP TABLE telethon_sent_files_old;
|
DROP TABLE telethon_sent_files_old;
|
||||||
|
|||||||
@@ -17,12 +17,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.mau.fi/util/dbutil/litestream"
|
"go.mau.fi/util/dbutil/litestream"
|
||||||
|
"go.mau.fi/util/exerrors"
|
||||||
"maunium.net/go/mautrix/bridgev2/bridgeconfig"
|
"maunium.net/go/mautrix/bridgev2/bridgeconfig"
|
||||||
"maunium.net/go/mautrix/bridgev2/matrix/mxmain"
|
"maunium.net/go/mautrix/bridgev2/matrix/mxmain"
|
||||||
|
|
||||||
@@ -102,6 +104,15 @@ func main() {
|
|||||||
),
|
),
|
||||||
true,
|
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.InitVersion(Tag, Commit, BuildTime)
|
||||||
m.Run()
|
m.Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user