ERROR: relation "site_texts" already exists when upgrading from v1.1.0.beta3 to v1.1.0.beta4


(Raul ) #1

Hi all,

I am getting this error when trying to update from v1.1.0.beta3 to v1.1.0.beta4, actually I got this when I do the db:migrate after getting the version v1.1.0.beta4 from git

git reset --hard v1.1.0.beta4

After that I stop the application and run bundle install --without test --deployment, but the next step fails

RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate --trace


** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20140924192418 RenameContentType: migrating ================================
-- rename_column(:site_contents, :content_type, :text_type)
   -> 0.0044s
-- rename_column(:site_contents, :content, :value)
   -> 0.0018s
-- rename_table(:site_contents, :site_texts)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  relation "site_texts" already exists
: ALTER TABLE "site_contents" RENAME TO "site_texts"/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.2/lib/patches/sql_patches.rb:160:in `exec'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.2/lib/patches/sql_patches.rb:160:in `async_exec'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/schema_statements.rb:381:in `rename_table'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:649:in `block in method_missing'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `block in say_with_time'
/home/kingadmin/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/benchmark.rb:281:in `measure'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `say_with_time'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:641:in `method_missing'
/fjord/discourse/db/migrate/20140924192418_rename_content_type.rb:5:in `change'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:595:in `exec_migration'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/home/kingadmin/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/benchmark.rb:281:in `measure'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:578:in `block in migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:577:in `migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:991:in `block in execute_migration_in_transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `block in ddl_transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `ddl_transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/kingadmin/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/fjord/discourse/vendor/bundle/ruby/2.0.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/fjord/discourse/vendor/bundle/ruby/2.0.0/bin/rake:23:in `load'
/fjord/discourse/vendor/bundle/ruby/2.0.0/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

Did I miss something important? the migration complains of the rename_table because the “site_texts” already exists, can I skip this somehow or how can I check the integrity of the database in order to try to upgrade to another newer version?

Many thanks in advance


(Sam Saffron) #2

Make a backup and drop the site_texts table, it should push you through the migration, no idea how it got there.


(Raul ) #3

Thanks Sam,

My bad, I should review before that actually the table was empty of content, especially because that is our testing instance to test upgrades before doing on production, most likely I mess the database because of a higher unsuccessful upgrade.

And now I am doing it progressively release per release to ensure integrity

Regards