Replace VARCHAR(255) with TEXT in Matrix state store

This commit is contained in:
Tulir Asokan 2021-10-30 23:31:49 +03:00
parent 5b5cbc2efa
commit f3d6bbbc4a
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,22 @@
package upgrades
import (
"database/sql"
)
func init() {
upgrades[29] = upgrade{"Replace VARCHAR(255) with TEXT in the Matrix state store", func(tx *sql.Tx, ctx context) error {
if ctx.dialect == SQLite {
// SQLite doesn't enforce varchar sizes anyway
return nil
}
return execMany(tx,
`ALTER TABLE mx_registrations ALTER COLUMN user_id TYPE TEXT`,
`ALTER TABLE mx_room_state ALTER COLUMN room_id TYPE TEXT`,
`ALTER TABLE mx_user_profile ALTER COLUMN room_id TYPE TEXT`,
`ALTER TABLE mx_user_profile ALTER COLUMN user_id TYPE TEXT`,
`ALTER TABLE mx_user_profile ALTER COLUMN membership TYPE TEXT`,
`ALTER TABLE mx_user_profile ALTER COLUMN avatar_url TYPE TEXT`,
)
}}
}

View file

@ -39,7 +39,7 @@ type upgrade struct {
fn upgradeFunc
}
const NumberOfUpgrades = 29
const NumberOfUpgrades = 30
var upgrades [NumberOfUpgrades]upgrade