Made the postgres connection be tested before opening, fixed the postgres create new users table
Signed-off-by: Arzumify <jliwin98@danwin1210.de>
This commit is contained in:
parent
4fe28255fe
commit
58838f51ad
33
main.go
33
main.go
|
@ -171,16 +171,29 @@ func processInterServiceMessage(channel chan library.InterServiceMessage, config
|
||||||
Message: err,
|
Message: err,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Report a successful activation
|
// Test the connection
|
||||||
services[message.ServiceID].Inbox <- library.InterServiceMessage{
|
err = pluginConn.Ping()
|
||||||
ServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000001"),
|
if err != nil {
|
||||||
ForServiceID: message.ServiceID,
|
// Report an error
|
||||||
MessageType: 2,
|
services[message.ServiceID].Inbox <- library.InterServiceMessage{
|
||||||
SentAt: time.Now(),
|
ServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000001"),
|
||||||
Message: library.Database{
|
ForServiceID: message.ServiceID,
|
||||||
DB: pluginConn,
|
MessageType: 1,
|
||||||
DBType: library.Postgres,
|
SentAt: time.Now(),
|
||||||
},
|
Message: err,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Report a successful activation
|
||||||
|
services[message.ServiceID].Inbox <- library.InterServiceMessage{
|
||||||
|
ServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000001"),
|
||||||
|
ForServiceID: message.ServiceID,
|
||||||
|
MessageType: 2,
|
||||||
|
SentAt: time.Now(),
|
||||||
|
Message: library.Database{
|
||||||
|
DB: pluginConn,
|
||||||
|
DBType: library.Postgres,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ func Main(information library.ServiceInitializationInformation) {
|
||||||
logFunc(err.Error(), 3, information)
|
logFunc(err.Error(), 3, information)
|
||||||
}
|
}
|
||||||
// Create the users table
|
// Create the users table
|
||||||
_, err = conn.DB.Exec("CREATE TABLE IF NOT EXISTS users (id BYTEA PRIMARY KEY NOT NULL UNIQUE, created INTEGER NOT NULL, username TEXT NOT NULL UNIQUE, password BYTEA NOT NULL, salt BYTEA NOT NULL)")
|
_, err = conn.DB.Exec("CREATE TABLE IF NOT EXISTS users (id BYTEA PRIMARY KEY NOT NULL UNIQUE, created INTEGER NOT NULL, username TEXT NOT NULL UNIQUE, publicKey BYTEA NOT NULL)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logFunc(err.Error(), 3, information)
|
logFunc(err.Error(), 3, information)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue