title: Rails Migration Error - relation 'users' does not exist ('"users"'::regclass) - (rails 3.2.6 / Postgresql)
body: <p>Good afternoon,</p>
  
  <p>I'm having serious troubles getting my database back up and running.  I dropped my tables earlier this week (wanted to rebuild) and am having all kinds of problems.</p>
  
  <p>I have done the following:</p>
  
  <pre><code>rake db:drop:all
  rake db:create:all
  rake db:migrate
  </code></pre>
  
  <p>I get the following error (will put full stack trace at the bottom):</p>
  
  <pre><code>PG::Error: ERROR:  relation "users" does not exist
  LINE 4:              WHERE a.attrelid = '"users"'::regclass
                                          ^
  :             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
                FROM pg_attribute a LEFT JOIN pg_attrdef d
                  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
               WHERE a.attrelid = '"users"'::regclass
                 AND a.attnum &gt; 0 AND NOT a.attisdropped
               ORDER BY a.attnum
  </code></pre>
  
  <p>Authlogic is the issue here.  The only reason I was able to see this error (the real error) was because I hid the authlogic error:</p>
  
  <pre><code>You must establish a database connection before using acts_as_authentic
  </code></pre>
  
  <p>As suggested in this post: <a href="https://stackoverflow.com/questions/9518976/authlogic-doesnt-work-with-my-rails-3-2-app">Stack overflow thread</a></p>
  
  <p>User migration:</p>
  
  <pre><code>class CreateUsers &lt; ActiveRecord::Migration
    def change
      create_table :users do |t|
        t.string    :name,               :null =&gt; false
        t.string    :email,               :null =&gt; false
        t.string    :plan, :default =&gt; "basic"
        t.boolean   :verified, :default =&gt; false
        t.boolean   :admin, :default =&gt; false
        t.integer   :selected_portfolio_id
        t.datetime  :last_email_at
        t.hstore    :data
  
        t.string    :crypted_password,    :null =&gt; false
        t.string    :password_salt,       :null =&gt; false
        t.string    :persistence_token,   :null =&gt; false
        t.string    :perishable_token,    :null =&gt; false
  
        # magic fields (all optional, see Authlogic::Session::MagicColumns)
        t.integer   :login_count,         :null =&gt; false, :default =&gt; 0
        t.integer   :failed_login_count,  :null =&gt; false, :default =&gt; 0
        t.datetime  :last_request_at
        t.datetime  :current_login_at
        t.datetime  :last_login_at
        t.string    :current_login_ip
        t.string    :last_login_ip
  
        # optional, see Authlogic::Session::Params
        #t.string    :single_access_token, :null =&gt; false  
        t.timestamps
      end
  
      add_index :users, ["email"], :name =&gt; "index_users_on_email", :unique =&gt; true
      add_index :users, ["persistence_token"], :name =&gt; "index_users_on_persistence_token", :unique =&gt; true
    end
  end
  </code></pre>
  
  <p>Why is authlogic trying to load up on a database migration?  I'm assuming this has to be the problem.... Full stack trace:</p>
  
  <pre><code>/Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `async_exec'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:1151:in `exec_no_cache'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in `block in exec_query'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.    rb:20:in `instrument'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `exec_query'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:1276:in `column_definitions'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/postgresql_adapter.rb:859:in `columns'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.    6/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in `yield'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in     `default'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:228:in     `columns'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/model_schema.rb:248:in     `column_names'
  /Users/brandon/Documents/authlogic/lib/authlogic/acts_as_authentic/base.rb:67:in `db_setup?'
  /Users/brandon/Documents/authlogic/lib/authlogic/acts_as_authentic/base.rb:31:in `acts_as_authentic'
  /Users/brandon/Dropbox/code/myapp/app/models/user_related/user.rb:14:in `&lt;class:User&gt;'
  /Users/brandon/Dropbox/code/myapp/app/models/user_related/user.rb:1:in `&lt;top (required)&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in     `block in load_file'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:639:in     `new_constants_in'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:468:in     `load_file'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:353:in     `require_or_load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:502:in     `load_missing_constant'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:192:in     `block in const_missing'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in     `const_missing'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:229:in     `block in constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in     `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in     `constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections.    rb:54:in `constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `block in     observe'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `collect!'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:189:in `observe'
  /Users/brandon/Dropbox/code/myapp/app/models/user_related/user_observer.rb:2:in `&lt;class:UserObserver&gt;'
  /Users/brandon/Dropbox/code/myapp/app/models/user_related/user_observer.rb:1:in `&lt;top (required)&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in `load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:469:in     `block in load_file'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:639:in     `new_constants_in'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:468:in     `load_file'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:353:in     `require_or_load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:502:in     `load_missing_constant'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:192:in     `block in const_missing'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:190:in     `const_missing'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:229:in     `block in constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in     `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in     `constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections.    rb:54:in `constantize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:86:in     `instantiate_observer'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in `block in     instantiate_observers'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activemodel-3.2.6/lib/active_model/observing.rb:59:in     `instantiate_observers'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/railtie.rb:117:in `block (2     levels) in &lt;class:Railtie&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:36:in     `instance_eval'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:36:in     `execute_hook'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:26:in     `block in on_load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:25:in     `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:25:in     `on_load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activerecord-3.2.6/lib/active_record/railtie.rb:116:in `block in &lt;    class:Railtie&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in     `call'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in     `execute_hook'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:43:in     `block in run_load_hooks'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in     `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in     `run_load_hooks'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application/finisher.rb:59:in `block in &lt;    module:Finisher&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in     run_initializers'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in     `method_missing'
  /Users/brandon/Dropbox/code/myapp/config/environment.rb:5:in `&lt;top (required)&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in     `require'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in     `block in require'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in     `load_dependency'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in     `require'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:103:in     `require_environment!'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@myapp/gems/railties-3.2.6/lib/rails/application.rb:292:in `block (2 levels) in     initialize_tasks'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
  /Users/brandon/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
  /Users/brandon/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
  /Users/brandon/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `&lt;main&gt;'
  Tasks: TOP =&gt; db:migrate =&gt; environment
  </code></pre>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I was able to solve this problem by commenting out "acts as authentic", migrating the database, then reapplying.  While it is a bandaid, it doesn't seem right.  How can I properly fix this?</p>