Commit 42878184 authored by Thong Kuah's avatar Thong Kuah

Merge branch '330839-add-note-to-timelogs' into 'master'

Add summary column to timelogs table

See merge request gitlab-org/gitlab!64552
parents f420a487 3f649999
...@@ -6,6 +6,7 @@ class Timelog < ApplicationRecord ...@@ -6,6 +6,7 @@ class Timelog < ApplicationRecord
before_save :set_project before_save :set_project
validates :time_spent, :user, presence: true validates :time_spent, :user, presence: true
validates :summary, length: { maximum: 255 }
validate :issuable_id_is_present, unless: :importing? validate :issuable_id_is_present, unless: :importing?
belongs_to :issue, touch: true belongs_to :issue, touch: true
......
# frozen_string_literal: true
class AddSummaryToTimelogs < ActiveRecord::Migration[6.1]
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20210621090030_add_text_limit_to_timelogs_summary
def change
add_column :timelogs, :summary, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end
# frozen_string_literal: true
class AddTextLimitToTimelogsSummary < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_text_limit :timelogs, :summary, 255
end
def down
remove_text_limit :timelogs, :summary
end
end
fb5b54e29400836afb122cd38a2ae34abc1ff6dd800eadaba023220c51da6868
\ No newline at end of file
5077a5c9cfe9b79506bb65d9dd02b745545a8586c198041bf7cbb945827c07cf
\ No newline at end of file
...@@ -18470,7 +18470,9 @@ CREATE TABLE timelogs ( ...@@ -18470,7 +18470,9 @@ CREATE TABLE timelogs (
merge_request_id integer, merge_request_id integer,
spent_at timestamp without time zone, spent_at timestamp without time zone,
note_id integer, note_id integer,
project_id integer project_id integer,
summary text,
CONSTRAINT check_271d321699 CHECK ((char_length(summary) <= 255))
); );
CREATE SEQUENCE timelogs_id_seq CREATE SEQUENCE timelogs_id_seq
...@@ -645,6 +645,7 @@ Timelog: ...@@ -645,6 +645,7 @@ Timelog:
- spent_at - spent_at
- created_at - created_at
- updated_at - updated_at
- summary
ProjectAutoDevops: ProjectAutoDevops:
- id - id
- enabled - enabled
......
...@@ -17,6 +17,8 @@ RSpec.describe Timelog do ...@@ -17,6 +17,8 @@ RSpec.describe Timelog do
it { is_expected.to validate_presence_of(:time_spent) } it { is_expected.to validate_presence_of(:time_spent) }
it { is_expected.to validate_presence_of(:user) } it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_length_of(:summary).is_at_most(255) }
it { expect(subject.project_id).not_to be_nil } it { expect(subject.project_id).not_to be_nil }
describe 'Issuable validation' do describe 'Issuable validation' do
......
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