add emoji reaction database model

main
anna 1 year ago
parent 8380f9fc2c
commit 0da3340f0d
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

@ -0,0 +1,16 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: emoji_reactions
#
# id :bigint(8) not null, primary key
# emoji :string
# status_id :bigint(8) not null
# account_id :bigint(8) not null
# created_at :datetime not null
# updated_at :datetime not null
#
class EmojiReaction < ApplicationRecord
belongs_to :status
belongs_to :account
end

@ -70,6 +70,7 @@ class Status < ApplicationRecord
has_many :mentions, dependent: :destroy, inverse_of: :status
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status
has_many :media_attachments, dependent: :nullify
has_many :emoji_reactions
has_and_belongs_to_many :tags
has_and_belongs_to_many :preview_cards

@ -0,0 +1,11 @@
class CreateEmojiReactions < ActiveRecord::Migration[6.1]
def change
create_table :emoji_reactions do |t|
t.string :emoji
t.references :status, null: false, foreign_key: true
t.references :account, null: false, foreign_key: true
t.timestamps
end
end
end

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_11_04_133904) do
ActiveRecord::Schema.define(version: 2022_11_23_004534) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -411,6 +411,16 @@ ActiveRecord::Schema.define(version: 2022_11_04_133904) do
t.index ["domain"], name: "index_email_domain_blocks_on_domain", unique: true
end
create_table "emoji_reactions", force: :cascade do |t|
t.string "emoji"
t.bigint "status_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["account_id"], name: "index_emoji_reactions_on_account_id"
t.index ["status_id"], name: "index_emoji_reactions_on_status_id"
end
create_table "encrypted_messages", id: :bigint, default: -> { "timestamp_id('encrypted_messages'::text)" }, force: :cascade do |t|
t.bigint "device_id"
t.bigint "from_account_id"
@ -781,6 +791,16 @@ ActiveRecord::Schema.define(version: 2022_11_04_133904) do
t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
end
create_table "reactions", force: :cascade do |t|
t.string "emoji"
t.bigint "status_id", null: false
t.bigint "account_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["account_id"], name: "index_reactions_on_account_id"
t.index ["status_id"], name: "index_reactions_on_status_id"
end
create_table "relays", force: :cascade do |t|
t.string "inbox_url", default: "", null: false
t.string "follow_activity_id"
@ -1158,6 +1178,8 @@ ActiveRecord::Schema.define(version: 2022_11_04_133904) do
add_foreign_key "devices", "accounts", on_delete: :cascade
add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
add_foreign_key "emoji_reactions", "accounts"
add_foreign_key "emoji_reactions", "statuses"
add_foreign_key "encrypted_messages", "accounts", column: "from_account_id", on_delete: :cascade
add_foreign_key "encrypted_messages", "devices", on_delete: :cascade
add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
@ -1198,6 +1220,8 @@ ActiveRecord::Schema.define(version: 2022_11_04_133904) do
add_foreign_key "polls", "accounts", on_delete: :cascade
add_foreign_key "polls", "statuses", on_delete: :cascade
add_foreign_key "preview_card_trends", "preview_cards", on_delete: :cascade
add_foreign_key "reactions", "accounts"
add_foreign_key "reactions", "statuses"
add_foreign_key "report_notes", "accounts", on_delete: :cascade
add_foreign_key "report_notes", "reports", on_delete: :cascade
add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify

@ -0,0 +1,5 @@
Fabricator(:emoji_reaction) do
emoji "MyString"
status nil
account nil
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EmojiReaction, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save