class AddSalesforceToProviderServiceEnum

Public Instance Methods

down() click to toggle source
# File lib/osso/db/migrate/20201125143501_add_salesforce_to_provider_service_enum.rb, line 10
  def down
    execute <<~SQL
      CREATE TYPE identity_provider_service_new AS ENUM ('AZURE', 'OKTA', 'ONELOGIN', 'GOOGLE', 'PING');

      -- Remove values that won't be compatible with new definition
      DELETE FROM identity_providers WHERE service = 'SALESFORCE';
      
      -- 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
up() click to toggle source
# File lib/osso/db/migrate/20201125143501_add_salesforce_to_provider_service_enum.rb, line 4
  def up
    execute <<-SQL
      ALTER TYPE identity_provider_service ADD VALUE 'SALESFORCE';
    SQL
  end