From 669c2c1c28b62ed8c5c91352102d521e22d8ad77 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 28 Feb 2020 17:00:53 +0100 Subject: 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. --- db.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/db.go b/db.go index e38a8eb..f9bed06 100644 --- a/db.go +++ b/db.go @@ -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 -- cgit v1.2.3