now seems to work for the most part

This commit is contained in:
2019-10-27 06:26:07 -07:00
parent e0102004eb
commit b4a7f23815
4 changed files with 43 additions and 16 deletions

View File

@@ -9,12 +9,17 @@ import _ "github.com/lib/pq"
var ormObject orm.Ormer
func Initialize() {
if os.Getenv("DEBUG") != "" {
orm.Debug = true
}
ConnectToDb()
SyncDB()
}
// ConnectToDb - Initializes the ORM and Connection to the postgres DB
func ConnectToDb() {
orm.DefaultTimeLoc = time.UTC
POSTGRES_DB_URL := os.Getenv("POSTGRES_DB_URL")

View File

@@ -3,9 +3,10 @@ package models
import "time"
type Merp struct {
ID int `json:"id" orm:"auto"`
Content string `json:"content" orm:"type(json)"`
Created time.Time `orm:"auto_now_add;type(datetime)"`
RemoteIP string `json:"remoteIP" orm:"size(128)"`
Thing string `json:"thing" orm:"size(128)"`
ID int `json:"id" orm:"auto;column(id)"`
Content string `json:"content" orm:"type(jsonb);column(content)"`
Created time.Time `orm:"auto_now_add;type(datetime);column(created)"`
RemoteIP string `json:"remoteIP" orm:"size(128);column(remoteip)"`
Thing string `json:"thing" orm:"size(256)"`
UUID string `json:"uuid" orm:"size(36);column(uuid)"`
}