Sha256: 69a04b365ab2736c0f125117aca09548870ebcb554d9044183df6dfd66138b44

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

if ActiveRecord.gem_version >= Gem::Version.new('5.0')
   class ActsAsFollowerMigration < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]; end
else
   class ActsAsFollowerMigration < ActiveRecord::Migration; end
end
FollowableBehaviourMigration.class_eval do
def self.up
    create_table :follows, force: true do |t|
      t.references :followable, polymorphic: true, null: false
      t.references :follower,   polymorphic: true, null: false
      t.boolean :blocked, default: false, null: false
      t.timestamps
    end

    add_index :follows, ["follower_id", "follower_type"],     name: "fk_follows"
    add_index :follows, ["followable_id", "followable_type"], name: "fk_followables"
  end

  def self.down
    drop_table :follows
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
followable_behaviour-0.2.0 lib/generators/templates/migration.rb
followable_behaviour-0.1.0 lib/generators/templates/migration.rb