From 2d3de9740c0a41d056b381ef52959f2f3eb5fc3a Mon Sep 17 00:00:00 2001 From: Dominic Renner Date: Wed, 6 Mar 2019 22:26:55 +0100 Subject: [PATCH] Update user.go --- database/user.go | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/database/user.go b/database/user.go index 919f32b..988acc2 100644 --- a/database/user.go +++ b/database/user.go @@ -34,19 +34,35 @@ type UserQuery struct { } func (uq *UserQuery) CreateTable(dbType string) error { - _, err := uq.db.Exec(`CREATE TABLE IF NOT EXISTS whatsapp_user ( - mxid VARCHAR(255) PRIMARY KEY, - jid VARCHAR(255) UNIQUE, + if strings.ToLower(dbType) == "postgres" { + _, err := uq.db.Exec(`CREATE TABLE IF NOT EXISTS whatsapp_user ( + mxid VARCHAR(255) PRIMARY KEY, + jid VARCHAR(255) UNIQUE, - management_room VARCHAR(255), + management_room VARCHAR(255), - client_id VARCHAR(255), - client_token VARCHAR(255), - server_token VARCHAR(255), - enc_key bytea, - mac_key bytea - )`) - return err + client_id VARCHAR(255), + client_token VARCHAR(255), + server_token VARCHAR(255), + enc_key bytea, + mac_key bytea + )`) + 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 {