```ruby
class AddTypetoPublic < ActiveRecord::Migration
  def change
    change_table :metasploit_credential_publics do |t|
      #
      # Single Table Inheritance
      #

      t.string :type, null: true
      Metasploit::Credential::Public.update_all(type: 'Metasploit::Credential::Username')

      change_column :metasploit_credential_publics, :type, :string, null: false

    end
  end

end
```

Use direct SQL instead of model reference in migraion
user
```ruby
class AddTypetoPublic < ActiveRecord::Migration
  def change
    change_table :metasploit_credential_publics do |t|
      #
      # Single Table Inheritance
      #

      t.string :type, null: true
      execute "UPDATE metasploit_credential_publics SET type = 'Metasploit::Credential::Username'"

      change_column :metasploit_credential_publics, :type, :string, null: false

    end
  end

end
```
assistant