Project

General

Profile

Actions

Bug #1545

closed

Rails DB migration fails on PosgreSQL 9.1

Added by Rytis Sileika about 12 years ago. Updated almost 12 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

My setup:

  • OS: RHEL5.7
  • DB: PostgreSQL
  • Puppet: 2.7.11
  • Foreman: 0.5 dev branch

When following instructions on http://theforeman.org/projects/foreman/wiki/Installing_latest_code to migrate DB, I discovered that a number of migration tasks are failing.

Some examples: http://pastie.org/3646861, http://pastie.org/3646935.

Running the same migration on SQLite DB does not cause any problems.


Related issues 1 (0 open1 closed)

Has duplicate Foreman - Bug #1568: PG::Error on fresh installClosedOhad Levy04/04/2012Actions
Actions #1

Updated by Rytis Sileika about 12 years ago

OK, this doesn't seem to be related to the DB type.

I installed MySQL, and pointed puppet at it. Puppet created all of its tables. Then I ran Foreman migration - same failures.

Dropped all tables in the Puppet DB, ran Foreman migration - no problems. Started puppet - seems to be working ok.

Actions #2

Updated by Rytis Sileika about 12 years ago

Sorry, wrong Puppet version, I'm using 2.7.12-1

Actions #3

Updated by Rytis Sileika about 12 years ago

More info:

PostgreSQL still doesn't work - same problem, even though I dropped all the tables before trying to migrate. It fails at the same tasks.

Just to reiterate - same problem happened with MySQL, when Puppet had already created its tables, dropping tables and running Rails migration fixed the issue on MySQL (but not on PGSQL)

Actions #4

Updated by Ohad Levy about 12 years ago

  • Target version set to 1.0

Rytis Sileika wrote:

More info:

PostgreSQL still doesn't work - same problem, even though I dropped all the tables before trying to migrate. It fails at the same tasks.

Just to reiterate - same problem happened with MySQL, when Puppet had already created its tables, dropping tables and running Rails migration fixed the issue on MySQL (but not on PGSQL)

oh, your second trace actually shows that the audit system complains..

can you try the following, simply remove all the places where it has something like Medium.create, Ptable.create etc and try again?

Actions #5

Updated by Rytis Sileika about 12 years ago

Just tried it from scratch...

The first migration it fails on is: db/migrate/20090717025820_create_media.rb
Commenting out Medium.create 'fixes' it.

It then fails on db/migrate/20090730152224_create_ptables.rb
Commenting out Ptable.create 'fixes' it.

Next it fails on db/migrate/20100310080727_add_family_to_os.rb
Not too sure what to remove from it though, as it seems to be failing on OS select, I might be wrong though, here's the stack trace:

  1. RAILS_ENV=production bundle exec rake db:migrate --trace
    /opt/foreman/vendor/ruby/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: warning: already initialized constant ENC_NONE
    /opt/foreman/vendor/ruby/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: warning: already initialized constant ENC_EUC
    /opt/foreman/vendor/ruby/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: warning: already initialized constant ENC_SJIS
    /opt/foreman/vendor/ruby/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:13: warning: already initialized constant ENC_UTF8
    • Invoke db:migrate (first_time)
    • Invoke environment (first_time)
    • Execute environment
    • Execute db:migrate
      AddFamilyToOs: migrating ================================================
      -- add_column(:operatingsystems, :family_id, :integer)
      -> 0.0015s
      rake aborted!
      An error has occurred, this and all later migrations canceled:

PG::Error: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT "operatingsystems".* FROM "operatingsystems" ORDER BY LOWER
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `log'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:514:in `execute'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:1004:in `select_raw'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:997:in `select'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/base.rb:473:in `find_by_sql'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/relation.rb:64:in `to_a'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/relation/finder_methods.rb:143:in `all'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/base.rb:444:in `__send__'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/base.rb:444:in `all'
/opt/foreman/db/migrate/20100310080727_add_family_to_os.rb:7:in `up_without_benchmarks'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:314:in `send'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:314:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:314:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:397:in `__send__'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:397:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:539:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:613:in `call'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:613:in `ddl_transaction'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/transactions.rb:207:in `transaction'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:613:in `ddl_transaction'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:538:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:525:in `each'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:525:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:435:in `up'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/migration.rb:417:in `migrate'
/opt/foreman/vendor/ruby/1.8/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:151
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/opt/foreman/vendor/ruby/1.8/gems/rake-0.9.2.2/bin/rake:33
/opt/foreman/vendor/ruby/1.8/bin/rake:19:in `load'
/opt/foreman/vendor/ruby/1.8/bin/rake:19
Tasks: TOP => db:migrate

Actions #6

Updated by Ohad Levy almost 12 years ago

  • Status changed from New to Duplicate
  • Target version deleted (1.0)
Actions

Also available in: Atom PDF