Sha256: 585952169f39a2e44da0b17871710ed16555be5c9dc2be8882e7ea3278a56f09

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

class AddImplicitVarcharUuidCast < ActiveRecord::Migration[5.2]
  def up
    if on_postgresql?
      ActiveRecord::Base.connection.execute <<~SQL
        CREATE CAST (varchar AS uuid)
        WITH INOUT
        AS IMPLICIT
      SQL
    end
  end

  def down
    if on_postgresql?
      ActiveRecord::Base.connection.execute <<~SQL
        DROP CAST (varchar AS uuid)
      SQL
    end
  end

  private

  def on_postgresql?
    ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman-tasks-0.15.4 db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb
foreman-tasks-0.15.3 db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb
foreman-tasks-0.15.2 db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb