Commit b3eb33ba authored by Lee Tickett's avatar Lee Tickett Committed by Andreas Brandl

Apply suggestion to...

Apply suggestion to db/migrate/20191114201118_make_created_at_not_null_in_design_management_versions.rb
parent f0bac84d
---
title: Make design_management_versions.created_at not null
merge_request: 20182
author: Lee Tickett
type: other
# frozen_string_literal: true
class MakeCreatedAtNotNullInDesignManagementVersions < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
change_column_null :design_management_versions, :created_at, false, Time.now.to_s(:db)
end
def down
change_column_null :design_management_versions, :created_at, true
end
end
...@@ -1446,7 +1446,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_074328) do ...@@ -1446,7 +1446,7 @@ ActiveRecord::Schema.define(version: 2020_03_03_074328) do
create_table "design_management_versions", force: :cascade do |t| create_table "design_management_versions", force: :cascade do |t|
t.binary "sha", null: false t.binary "sha", null: false
t.bigint "issue_id" t.bigint "issue_id"
t.datetime_with_timezone "created_at" t.datetime_with_timezone "created_at", null: false
t.integer "author_id" t.integer "author_id"
t.index ["author_id"], name: "index_design_management_versions_on_author_id", where: "(author_id IS NOT NULL)" t.index ["author_id"], name: "index_design_management_versions_on_author_id", where: "(author_id IS NOT NULL)"
t.index ["issue_id"], name: "index_design_management_versions_on_issue_id" t.index ["issue_id"], name: "index_design_management_versions_on_issue_id"
......
...@@ -20,7 +20,7 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do ...@@ -20,7 +20,7 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do
def create_version_with_missing_data(attrs = {}) def create_version_with_missing_data(attrs = {})
version = create_version(attrs) version = create_version(attrs)
version.update_columns(author_id: nil, created_at: nil) version.update_columns(author_id: nil)
version version
end end
...@@ -29,19 +29,17 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do ...@@ -29,19 +29,17 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do
commit = issue.project.design_repository.commit(version.sha) commit = issue.project.design_repository.commit(version.sha)
expect(version).to have_attributes( expect(version).to have_attributes(
author_id: nil, author_id: nil
created_at: nil
) )
expect(commit.author.id).to be_present expect(commit.author.id).to be_present
expect(commit.created_at).to be_present
expect { perform_worker }.to( expect { perform_worker }.to(
change do change do
version.reload version.reload
[version.author_id, version.created_at] version.author_id
end end
.from([nil, nil]) .from(nil)
.to([commit.author.id, commit.created_at]) .to(commit.author.id)
) )
end end
...@@ -73,7 +71,7 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do ...@@ -73,7 +71,7 @@ describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do
expect { perform_worker }.not_to( expect { perform_worker }.not_to(
change do change do
version.reload version.reload
[version.author_id, version.created_at] version.author_id
end end
) )
end end
......
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