diff --git a/CHANGELOG.md b/CHANGELOG.md index dbb47bb8..528abcc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Makefile b/Makefile index eef6defd..fb15772b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/main.go b/cmd/main.go index 9d147cd6..674d3fde 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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")) + } } } diff --git a/dev/docker-compose.db.yml b/dev/docker-compose.db.yml index 6588a813..c76a1254 100644 --- a/dev/docker-compose.db.yml +++ b/dev/docker-compose.db.yml @@ -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 @@ -22,8 +20,6 @@ services: mysql: container_name: mysql image: mysql:5.7 - volumes: - - ../docker/databases/mysql:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: password123 @@ -31,7 +27,7 @@ services: MYSQL_USER: root MYSQL_PASSWORD: password123 ports: - - 3306:3306 + - "127.0.0.1:3306:3306" healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] timeout: 20s @@ -46,7 +42,7 @@ services: mysql: condition: service_healthy ports: - - 5050:80 + - "127.0.0.1:5050:80" links: - mysql:db environment: @@ -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: @@ -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 @@ -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 diff --git a/types/configs/database.go b/types/configs/database.go index 98e1f7eb..60d81eaf 100644 --- a/types/configs/database.go +++ b/types/configs/database.go @@ -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" @@ -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") diff --git a/types/core/struct.go b/types/core/struct.go index 0a04520a..d47108fb 100644 --- a/types/core/struct.go +++ b/types/core/struct.go @@ -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"` @@ -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"` diff --git a/types/failures/samples.go b/types/failures/samples.go index 74cff009..d1535b77 100644 --- a/types/failures/samples.go +++ b/types/failures/samples.go @@ -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 ( diff --git a/types/notifications/struct.go b/types/notifications/struct.go index 17cb1575..83a91f7f 100644 --- a/types/notifications/struct.go +++ b/types/notifications/struct.go @@ -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"` diff --git a/version.txt b/version.txt index 399071fd..708a7d94 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.26 +0.90.27