Actually gorm:"type:text" was useless

With the Postgres backend, strings will use text by default.
Using varchar(255) by default (which is stupid) is done only for sqlite,
which doesn't care about the type anyways.
This commit is contained in:
Alex 2020-02-28 17:00:53 +01:00
parent eaf245e3ee
commit 669c2c1c28

42
db.go
View file

@ -55,10 +55,10 @@ func InitDb() error {
type DbAccountConfig struct {
gorm.Model
MxUserID string `gorm:"type:text;index"`
Name string `gorm:"type:text"`
Protocol string `gorm:"type:text"`
Config string `gorm:"type:text"`
MxUserID string `gorm:"index"`
Name string
Protocol string
Config string
}
// List of joined channels to be re-joined on reconnect
@ -66,21 +66,21 @@ type DbJoinedRoom struct {
ID uint `gorm:"primary_key"`
// User id and account name
MxUserID string `gorm:"type:text"`
Protocol string `gorm:"type:text"`
AccountName string `gorm:"type:text"`
MxUserID string
Protocol string
AccountName string
// Room ID
RoomID connector.RoomID `gorm:"type:text"`
RoomID connector.RoomID
}
// User mapping between protocol user IDs and puppeted matrix ids
type DbUserMap struct {
ID uint `gorm:"primary_key"`
Protocol string `gorm:"type:text"`
UserID connector.UserID `gorm:"type:text"`
MxUserID string `gorm:"type:text;index"`
Protocol string
UserID connector.UserID
MxUserID string `gorm:"index"`
}
// Room mapping between Matrix rooms and outside rooms
@ -88,13 +88,13 @@ type DbRoomMap struct {
ID uint `gorm:"primary_key"`
// Network protocol
Protocol string `gorm:"type:text"`
Protocol string
// Room id on the bridged network
RoomID connector.RoomID `gorm:"type:text"`
RoomID connector.RoomID
// Bridged room matrix id
MxRoomID string `gorm:"type:text;index"`
MxRoomID string `gorm:"index"`
}
// Room mapping between Matrix rooms and private messages
@ -102,21 +102,21 @@ type DbPmRoomMap struct {
ID uint `gorm:"primary_key"`
// User id and account name of the local end viewed on Matrix
MxUserID string `gorm:"type:text"`
Protocol string `gorm:"type:text"`
AccountName string `gorm:"type:text"`
MxUserID string
Protocol string
AccountName string
// User id to reach them
UserID connector.UserID `gorm:"type:text"`
UserID connector.UserID
// Bridged room for PMs
MxRoomID string `gorm:"type:text;index"`
MxRoomID string `gorm:"index"`
}
// Key-value store for various things
type DbKv struct {
Key string `gorm:"type:text;primary_key"`
Value string `gorm:"type:text"`
Key string `gorm:"primary_key"`
Value string
}
// ---- Simple locking mechanism