diff --git a/store/datastore/ddl/mysql/files/013_add_column_repo_seq.sql b/store/datastore/ddl/mysql/files/013_add_column_repo_seq.sql new file mode 100644 index 00000000..ed04c984 --- /dev/null +++ b/store/datastore/ddl/mysql/files/013_add_column_repo_seq.sql @@ -0,0 +1,11 @@ +-- name: alter-table-add-repo-seq + +ALTER TABLE repos ADD COLUMN repo_counter INTEGER; + +-- name: update-table-set-repo-seq + +UPDATE repos SET repo_counter = ( + SELECT max(build_number) + FROM builds + WHERE builds.build_repo_id = repos.repo_id +) diff --git a/store/datastore/ddl/postgres/files/013_add_column_repo_seq.sql b/store/datastore/ddl/postgres/files/013_add_column_repo_seq.sql new file mode 100644 index 00000000..ed04c984 --- /dev/null +++ b/store/datastore/ddl/postgres/files/013_add_column_repo_seq.sql @@ -0,0 +1,11 @@ +-- name: alter-table-add-repo-seq + +ALTER TABLE repos ADD COLUMN repo_counter INTEGER; + +-- name: update-table-set-repo-seq + +UPDATE repos SET repo_counter = ( + SELECT max(build_number) + FROM builds + WHERE builds.build_repo_id = repos.repo_id +)