Skip to content

Commit

Permalink
postgres issue fixed, SAMPLE_DATA env
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Apr 15, 2020
1 parent 5743dd9 commit 428a840
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.90.27 (04-15-2020)
- Fixed postgres database table creation process
- Modified go build process, additional ARCHs
- Added 'SAMPLE_DATA' environment variable to disable example data on startup. (default: true)

# 0.90.26 (04-13-2020)
- Fixed Delete Failures button/function
- Removed timezone field from Settings (core)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ db-up:
docker-compose -f dev/docker-compose.db.yml up -d --remove-orphans

db-down:
docker-compose -f dev/docker-compose.full.yml down --remove-orphans
docker-compose -f dev/docker-compose.db.yml down --volumes --remove-orphans

console:
docker exec -t -i statping /bin/sh
Expand Down
6 changes: 4 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ func main() {
exit(errors.Wrap(err, "error creating default admin user"))
}

if err := configs.TriggerSamples(); err != nil {
exit(errors.Wrap(err, "error creating database"))
if utils.Getenv("SAMPLE_DATA", true).(bool) {
if err := configs.TriggerSamples(); err != nil {
exit(errors.Wrap(err, "error creating database"))
}
}

}
Expand Down
19 changes: 6 additions & 13 deletions dev/docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ services:
postgres:
container_name: postgres
image: postgres
volumes:
- ../docker/databases/postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password123
POSTGRES_DB: statping
POSTGRES_USER: root
ports:
- 5432:5432
- "127.0.0.1:5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U root"]
interval: 15s
Expand All @@ -22,16 +20,14 @@ services:
mysql:
container_name: mysql
image: mysql:5.7
volumes:
- ../docker/databases/mysql:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password123
MYSQL_DATABASE: statping
MYSQL_USER: root
MYSQL_PASSWORD: password123
ports:
- 3306:3306
- "127.0.0.1:3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
Expand All @@ -46,7 +42,7 @@ services:
mysql:
condition: service_healthy
ports:
- 5050:80
- "127.0.0.1:5050:80"
links:
- mysql:db
environment:
Expand All @@ -62,7 +58,7 @@ services:
restart: on-failure
command: sqlite_web -H 0.0.0.0 -r -x /data/statping.db
ports:
- 6050:8080
- "127.0.0.1:6050:8080"
volumes:
- ../docker/statping/sqlite/statping.db:/data/statping.db:ro
environment:
Expand All @@ -75,11 +71,8 @@ services:
environment:
DEFAULT_USER: admin@admin.com
DEFAULT_PASSWORD: admin
depends_on:
postgres:
condition: service_healthy
ports:
- 7000:5050
- "127.0.0.1:7000:5050"
links:
- postgres:postgres

Expand All @@ -91,7 +84,7 @@ services:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- ../docker/databases/prometheus:/prometheus
ports:
- 7050:9090
- "127.0.0.1:7050:9090"
healthcheck:
test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1"
interval: 10s
Expand Down
6 changes: 4 additions & 2 deletions types/configs/database.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package configs

import (
"fmt"
"github.com/pkg/errors"
"github.com/statping/statping/database"
"github.com/statping/statping/types/checkins"
"github.com/statping/statping/types/core"
Expand Down Expand Up @@ -101,11 +103,11 @@ func (d *DbConfig) CreateDatabase() error {
log.Infoln("Creating Database Tables...")
for _, table := range DbModels {
if err := d.Db.CreateTable(table); err.Error() != nil {
return err.Error()
return errors.Wrap(err.Error(), fmt.Sprintf("error creating '%T' table", table))
}
}
if err := d.Db.Table("core").CreateTable(&core.Core{}); err.Error() != nil {
return err.Error()
return errors.Wrap(err.Error(), fmt.Sprintf("error creating 'core' table"))
}
log.Infoln("Statping Database Created")

Expand Down
4 changes: 2 additions & 2 deletions types/core/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Core struct {
UseCdn null.NullBool `gorm:"column:use_cdn;default:false" json:"using_cdn,omitempty"`
LoggedIn bool `gorm:"-" json:"logged_in"`
IsAdmin bool `gorm:"-" json:"admin"`
AllowReports null.NullBool `gorm:"column:allow_reports;default:false" json:"allow_reports"`
AllowReports null.NullBool `gorm:"column:allow_reports;default:false" json:"allow_reports,omitempty"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
Started time.Time `gorm:"-" json:"started_on"`
Expand All @@ -46,7 +46,7 @@ type Core struct {

type OAuth struct {
Domains string `gorm:"column:oauth_domains" json:"oauth_domains,omitempty" scope:"admin"`
Providers string `gorm:"column:oauth_providers;default:local" json:"oauth_providers,omitempty"`
Providers string `gorm:"column:oauth_providers;" json:"oauth_providers,omitempty"`
GithubClientID string `gorm:"column:gh_client_id" json:"gh_client_id,omitempty" scope:"admin"`
GithubClientSecret string `gorm:"column:gh_client_secret" json:"gh_client_secret,omitempty" scope:"admin"`
GoogleClientID string `gorm:"column:google_client_id" json:"google_client_id,omitempty" scope:"admin"`
Expand Down
4 changes: 0 additions & 4 deletions types/failures/samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import (
"github.com/statping/statping/types"
"github.com/statping/statping/utils"
"time"

_ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/mattn/go-sqlite3"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion types/notifications/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Notification struct {
Var2 string `gorm:"not null;column:var2" json:"var2,omitempty"`
ApiKey string `gorm:"not null;column:api_key" json:"api_key,omitempty"`
ApiSecret string `gorm:"not null;column:api_secret" json:"api_secret,omitempty"`
Enabled null.NullBool `gorm:"column:enabled;type:boolean;default:false" json:"enabled"`
Enabled null.NullBool `gorm:"column:enabled;type:boolean;default:false" json:"enabled,omitempty"`
Limits int `gorm:"not null;column:limits" json:"limits"`
Removable bool `gorm:"column:removable" json:"removable"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.90.26
0.90.27

0 comments on commit 428a840

Please sign in to comment.