Note we're excluding a few files: * Configuration files that weren't generated by us * Migration files that weren't generated by us * The Gemfile, since it includes an important comment that must be on the same line as the gem declaration * The Budget::Stats class, since the heading statistics are a mess and having shorter lines would require a lot of refactoring
20 lines
842 B
Ruby
20 lines
842 B
Ruby
class CreateRelatedContent < ActiveRecord::Migration[4.2]
|
|
def change
|
|
create_table :related_contents do |t|
|
|
t.references :parent_relationable, polymorphic: true,
|
|
index: { name: "index_related_contents_on_parent_relationable" }
|
|
t.references :child_relationable, polymorphic: true,
|
|
index: { name: "index_related_contents_on_child_relationable" }
|
|
t.references :related_content, index: { name: "opposite_related_content" }
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :related_contents,
|
|
[:parent_relationable_id, :parent_relationable_type,
|
|
:child_relationable_id, :child_relationable_type],
|
|
name: "unique_parent_child_related_content",
|
|
unique: true,
|
|
using: :btree
|
|
end
|
|
end
|