Commit 812bfb15 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add the `UserStatus` model

This model will hold the status of a user, including these fields:

- emoji: always present, with a default value
- user: always present, foreign key to user
- message: optional, maximum length of 100

The table also stores

- cached_markdown_version
- message_html

For rendering markdown in the `message` field.
parent 3f14c56b
# frozen_string_literal: true
class UserStatus < ActiveRecord::Base
include CacheMarkdownField
belongs_to :user
validates :user, presence: true
validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names }
validates :message, length: { maximum: 100 }, allow_blank: true
cache_markdown_field :message, pipeline: :single_line
end
# frozen_string_literal: true
class CreateUserStatuses < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :user_statuses, id: false, primary_key: :user_id do |t|
t.references :user,
foreign_key: { on_delete: :cascade },
null: false,
primary_key: true
t.integer :cached_markdown_version, limit: 4
t.string :emoji, null: false, default: 'speech_balloon'
t.string :message, limit: 100
t.string :message_html
end
end
end
......@@ -2048,6 +2048,13 @@ ActiveRecord::Schema.define(version: 20180722103201) do
add_index "user_interacted_projects", ["project_id", "user_id"], name: "index_user_interacted_projects_on_project_id_and_user_id", unique: true, using: :btree
add_index "user_interacted_projects", ["user_id"], name: "index_user_interacted_projects_on_user_id", using: :btree
create_table "user_statuses", primary_key: "user_id", force: :cascade do |t|
t.integer "cached_markdown_version"
t.string "emoji", default: "speech_balloon", null: false
t.string "message", limit: 100
t.string "message_html"
end
create_table "user_synced_attributes_metadata", force: :cascade do |t|
t.boolean "name_synced", default: false
t.boolean "email_synced", default: false
......@@ -2349,6 +2356,7 @@ ActiveRecord::Schema.define(version: 20180722103201) do
add_foreign_key "user_custom_attributes", "users", on_delete: :cascade
add_foreign_key "user_interacted_projects", "projects", name: "fk_722ceba4f7", on_delete: :cascade
add_foreign_key "user_interacted_projects", "users", name: "fk_0894651f08", on_delete: :cascade
add_foreign_key "user_statuses", "users", on_delete: :cascade
add_foreign_key "user_synced_attributes_metadata", "users", on_delete: :cascade
add_foreign_key "users", "application_setting_terms", column: "accepted_term_id", name: "fk_789cd90b35", on_delete: :cascade
add_foreign_key "users_star_projects", "projects", name: "fk_22cd27ddfc", on_delete: :cascade
......
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