3scale/porta

View on GitHub
db/migrate/20230718082519_add_primary_key_to_backend_events.rb

Summary

Maintainability
A
0 mins
Test Coverage
class AddPrimaryKeyToBackendEvents < ActiveRecord::Migration[5.2]
  def up
    if System::Database.mysql?
      execute 'ALTER TABLE backend_events ADD PRIMARY KEY (id)'
      remove_index :backend_events, :id
    elsif System::Database.postgres?
      execute 'ALTER TABLE backend_events ADD CONSTRAINT backend_events_pk PRIMARY KEY (id)'
      remove_index :backend_events, :id
    else
      remove_index :backend_events, :id
      execute 'ALTER TABLE BACKEND_EVENTS MODIFY ID PRIMARY KEY'
    end
  end
end