Foreman 1.3.1 db migration from sqlite3 to postgres failed when running db:convert:prod2dev

I'm trying to migrate to postgres by following the manual:
http://theforeman.org/manuals/1.3/index.html#3.5.3DatabaseSetup

However, I'm stuck on the db:convert:prod2dev step. Got the following
message. Any suggestion? Possible bug?

[compass@puppet foreman]$ sudo /opt/rh/ruby193/root/usr/bin/rake --trace
db:convert:prod2dev
** Invoke db:convert:prod2dev (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:convert:prod2dev
Converting resources…rake aborted!
PGError: ERROR: relation "resources" does not exist
LINE 1: DELETE FROM "resources"
^
: DELETE FROM "resources"
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in
async_exec' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:inexec_no_cache'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in
block in exec_delete' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:inblock in log'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in
instrument' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:inlog'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in
exec_delete' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:101:indelete'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in
delete' /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation.rb:413:indelete_all'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/querying.rb:7:in
delete_all&#39; /usr/share/foreman/lib/tasks/convert.rake:104:inblock (4 levels) in <top
(required)>'
/usr/share/foreman/lib/tasks/convert.rake:84:in each&#39; /usr/share/foreman/lib/tasks/convert.rake:84:inblock (3 levels) in <top
(required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in call&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:inblock in execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in each&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:inexecute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in block in invoke_with_call_chain&#39; /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:inmon_synchronize'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
invoke_with_call_chain&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:ininvoke'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in invoke_task&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:inblock (2
levels) in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in each&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:inblock in
top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:intop_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in block in run&#39; /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:instandard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in run&#39; /opt/rh/ruby193/root/usr/bin/rake:32:in<main>'
Tasks: TOP => db:convert:prod2dev

Was your source database originally shared with Puppet? That adds some
tables which will not be present in the schema of the new database, which
will lead to the error above. Take a look at the bug report[1] for a list
of tables you can safely drop from an old sharing setup.

Note with Foreman 1.3 (or 1.3.1) there's an issue with prod2dev on PSQL
because of the new foreign key constraints. THis has been fixed for 1.3.2,
but you can see[2] for the patch to the rake task if you can't wait :slight_smile:

HTH,
Greg

[1] Bug #3236: prod2dev assumes all production tables exist in development - Foreman
[2] Bug #3268: defer postgresql foreign key constraints for rake db:convert:prod2dev - Foreman

··· On 7 December 2013 06:39, Pan Luo wrote:

I’m trying to migrate to postgres by following the manual:
Foreman :: Manual

However, I’m stuck on the db:convert:prod2dev step. Got the following
message. Any suggestion? Possible bug?

[compass@puppet foreman]$ sudo /opt/rh/ruby193/root/usr/bin/rake --trace
db:convert:prod2dev
** Invoke db:convert:prod2dev (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:convert:prod2dev
Converting resources…rake aborted!
PGError: ERROR: relation “resources” does not exist
LINE 1: DELETE FROM “resources”

Thanks. Dropped all extra tables listed in [1] solved the problem.

Cheers,
Pan

··· On Sat, Dec 7, 2013 at 5:30 AM, Greg Sutcliffe wrote:

On 7 December 2013 06:39, Pan Luo luopan81@gmail.com wrote:

I’m trying to migrate to postgres by following the manual:
Foreman :: Manual

However, I’m stuck on the db:convert:prod2dev step. Got the following
message. Any suggestion? Possible bug?

[compass@puppet foreman]$ sudo /opt/rh/ruby193/root/usr/bin/rake --trace
db:convert:prod2dev
** Invoke db:convert:prod2dev (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:convert:prod2dev
Converting resources…rake aborted!
PGError: ERROR: relation “resources” does not exist
LINE 1: DELETE FROM “resources”

Was your source database originally shared with Puppet? That adds some
tables which will not be present in the schema of the new database, which
will lead to the error above. Take a look at the bug report[1] for a list
of tables you can safely drop from an old sharing setup.

Note with Foreman 1.3 (or 1.3.1) there’s an issue with prod2dev on PSQL
because of the new foreign key constraints. THis has been fixed for 1.3.2,
but you can see[2] for the patch to the rake task if you can’t wait :slight_smile:

HTH,
Greg

[1] Bug #3236: prod2dev assumes all production tables exist in development - Foreman
[2] Bug #3268: defer postgresql foreign key constraints for rake db:convert:prod2dev - Foreman


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-users/H8qQ7eDpLpI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.