Add basic Matrix puppeting support

May contain bugs.
EDUs from /sync are not yet handled.
This commit is contained in:
Tulir Asokan
2019-05-24 02:33:26 +03:00
parent 95e62fae77
commit 2c9c473040
14 changed files with 379 additions and 55 deletions

View File

@ -22,7 +22,9 @@ type upgrade struct {
fn upgradeFunc
}
var upgrades [5]upgrade
const NumberOfUpgrades = 6
var upgrades [NumberOfUpgrades]upgrade
func getVersion(dialect Dialect, db *sql.DB) (int, error) {
_, err := db.Exec("CREATE TABLE IF NOT EXISTS version (version INTEGER)")
@ -63,7 +65,7 @@ func Run(log log.Logger, dialectName string, db *sql.DB) error {
return err
}
log.Infofln("Database currently on v%d, latest: v%d", version, len(upgrades))
log.Infofln("Database currently on v%d, latest: v%d", version, NumberOfUpgrades)
for i, upgrade := range upgrades[version:] {
log.Infofln("Upgrading database to v%d: %s", version+i+1, upgrade.message)
tx, err := db.Begin()