Sha256: 0b23b8223fd49ecbad4ab3ba62d52c9457236febac9978d09e756b407b29b3f4

Contents?: true

Size: 884 Bytes

Versions: 21

Compression:

Stored size: 884 Bytes

Contents

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

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

      -- Remove values that won't be compatible with new definition
      DELETE FROM identity_providers WHERE service = 'GOOGLE';
      
      -- 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

21 entries across 21 versions & 1 rubygems

Version Path
osso-0.0.5.pre.alpha lib/osso/db/migrate/20200916125543_add_google_to_identity_provider_service_enum.rb