Merge pull request 'Ajouter seed automatique de la base de données' (#23) from feature/autoseed into main
Reviewed-on: #23
This commit is contained in:
commit
ea15efb7e4
2 changed files with 6 additions and 2 deletions
|
@ -81,11 +81,15 @@ var apiCmd = &cobra.Command{
|
||||||
defer dataClient.DB.Close()
|
defer dataClient.DB.Close()
|
||||||
|
|
||||||
if err := dataClient.DB.Ping(); err != nil {
|
if err := dataClient.DB.Ping(); err != nil {
|
||||||
log.Fatalf("[bottin-agenda db] dataClient.DB.Ping(): %s", err)
|
log.Fatalf("[bottin-agenda db] dataClient.DB.Ping() failed: %s", err)
|
||||||
} else {
|
} else {
|
||||||
log.Println("[bottin-agenda db] ok")
|
log.Println("[bottin-agenda db] ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err = dataClient.Seed(); err != nil {
|
||||||
|
log.Fatalf("[bottin-agenda db] dataClient.Seed() failed: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Execution
|
// Execution
|
||||||
|
|
||||||
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", apiPort)))
|
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", apiPort)))
|
||||||
|
|
|
@ -3,7 +3,7 @@ package models
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
var Schema = `
|
var Schema = `
|
||||||
CREATE TABLE transactions (
|
CREATE TABLE IF NOT EXISTS transactions (
|
||||||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||||
membre_id VARCHAR(7),
|
membre_id VARCHAR(7),
|
||||||
given_at TIMESTAMP,
|
given_at TIMESTAMP,
|
||||||
|
|
Loading…
Reference in a new issue