Migrating ci_builds data to ci_artifacts

Artifacts will get their own table, and data needs to be moved from the ci_builds table.

Artifacts will have:

  • id (primary key, auto increment)
  • project_id
  • build_id
  • size, integer, limit: 8
  • type (integer, enum, to differentiate between archive/metadata/trace)
  • created_at
  • updated_at
  • erased_at
  • erased_by_id
  • expire_at
  • file (text, carrierwave will mount this)
    • is either artifacts_file or the artifacts_metadata column
    • Trace is added later, but we might claim the ids already?

All these columns, expect the id, come from ci_builds. To move this data we have a few options:

  1. Usual way:
  • Create table with all columns
  • Add indexes and FKs
  • Migrate data to there using INSERT INTO
  1. CREATE TABLE AS
  • Migrate and create in one go
  • create primary key column and set all ids
  1. Copy the whole table
  • Seems overkill, as there is much data we really dont need
  1. Please make suggestions in the notes

Now, what we'd like, is to be able to sort on the id so we know it maps to the build_id so we know that a low ID is created before each higher id. Thinking about this a bit more, I wonder how realistic this really is, but it would be nice as else me might need another index on this column.

/cc @yorickpeterse @ayufan @grzesiek

Edited Aug 30, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading