diff --git a/store/datastore/ddl/mysql/ddl_gen.go b/store/datastore/ddl/mysql/ddl_gen.go index f3f9efe2d..14f5b85a4 100644 --- a/store/datastore/ddl/mysql/ddl_gen.go +++ b/store/datastore/ddl/mysql/ddl_gen.go @@ -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 @@ -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 +` diff --git a/store/datastore/ddl/mysql/files/014_add_column_repo_seq.sql b/store/datastore/ddl/mysql/files/014_add_column_repo_seq.sql index ed04c9848..a0be87dda 100644 --- a/store/datastore/ddl/mysql/files/014_add_column_repo_seq.sql +++ b/store/datastore/ddl/mysql/files/014_add_column_repo_seq.sql @@ -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 diff --git a/store/datastore/ddl/postgres/ddl_gen.go b/store/datastore/ddl/postgres/ddl_gen.go index a39cebd74..a4d21ff5c 100644 --- a/store/datastore/ddl/postgres/ddl_gen.go +++ b/store/datastore/ddl/postgres/ddl_gen.go @@ -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 @@ -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 +` diff --git a/store/datastore/ddl/postgres/files/014_add_column_repo_seq.sql b/store/datastore/ddl/postgres/files/014_add_column_repo_seq.sql index ed04c9848..a0be87dda 100644 --- a/store/datastore/ddl/postgres/files/014_add_column_repo_seq.sql +++ b/store/datastore/ddl/postgres/files/014_add_column_repo_seq.sql @@ -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 diff --git a/store/datastore/ddl/sqlite/ddl_gen.go b/store/datastore/ddl/sqlite/ddl_gen.go index 5d660ee89..0eeab520a 100644 --- a/store/datastore/ddl/sqlite/ddl_gen.go +++ b/store/datastore/ddl/sqlite/ddl_gen.go @@ -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 @@ -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 +` diff --git a/store/datastore/ddl/sqlite/files/014_add_column_repo_seq.sql b/store/datastore/ddl/sqlite/files/014_add_column_repo_seq.sql index ed04c9848..a0be87dda 100644 --- a/store/datastore/ddl/sqlite/files/014_add_column_repo_seq.sql +++ b/store/datastore/ddl/sqlite/files/014_add_column_repo_seq.sql @@ -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