Update user.go

This commit is contained in:
Dominic Renner 2019-03-06 22:26:55 +01:00 committed by GitHub
parent 539699ba04
commit 2d3de9740c

View file

@ -34,19 +34,35 @@ type UserQuery struct {
} }
func (uq *UserQuery) CreateTable(dbType string) error { func (uq *UserQuery) CreateTable(dbType string) error {
_, err := uq.db.Exec(`CREATE TABLE IF NOT EXISTS whatsapp_user ( if strings.ToLower(dbType) == "postgres" {
mxid VARCHAR(255) PRIMARY KEY, _, err := uq.db.Exec(`CREATE TABLE IF NOT EXISTS whatsapp_user (
jid VARCHAR(255) UNIQUE, mxid VARCHAR(255) PRIMARY KEY,
jid VARCHAR(255) UNIQUE,
management_room VARCHAR(255), management_room VARCHAR(255),
client_id VARCHAR(255), client_id VARCHAR(255),
client_token VARCHAR(255), client_token VARCHAR(255),
server_token VARCHAR(255), server_token VARCHAR(255),
enc_key bytea, enc_key bytea,
mac_key bytea mac_key bytea
)`) )`)
return err return err
} else {
_, err := uq.db.Exec(`CREATE TABLE IF NOT EXISTS whatsapp_user (
mxid VARCHAR(255) PRIMARY KEY,
jid VARCHAR(255) UNIQUE,
management_room VARCHAR(255),
client_id VARCHAR(255),
client_token VARCHAR(255),
server_token VARCHAR(255),
enc_key BLOB,
mac_key BLOB
)`)
return err
}
} }
func (uq *UserQuery) New() *User { func (uq *UserQuery) New() *User {