Skip to content

Commit

Permalink
Make LabelTemplate's name and color required
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Aug 2, 2024
1 parent 4c485ff commit c611b2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/api/app/models/label_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class LabelTemplate < ApplicationRecord
#### Scopes (first the default_scope macro if is used)

#### Validations macros
validates :name, length: { maximum: 255 }
validates :name, length: { maximum: 255 }, presence: true
validates :color, presence: true

#### Class methods using self. (public and then private)

Expand All @@ -33,8 +34,8 @@ class LabelTemplate < ApplicationRecord
# Table name: label_templates
#
# id :bigint not null, primary key
# color :integer
# name :string(255)
# color :integer not null
# name :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
# project_id :integer not null, indexed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class MakeLabelTemplatesNameAndColorRequired < ActiveRecord::Migration[7.0]
def change
change_column_null :label_templates, :name, false
change_column_null :label_templates, :color, false
end
end
6 changes: 3 additions & 3 deletions src/api/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_08_01_091535) do
ActiveRecord::Schema[7.0].define(version: 2024_08_02_093510) do
create_table "active_storage_attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
Expand Down Expand Up @@ -730,8 +730,8 @@

create_table "label_templates", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "project_id", null: false
t.string "name"
t.integer "color"
t.string "name", null: false
t.integer "color", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["project_id"], name: "index_label_templates_on_project_id"
Expand Down

0 comments on commit c611b2f

Please sign in to comment.