title: ActiveRecord::NoDatabaseError: local user with ID does not exist
body: <p>Developing an API-only Rails app to consume data from an API, filter out a number of the fields, and then broadcast fields we want public.  </p>
  
  <p>My app was returning data normally, but I realized that on the source API level, we changed the data type for one of the fields of data we're exposing.  To accommodate, I committed my work, checked out a new branch, ran a migrations to change a data field's data type, decided I wasn't happy with how it worked, rolled back the migration, committed, and checkout out the master branch.  The app is returning data as normal.  However, now when I test my model's records in Rails Console using finder methods like <code>.first</code>, <code>.last</code>, etc., I get the error below.  They were working fine before.</p>
  
  <p>I've looked around and haven't seen any threads on this particular error (they all seem to deal with finding individual records for the show page) - although <a href="https://stackoverflow.com/questions/33530287/when-i-try-to-do-rake-dbmigrate-i-get-an-error-activerecordnodatabaseerror">this</a>, and <a href="https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist/11919677#11919677">this</a> thread (by extension) seem closest.  And checking the users on the db I'm using shows that the user ID ("501") in the error is not present.  </p>
  
  <p>What did I do and what do I need to do so that I can call finder methods again?   Do I need to create that user referenced in the error in my db?  (and why is it not the default user that I always use to connect to my db?  Where did that user ID in the error come from?  Does it even matter?)</p>
  
  <p>ps - in case it's relevant, I used <code>rake db:rollback</code> to rollback my migration as per <a href="https://stackoverflow.com/questions/3647685/rails-3-how-to-roll-back-a-migration-file">this</a> thread.</p>
  
  <p>Thanks in advance.  </p>
  
  <p><strong>Rails Console</strong></p>
  
  <pre><code>.2.1 :001 &gt; KoboApi.first
  ActiveRecord::NoDatabaseError: local user with ID 501 does not exist
  
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis_adapter.rb:51:in `initialize'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `new'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `postgis_connection'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
      from /Users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
      from /Users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
  ... 13 levels...
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in `start'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in `console'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `&lt;top (required)&gt;'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `block in require'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require'
      from /Users/toby/code/projects/koboApi-broker/bin/rails:9:in `&lt;top (required)&gt;'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `block in load'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
      from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in `load'
      from /Users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
      from /Users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  </code></pre>
  
  <p>I'm definitely getting my records - they're coming into the database:</p>
  
  <p><strong>Rails dbconsole</strong></p>
  
  <pre><code>koboApi_development=# select * from kobo_apis limit 1;
    id  | lemurs_quantity | month_and_year | _geolocation | lemur_category | location_admin1 | location_admin2 | record_id | sighting_month | sighting_year
  ------+-----------------+----------------+--------------+----------------+-----------------+-----------------+-----------+----------------+---------------
   1365 |               1 |                |              | I_dont_remembe | antsiranana     | diana           |   1234567 | no_response    | 2013
  (1 row)
  
  koboApi_development=# \du
                               List of roles
   Role name |                   Attributes                   | Member of
  -----------+------------------------------------------------+-----------
   [user]    | Superuser, Create role, Create DB, Replication | {}
  </code></pre>
  
  <p><strong>from my schema</strong></p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20160705203507) do
  
    # These are extensions that must be enabled in order to support this database
    enable_extension "plpgsql"
    enable_extension "postgis"
  
    create_table "kobo_apis", force: :cascade do |t|
      t.integer "lemurs_quantity"
      t.date    "month_and_year"
      t.text    "_geolocation"
      t.text    "lemur_category"
      t.string  "location_admin1"
      t.string  "location_admin2"
      t.integer "record_id"
      t.string  "sighting_month"
      t.string  "sighting_year"
    end
  
    create_table "my_spatial_table", force: :cascade do |t|
      t.geography "polygon_data", limit: {:srid=&gt;4326, :type=&gt;"polygon", :geographic=&gt;true}
    end
  
  end
  </code></pre>
  
  <p><strong>My database.yml</strong></p>
  
  <pre><code>development:
    adapter: postgis
    encoding: unicode
    postgis_extension: postgis      # default is postgis
    postgis_schema: public          # default is public
    schema_search_path: public,postgis
    database: koboApi_development
    pool: 5
  
  test:
    adapter: postgresql
    encoding: unicode
    database: koboApi_test
    pool: 5
  
  production:
    adapter: postgresql
    encoding: unicode
    database: koboApi_production
    pool: 5
  </code></pre>