diff options
Diffstat (limited to 'db/migrate/20230915103259_create_ci_finished_build_ch_sync_events.rb')
-rw-r--r-- | db/migrate/20230915103259_create_ci_finished_build_ch_sync_events.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/db/migrate/20230915103259_create_ci_finished_build_ch_sync_events.rb b/db/migrate/20230915103259_create_ci_finished_build_ch_sync_events.rb new file mode 100644 index 00000000000..718fd49f5c0 --- /dev/null +++ b/db/migrate/20230915103259_create_ci_finished_build_ch_sync_events.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreateCiFinishedBuildChSyncEvents < Gitlab::Database::Migration[2.1] + def change + options = { + primary_key: [:build_id, :partition], + options: 'PARTITION BY LIST (partition)' + } + + create_table(:p_ci_finished_build_ch_sync_events, **options) do |t| + # Do not bother with foreign key as it provides not benefit and has a performance cost. These get cleaned up over + # time anyway. + t.bigint :build_id, null: false + t.bigint :partition, null: false, default: 1 + # rubocop: disable Migration/Datetime + # The source for this field does not have a timezone + t.datetime :build_finished_at, null: false + # rubocop: enable Migration/Datetime + t.boolean :processed, null: false, default: false + + t.index '(build_id % 100), build_id', + where: 'processed = FALSE', + name: 'index_ci_finished_build_ch_sync_events_for_partitioned_query' + end + end +end |