Commit b6ad71fc authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ) Committed by Andreas Brandl

Remove outdated ci db columns

Signed-off-by: default avatarDmytro Zaporozhets <dzaporozhets@gitlab.com>
parent 8da5d135
---
title: Remove outdated ci db columns
merge_request: 54564
author:
type: changed
# frozen_string_literal: true
class RemoveDeprecatedCiBuildsColumns < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
with_lock_retries do
remove_column :ci_builds, :artifacts_file
remove_column :ci_builds, :artifacts_file_store
remove_column :ci_builds, :artifacts_metadata
remove_column :ci_builds, :artifacts_metadata_store
remove_column :ci_builds, :artifacts_size
remove_column :ci_builds, :commands
end
end
def down
# rubocop:disable Migration/AddColumnsToWideTables
with_lock_retries do
add_column :ci_builds, :artifacts_file, :text
add_column :ci_builds, :artifacts_file_store, :integer
add_column :ci_builds, :artifacts_metadata, :text
add_column :ci_builds, :artifacts_metadata_store, :integer
add_column :ci_builds, :artifacts_size, :bigint
add_column :ci_builds, :commands, :text
end
# rubocop:enable Migration/AddColumnsToWideTables
add_concurrent_index :ci_builds, :artifacts_expire_at, where: "artifacts_file <> ''::text", name: 'index_ci_builds_on_artifacts_expire_at'
end
end
# frozen_string_literal: true
class RemoveDeprecatedCiRunnerColumn < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
with_lock_retries do
remove_column :ci_runners, :is_shared
end
end
def down
add_column :ci_runners, :is_shared, :boolean, default: false unless column_exists?(:ci_runners, :is_shared)
add_concurrent_index :ci_runners, :is_shared
end
end
b5ff5aeb9cef243165d9c40db7211f61a632edb6a189c09112ef069d267bf64d
\ No newline at end of file
7631c82f9762e643a4da9c03f3870ab1c97fae93da4975219d9ab7cd629720ec
\ No newline at end of file
......@@ -10266,7 +10266,6 @@ CREATE TABLE ci_builds (
runner_id integer,
coverage double precision,
commit_id integer,
commands text,
name character varying,
options text,
allow_failure boolean DEFAULT false NOT NULL,
......@@ -10279,14 +10278,11 @@ CREATE TABLE ci_builds (
type character varying,
target_url character varying,
description character varying,
artifacts_file text,
project_id integer,
artifacts_metadata text,
erased_by_id integer,
erased_at timestamp without time zone,
artifacts_expire_at timestamp without time zone,
environment character varying,
artifacts_size bigint,
"when" character varying,
yaml_variables text,
queued_at timestamp without time zone,
......@@ -10296,8 +10292,6 @@ CREATE TABLE ci_builds (
auto_canceled_by_id integer,
retried boolean,
stage_id integer,
artifacts_file_store integer,
artifacts_metadata_store integer,
protected boolean,
failure_reason integer,
scheduled_at timestamp with time zone,
......@@ -10832,7 +10826,6 @@ CREATE TABLE ci_runners (
description character varying,
contacted_at timestamp without time zone,
active boolean DEFAULT true NOT NULL,
is_shared boolean DEFAULT false,
name character varying,
version character varying,
revision character varying,
......@@ -21752,8 +21745,6 @@ CREATE INDEX index_ci_builds_metadata_on_build_id_and_id_and_interruptible ON ci
CREATE INDEX index_ci_builds_metadata_on_project_id ON ci_builds_metadata USING btree (project_id);
CREATE INDEX index_ci_builds_on_artifacts_expire_at ON ci_builds USING btree (artifacts_expire_at) WHERE (artifacts_file <> ''::text);
CREATE INDEX index_ci_builds_on_auto_canceled_by_id ON ci_builds USING btree (auto_canceled_by_id);
CREATE INDEX index_ci_builds_on_commit_id_and_stage_idx_and_created_at ON ci_builds USING btree (commit_id, stage_idx, created_at);
......@@ -21916,8 +21907,6 @@ CREATE INDEX index_ci_runner_projects_on_runner_id ON ci_runner_projects USING b
CREATE INDEX index_ci_runners_on_contacted_at ON ci_runners USING btree (contacted_at);
CREATE INDEX index_ci_runners_on_is_shared ON ci_runners USING btree (is_shared);
CREATE INDEX index_ci_runners_on_locked ON ci_runners USING btree (locked);
CREATE INDEX index_ci_runners_on_runner_type ON ci_runners USING btree (runner_type);
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts do
RSpec.describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, schema: 20210210093901 do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment