Sha256: e7f928938b8d1608f585bc95cf0721ce6ca5f681fdfa7602f8dcd77f4aac6e52

Contents?: true

Size: 610 Bytes

Versions: 8

Compression:

Stored size: 610 Bytes

Contents

class RemoveUuid < ActiveRecord::Migration[4.2]
  @@uuid_configured = false

  def self.up
    %i[users accounts campaigns leads contacts opportunities tasks].each do |table|
      remove_column table, :uuid
      execute("DROP TRIGGER IF EXISTS #{table}_uuid") if uuid_configured?
    end
  end

  def self.down
    raise ActiveRecord::IrreversibleMigration, "Can't recover deleted UUIDs"
  end

  private

  def self.uuid_configured?
    return @@uuid_configured if @@uuid_configured
    config = ActiveRecord::Base.connection.instance_variable_get("@config")
    @@uuid_configured = config[:uuid]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fat_free_crm-0.15.2 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.16.4 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.15.1 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.16.3 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.16.2 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.16.1 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.16.0 db/migrate/20100928030620_remove_uuid.rb
fat_free_crm-0.15.0 db/migrate/20100928030620_remove_uuid.rb