pull/10/head
Hunter Long 2018-06-23 19:50:14 -07:00
parent 20ca133eb5
commit 13f584e20b
5 changed files with 30 additions and 10 deletions

View File

@ -17,7 +17,8 @@ services:
- mongodb
env:
- VERSION=0.18
global:
- VERSION=0.18
matrix:
allow_failures:

View File

@ -1,17 +1,21 @@
#!/usr/bin/env bash
mkdir build
APP="statup"
printf "\nUPDATE core SET version='$VERSION';" >> sql/upgrade.sql
rice embed-go
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
docker build -f Dockerfile -t hunterlong/statup:$VERSION .
docker tag hunterlong/statup:$VERSION hunterlong/statup:latest
docker tag hunterlong/statup:$VERSION hunterlong/statup:$VERSION
docker push hunterlong/statup
mkdir build
xgo -go 1.10.x --targets=darwin/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=darwin/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=linux/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=linux/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=windows/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
cd build

View File

@ -1,16 +1,16 @@
package main
import (
"fmt"
"github.com/hunterlong/statup/types"
"time"
)
func LoadDefaultCommunications() {
emailer := SelectCommunication(1)
fmt.Println(emailer)
LoadMailer(emailer)
go EmailerQueue()
if emailer.Enabled {
LoadMailer(emailer)
go EmailerQueue()
}
}
func LoadComms() {

View File

@ -147,6 +147,7 @@ func mainProcess() {
if err != nil {
throw(err)
}
RunDatabaseUpgrades()
core, err = SelectCore()
if err != nil {
fmt.Println("Core database was not found, Statup is not setup yet.")

View File

@ -10,6 +10,7 @@ import (
"strconv"
"strings"
"time"
"upper.io/db.v3"
)
type DbConfig struct {
@ -28,6 +29,19 @@ type DbConfig struct {
Error error `yaml:"-"`
}
func RunDatabaseUpgrades() {
fmt.Println("Upgrading Tables...")
upgrade, _ := sqlBox.String("upgrade.sql")
requests := strings.Split(upgrade, ";")
for _, request := range requests {
_, err := dbSession.Exec(db.Raw(request + ";"))
if err != nil {
fmt.Println(err)
}
}
fmt.Println("Database Upgraded")
}
func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
if core != nil {
http.Redirect(w, r, "/", http.StatusSeeOther)