Add database support and model for tips

This commit is contained in:
Sebastian Serth
2020-10-07 17:42:44 +02:00
parent 85a05225ec
commit 2e1c97d87d
7 changed files with 101 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class CreateTips < ActiveRecord::Migration[5.2]
def change
create_table :tips do |t|
t.string :title
t.text :description
t.text :example
t.references :file_type, foreign_key: true
t.references :user, polymorphic: true, null: false
t.timestamps
end
create_table :exercise_tips do |t|
t.references :exercise, null: false
t.references :tip, null: false
t.integer :rank, null: false
t.references :parent_exercise_tip, foreign_key: {to_table: :exercise_tips}
t.index %i[exercise_id tip_id rank], unique: true
end
end
end