From 284fca370e99175d820f252805953d0cf1f6397c Mon Sep 17 00:00:00 2001 From: Vaidas Jablonskis Date: Tue, 18 Oct 2016 16:45:15 +0100 Subject: [PATCH] Add a reference to parent build on forks / deploys --- model/build.go | 1 + server/build.go | 1 + store/datastore/ddl/mysql/8.sql | 7 +++++++ store/datastore/ddl/postgres/8.sql | 7 +++++++ store/datastore/ddl/sqlite3/8.sql | 7 +++++++ 5 files changed, 23 insertions(+) create mode 100644 store/datastore/ddl/mysql/8.sql create mode 100644 store/datastore/ddl/postgres/8.sql create mode 100644 store/datastore/ddl/sqlite3/8.sql diff --git a/model/build.go b/model/build.go index 2b06763b..de214a03 100644 --- a/model/build.go +++ b/model/build.go @@ -5,6 +5,7 @@ type Build struct { ID int64 `json:"id" meddler:"build_id,pk"` RepoID int64 `json:"-" meddler:"build_repo_id"` Number int `json:"number" meddler:"build_number"` + Parent int `json:"parent" meddler:"build_parent"` Event string `json:"event" meddler:"build_event"` Status string `json:"status" meddler:"build_status"` Enqueued int64 `json:"enqueued_at" meddler:"build_enqueued"` diff --git a/server/build.go b/server/build.go index b7f805cd..391688b5 100644 --- a/server/build.go +++ b/server/build.go @@ -228,6 +228,7 @@ func PostBuild(c *gin.Context) { if forkit, _ := strconv.ParseBool(fork); forkit { build.ID = 0 build.Number = 0 + build.Parent = num for _, job := range jobs { job.ID = 0 job.NodeID = 0 diff --git a/store/datastore/ddl/mysql/8.sql b/store/datastore/ddl/mysql/8.sql new file mode 100644 index 00000000..ad6759b2 --- /dev/null +++ b/store/datastore/ddl/mysql/8.sql @@ -0,0 +1,7 @@ +-- +migrate Up + +ALTER TABLE builds ADD COLUMN build_parent INTEGER DEFAULT 0; + +-- +migrate Down + +ALTER TABLE builds DROP COLUMN build_parent; diff --git a/store/datastore/ddl/postgres/8.sql b/store/datastore/ddl/postgres/8.sql new file mode 100644 index 00000000..ad6759b2 --- /dev/null +++ b/store/datastore/ddl/postgres/8.sql @@ -0,0 +1,7 @@ +-- +migrate Up + +ALTER TABLE builds ADD COLUMN build_parent INTEGER DEFAULT 0; + +-- +migrate Down + +ALTER TABLE builds DROP COLUMN build_parent; diff --git a/store/datastore/ddl/sqlite3/8.sql b/store/datastore/ddl/sqlite3/8.sql new file mode 100644 index 00000000..ad6759b2 --- /dev/null +++ b/store/datastore/ddl/sqlite3/8.sql @@ -0,0 +1,7 @@ +-- +migrate Up + +ALTER TABLE builds ADD COLUMN build_parent INTEGER DEFAULT 0; + +-- +migrate Down + +ALTER TABLE builds DROP COLUMN build_parent;