add visibility database field
This commit is contained in:
parent
cedc0517bf
commit
c64a244c27
7 changed files with 108 additions and 2 deletions
|
@ -22,6 +22,7 @@ type Repo struct {
|
|||
Clone string `json:"clone_url,omitempty" meddler:"repo_clone"`
|
||||
Branch string `json:"default_branch,omitempty" meddler:"repo_branch"`
|
||||
Timeout int64 `json:"timeout,omitempty" meddler:"repo_timeout"`
|
||||
Visibility string `json:"visibility" meddler:"repo_visibility"`
|
||||
IsPrivate bool `json:"private,omitempty" meddler:"repo_private"`
|
||||
IsTrusted bool `json:"trusted" meddler:"repo_trusted"`
|
||||
IsStarred bool `json:"starred,omitempty" meddler:"-"`
|
||||
|
|
|
@ -88,6 +88,14 @@ var migrations = []struct {
|
|||
name: "create-index-sender-repos",
|
||||
stmt: createIndexSenderRepos,
|
||||
},
|
||||
{
|
||||
name: "alter-table-add-repo-visibility",
|
||||
stmt: alterTableAddRepoVisibility,
|
||||
},
|
||||
{
|
||||
name: "update-table-set-repo-visibility",
|
||||
stmt: updateTableSetRepoVisibility,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -442,3 +450,19 @@ CREATE TABLE IF NOT EXISTS senders (
|
|||
var createIndexSenderRepos = `
|
||||
CREATE INDEX sender_repo_ix ON senders (sender_repo_id);
|
||||
`
|
||||
|
||||
//
|
||||
// 013_add_column_repo_visibility.sql
|
||||
//
|
||||
|
||||
var alterTableAddRepoVisibility = `
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
`
|
||||
|
||||
var updateTableSetRepoVisibility = `
|
||||
UPDATE repos
|
||||
SET repo_visibility = CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END
|
||||
`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
-- name: alter-table-add-repo-visibility
|
||||
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
|
||||
-- name: update-table-set-repo-visibility
|
||||
|
||||
UPDATE repos
|
||||
SET repo_visibility = CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END
|
|
@ -88,6 +88,14 @@ var migrations = []struct {
|
|||
name: "create-index-sender-repos",
|
||||
stmt: createIndexSenderRepos,
|
||||
},
|
||||
{
|
||||
name: "alter-table-add-repo-visibility",
|
||||
stmt: alterTableAddRepoVisibility,
|
||||
},
|
||||
{
|
||||
name: "update-table-set-repo-visibility",
|
||||
stmt: updateTableSetRepoVisibility,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -150,7 +158,7 @@ func selectCompleted(db *sql.DB) (map[string]struct{}, error) {
|
|||
|
||||
var migrationTableCreate = `
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
name VARCHAR(512)
|
||||
name VARCHAR(255)
|
||||
,UNIQUE(name)
|
||||
)
|
||||
`
|
||||
|
@ -442,3 +450,19 @@ CREATE TABLE IF NOT EXISTS senders (
|
|||
var createIndexSenderRepos = `
|
||||
CREATE INDEX IF NOT EXISTS sender_repo_ix ON senders (sender_repo_id);
|
||||
`
|
||||
|
||||
//
|
||||
// 013_add_column_repo_visibility.sql
|
||||
//
|
||||
|
||||
var alterTableAddRepoVisibility = `
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
`
|
||||
|
||||
var updateTableSetRepoVisibility = `
|
||||
UPDATE repos
|
||||
SET repo_visibility = (CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END)
|
||||
`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
-- name: alter-table-add-repo-visibility
|
||||
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
|
||||
-- name: update-table-set-repo-visibility
|
||||
|
||||
UPDATE repos
|
||||
SET repo_visibility = (CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END)
|
|
@ -92,6 +92,14 @@ var migrations = []struct {
|
|||
name: "create-index-sender-repos",
|
||||
stmt: createIndexSenderRepos,
|
||||
},
|
||||
{
|
||||
name: "alter-table-add-repo-visibility",
|
||||
stmt: alterTableAddRepoVisibility,
|
||||
},
|
||||
{
|
||||
name: "update-table-set-repo-visibility",
|
||||
stmt: updateTableSetRepoVisibility,
|
||||
},
|
||||
}
|
||||
|
||||
// Migrate performs the database migration. If the migration fails
|
||||
|
@ -154,7 +162,7 @@ func selectCompleted(db *sql.DB) (map[string]struct{}, error) {
|
|||
|
||||
var migrationTableCreate = `
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
name VARCHAR(512)
|
||||
name VARCHAR(255)
|
||||
,UNIQUE(name)
|
||||
)
|
||||
`
|
||||
|
@ -443,3 +451,19 @@ CREATE TABLE IF NOT EXISTS senders (
|
|||
var createIndexSenderRepos = `
|
||||
CREATE INDEX IF NOT EXISTS sender_repo_ix ON senders (sender_repo_id);
|
||||
`
|
||||
|
||||
//
|
||||
// 013_add_column_repo_visibility.sql
|
||||
//
|
||||
|
||||
var alterTableAddRepoVisibility = `
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
`
|
||||
|
||||
var updateTableSetRepoVisibility = `
|
||||
UPDATE repos
|
||||
SET repo_visibility = CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END
|
||||
`
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
-- name: alter-table-add-repo-visibility
|
||||
|
||||
ALTER TABLE repos ADD COLUMN repo_visibility INTEGER
|
||||
|
||||
-- name: update-table-set-repo-visibility
|
||||
|
||||
UPDATE repos
|
||||
SET repo_visibility = CASE
|
||||
WHEN repo_private = 0 THEN 'public'
|
||||
ELSE 'private'
|
||||
END
|
Loading…
Reference in a new issue