add migration function to remove null repo counters

This commit is contained in:
Brad Rydzewski 2017-05-25 12:25:16 +02:00
parent 62876d6ad9
commit ee54698c62
6 changed files with 42 additions and 0 deletions

View file

@ -104,6 +104,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq", name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq, stmt: updateTableSetRepoSeq,
}, },
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
} }
// Migrate performs the database migration. If the migration fails // Migrate performs the database migration. If the migration fails
@ -490,3 +494,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id WHERE builds.build_repo_id = repos.repo_id
) )
` `
var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`

View file

@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds FROM builds
WHERE builds.build_repo_id = repos.repo_id 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

View file

@ -104,6 +104,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq", name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq, stmt: updateTableSetRepoSeq,
}, },
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
} }
// Migrate performs the database migration. If the migration fails // Migrate performs the database migration. If the migration fails
@ -490,3 +494,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id WHERE builds.build_repo_id = repos.repo_id
) )
` `
var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`

View file

@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds FROM builds
WHERE builds.build_repo_id = repos.repo_id 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

View file

@ -108,6 +108,10 @@ var migrations = []struct {
name: "update-table-set-repo-seq", name: "update-table-set-repo-seq",
stmt: updateTableSetRepoSeq, stmt: updateTableSetRepoSeq,
}, },
{
name: "update-table-set-repo-seq-default",
stmt: updateTableSetRepoSeqDefault,
},
} }
// Migrate performs the database migration. If the migration fails // Migrate performs the database migration. If the migration fails
@ -491,3 +495,8 @@ UPDATE repos SET repo_counter = (
WHERE builds.build_repo_id = repos.repo_id WHERE builds.build_repo_id = repos.repo_id
) )
` `
var updateTableSetRepoSeqDefault = `
UPDATE repos SET repo_counter = 0
WHERE repo_counter IS NULL
`

View file

@ -9,3 +9,8 @@ UPDATE repos SET repo_counter = (
FROM builds FROM builds
WHERE builds.build_repo_id = repos.repo_id 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