mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 20:15:59 +01:00
Create Appendable model
This commit is contained in:
parent
be8418a1aa
commit
544e9c8fa6
2 changed files with 29 additions and 0 deletions
6
app/models/appendable.rb
Normal file
6
app/models/appendable.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Appendable < ApplicationRecord
|
||||||
|
belongs_to :parent, polymorphic: true
|
||||||
|
belongs_to :user
|
||||||
|
end
|
23
db/migrate/20220127212925_create_appendables.rb
Normal file
23
db/migrate/20220127212925_create_appendables.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CreateAppendables < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
create_table :appendables do |t|
|
||||||
|
t.string :type, null: false
|
||||||
|
t.bigint :user_id, null: false
|
||||||
|
t.bigint :parent_id, null: false
|
||||||
|
t.string :parent_type, null: false
|
||||||
|
t.text :content
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
change_column :appendables, :id, :bigint
|
||||||
|
add_index :appendables, %i[parent_id parent_type]
|
||||||
|
add_index :appendables, %i[user_id created_at]
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :appendables
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue