Sha256: 1d2758bcf274c92cf98a79b739ee8e275af869f58a40e005c50836af91e4c0a1

Contents?: true

Size: 878 Bytes

Versions: 22

Compression:

Stored size: 878 Bytes

Contents

class AddOneLoginToIdentityProviderServiceEnum < ActiveRecord::Migration[6.0]
  disable_ddl_transaction!

  def up
    execute <<-SQL
      ALTER TYPE identity_provider_service ADD VALUE 'ONELOGIN';
    SQL
  end
  
  def down
    execute <<~SQL
      CREATE TYPE identity_provider_service_new AS ENUM ('AZURE', 'OKTA');

      -- Remove values that won't be compatible with new definition
      DELETE FROM identity_providers WHERE service = 'ONELOGIN';
      
      -- Convert to new type, casting via text representation
      ALTER TABLE identity_providers 
        ALTER COLUMN service TYPE identity_provider_service_new 
          USING (service::text::identity_provider_service_new);
      
      -- and swap the types
      DROP TYPE identity_provider_service;
      
      ALTER TYPE identity_provider_service_new RENAME TO identity_provider_service;
    SQL
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
osso-0.0.5.pre.alpha lib/osso/db/migrate/20200913154919_add_one_login_to_identity_provider_service_enum.rb
osso-0.0.4 lib/osso/db/migrate/20200913154919_add_one_login_to_identity_provider_service_enum.rb