Sha256: 8cc1c392c4f4a1ae30432a1c53a89ad4d592a40fe985769157c34f6e6144d82c

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

module Migrations
  module ReferralMigrator

    def create_reward_migration
      generate 'migration', "create_referrals"
      add_referral_migration_details
    end

    private

    def add_referral_migration_details
      return unless migration_created?('create_referrals')
      inject_into_file(last_migration, after: 'do |t|') do
        <<~TEXT
        \n
            t.integer "recruit_id"
            t.datetime "created_at", null: false
            t.datetime "updated_at", null: false
            t.string "referrer_type"
            t.bigint "referrer_id"
            t.string "recruit_type"
            t.index ["recruit_type", "recruit_id"], name: "index_referrals_on_recruit_type_and_recruit_id"
            t.index ["referrer_type", "referrer_id"], name: "index_referrals_on_referrer_type_and_referrer_id"
        TEXT
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
referable-0.3.1 lib/generators/referable/migrations/referral_migration.rb
referable-0.3.0 lib/generators/referable/migrations/referral_migration.rb
referable-0.2.0 lib/generators/referable/migrations/referral_migration.rb