Skip to content

Commit

Permalink
add migration function to remove null repo counters
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed May 25, 2017
1 parent 62876d6 commit ee54698
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions store/datastore/ddl/mysql/ddl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq,
},
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
}

// Migrate performs the database migration. If the migration fails
Expand Down Expand Up @@ -490,3 +494,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id
)
`

var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`
5 changes: 5 additions & 0 deletions store/datastore/ddl/mysql/files/014_add_column_repo_seq.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds
WHERE builds.build_repo_id = repos.repo_id
)

-- name: update-table-set-repo-seq-default

UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
9 changes: 9 additions & 0 deletions store/datastore/ddl/postgres/ddl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq,
},
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
}

// Migrate performs the database migration. If the migration fails
Expand Down Expand Up @@ -490,3 +494,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id
)
`

var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds
WHERE builds.build_repo_id = repos.repo_id
)

-- name: update-table-set-repo-seq-default

UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
9 changes: 9 additions & 0 deletions store/datastore/ddl/sqlite/ddl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq,
},
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
}

// Migrate performs the database migration. If the migration fails
Expand Down Expand Up @@ -491,3 +495,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id
)
`

var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`
5 changes: 5 additions & 0 deletions store/datastore/ddl/sqlite/files/014_add_column_repo_seq.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds
WHERE builds.build_repo_id = repos.repo_id
)

-- name: update-table-set-repo-seq-default

UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL

0 comments on commit ee54698

Please sign in to comment.