Class: CreateMentions
- Inherits:
-
Object
- Object
- CreateMentions
- Defined in:
- lib/generators/mention_system/templates/migration.rb
Overview
CreateMentions class
This class defines the create mentions migration in mention system
Instance Method Summary collapse
-
#change ⇒ Object
Changes the database.
Instance Method Details
#change ⇒ Object
Changes the database
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/mention_system/templates/migration.rb', line 10 def change ### # Mentions table creation ### create_table :mentions do |t| ### # Mentionee id field and mentionee type field definition ### t.references :mentionee, polymorphic: true ### # Mentioner id fiel and mentioner type field definition ### t.references :mentioner, polymorphic: true ### # Timestamps fields definition ### t. null: false end ### # Mentions table mentionee id field and mentionee type field index addition ### add_index :mentions, [:mentionee_id, :mentionee_type], name: "mentions_mentionee_idx" ### # Mentions table mentioner id field and mentioner type field index addition ### add_index :mentions, [:mentioner_id, :mentioner_type], name: "mentions_mentioner_idx" ### # Mentions table mentionee id field and mentionee type field and mentioner id field and mentioner type field unique index addition ### add_index :mentions, [:mentionee_id, :mentionee_type, :mentioner_id, :mentioner_type], name: "mentions_mentionee_mentioner_idx", unique: true end |