Commit 3f649999 authored by Lee Tickett's avatar Lee Tickett

Add summary to timelogs

We currently reference the note_id when a timelog is added via a
quick action, but there is a desire to be able to add a summary
"note" to the timelog itself.

This introduces the database field for us to build the backend.

Changelog: added
parent 0b27fd04
......@@ -6,6 +6,7 @@ class Timelog < ApplicationRecord
before_save :set_project
validates :time_spent, :user, presence: true
validates :summary, length: { maximum: 255 }
validate :issuable_id_is_present, unless: :importing?
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
......@@ -18394,7 +18394,9 @@ CREATE TABLE timelogs (
merge_request_id integer,
spent_at timestamp without time zone,
note_id integer,
project_id integer
project_id integer,
summary text,
CONSTRAINT check_271d321699 CHECK ((char_length(summary) <= 255))
);
CREATE SEQUENCE timelogs_id_seq
......@@ -645,6 +645,7 @@ Timelog:
- spent_at
- created_at
- updated_at
- summary
ProjectAutoDevops:
- id
- enabled
......
......@@ -17,6 +17,8 @@ RSpec.describe Timelog do
it { is_expected.to validate_presence_of(:time_spent) }
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 }
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