Db:migrate, storeconfigs and database shared w/ Puppet

Hello,

An error occur during "db:migrate" if Foreman database is shared with
Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried
with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to
1.0 is OK even with an existant database.

Some relevant information:

  • There is a problem with 2 files:
    /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb
    /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb

  • Theses files are identical in /usr/share/foreman/migrate in version 0.4
    and 1.0

  • If I comment them, db:migrate is OK (but database is inconsistent)

  • If I delete "self" before "up" and "down" db:migrate is OK (I don't know
    what it implies as a Ruby newbie)

Any ideas ? Thanks.

Paul (fr)

[root@puppet ~]# su - foreman -s /bin/bash -c
/usr/share/foreman/extras/dbmigrate
Libvirt binding are missing - hypervisor management is disabled
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10:
warning: already initialized constant ENC_NONE
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11:
warning: already initialized constant ENC_EUC
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12:
warning: already initialized constant ENC_SJIS
/usr/lib/ruby/gems/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
== CreateHosts: migrating

··· ==================================================== -- add_column(:hosts, :mac, :string, {:default=>"", :limit=>17}) -> 0.0010s -- add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17}) -> 0.0007s -- add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15}) -> 0.0007s -- add_column(:hosts, :sp_name, :string, {:default=>""}) -> 0.0006s -- add_column(:hosts, :root_pass, :string, {:limit=>64}) -> 0.0003s -- add_column(:hosts, :serial, :string, {:limit=>12}) -> 0.0003s -- add_column(:hosts, :puppetmaster, :string) -> 0.0004s -- add_column(:hosts, :puppet_status, :integer, {:null=>false, :default=>0}) -> 0.0033s -- add_column(:hosts, :domain_id, :integer) -> 0.0004s -- add_column(:hosts, :architecture_id, :integer) -> 0.0003s -- add_column(:hosts, :operatingsystem_id, :integer) -> 0.0003s -- add_column(:hosts, :environment_id, :integer) -> 0.0004s -- add_column(:hosts, :subnet_id, :integer) -> 0.0003s -- add_column(:hosts, :sp_subnet_id, :integer) -> 0.0003s -- add_column(:hosts, :ptable_id, :integer) -> 0.0003s -- add_column(:hosts, :medium_id, :integer) -> 0.0003s -- add_column(:hosts, :build, :boolean, {:default=>true}) -> 0.0006s -- add_column(:hosts, :comment, :text) -> 0.0003s -- add_column(:hosts, :disk, :text) -> 0.0004s -- add_column(:hosts, :installed_at, :datetime) -> 0.0003s == CreateHosts: migrated (0.0137s) ===========================================

== AddAuditsTable: migrating

– create_table(:audits, {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence “audits_id_seq” for
serial column "audits.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "audits_pkey"
for table “audits”
-> 0.0051s
– add_index(:audits, [:auditable_id, :auditable_type],
{:name=>“auditable_index”})
-> 0.0019s
– add_index(:audits, [:user_id, :user_type], {:name=>“user_index”})
-> 0.0022s
– add_index(:audits, :created_at)
-> 0.0024s
– add_index(:audits, [:auditable_parent_id, :auditable_parent_type],
{:name=>“auditable_parent_index”})
-> 0.0025s
== AddAuditsTable: migrated (0.0143s)

== CreateArchitectures: migrating

– create_table(:architectures)
NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq"
for serial column “architectures.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"architectures_pkey” for table “architectures”
-> 0.0029s
– create_table(:architectures_operatingsystems, {:id=>false})
-> 0.0005s
== CreateArchitectures: migrated (0.0036s)

== CreateMedia: migrating

– create_table(:media)
NOTICE: CREATE TABLE will create implicit sequence “media_id_seq” for
serial column "media.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "media_pkey"
for table “media”
-> 0.0027s
== CreateMedia: migrated (0.0152s)

== CreateDomains: migrating

– create_table(:domains)
NOTICE: CREATE TABLE will create implicit sequence “domains_id_seq” for
serial column “domains.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"domains_pkey” for table “domains”
-> 0.0038s
== CreateDomains: migrated (0.0038s)

== CreateSubnets: migrating

– create_table(:subnets)
NOTICE: CREATE TABLE will create implicit sequence “subnets_id_seq” for
serial column “subnets.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"subnets_pkey” for table “subnets”
-> 0.0038s
== CreateSubnets: migrated (0.0038s)

== CreateOperatingsystems: migrating

– create_table(:operatingsystems)
NOTICE: CREATE TABLE will create implicit sequence
"operatingsystems_id_seq" for serial column “operatingsystems.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"operatingsystems_pkey” for table “operatingsystems”
-> 0.0026s
== CreateOperatingsystems: migrated (0.0027s)

== CreateModels: migrating

– create_table(:models)
NOTICE: CREATE TABLE will create implicit sequence “models_id_seq” for
serial column "models.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "models_pkey"
for table “models”
-> 0.0035s
– add_column(:hosts, :model_id, :integer)
-> 0.0003s
== CreateModels: migrated (0.0039s)

== CreateEnvironments: migrating

– create_table(:environments)
NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq"
for serial column “environments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"environments_pkey” for table “environments”
-> 0.0023s
– create_table(:environments_puppetclasses, {:id=>false})
-> 0.0006s
== CreateEnvironments: migrated (0.0031s)

== CreateReports: migrating

– create_table(:reports)
NOTICE: CREATE TABLE will create implicit sequence “reports_id_seq” for
serial column “reports.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"reports_pkey” for table “reports”
-> 0.0035s
== CreateReports: migrated (0.0036s)

== CreatePtables: migrating

– create_table(:ptables)
NOTICE: CREATE TABLE will create implicit sequence “ptables_id_seq” for
serial column “ptables.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"ptables_pkey” for table “ptables”
-> 0.0038s
– create_table(:operatingsystems_ptables, {:id=>false})
-> 0.0006s
== CreatePtables: migrated (0.0134s)

== CreatePuppetclasses: migrating

– create_table(:puppetclasses)
NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq"
for serial column “puppetclasses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"puppetclasses_pkey” for table “puppetclasses”
-> 0.0039s
– create_table(:hosts_puppetclasses, {:id=>false})
-> 0.0006s
– create_table(:operatingsystems_puppetclasses, {:id=>false})
-> 0.0006s
== CreatePuppetclasses: migrated (0.0053s)

== CreateParameters: migrating

– create_table(:parameters)
NOTICE: CREATE TABLE will create implicit sequence “parameters_id_seq” for
serial column “parameters.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"parameters_pkey” for table “parameters”
-> 0.0039s
== CreateParameters: migrated (0.0040s)

== CreateAuthSources: migrating

– create_table(:auth_sources)
NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq"
for serial column “auth_sources.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"auth_sources_pkey” for table “auth_sources”
-> 0.0045s
== CreateAuthSources: migrated (0.0045s)

== CreateHostgroups: migrating

– create_table(:hostgroups)
NOTICE: CREATE TABLE will create implicit sequence “hostgroups_id_seq” for
serial column “hostgroups.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"hostgroups_pkey” for table “hostgroups”
-> 0.0024s
– create_table(:hostgroups_puppetclasses, {:id=>false})
-> 0.0006s
– add_column(:hosts, :hostgroup_id, :integer)
-> 0.0004s
– add_column(:parameters, :hostgroup_id, :integer)
-> 0.0003s
== CreateHostgroups: migrated (0.0040s)

== AddTypeToParameter: migrating

– add_column(:parameters, :type, :string)
-> 0.0003s
== AddTypeToParameter: migrated (0.0004s)

== AddDomainToParameter: migrating

– add_column(:parameters, :domain_id, :integer)
-> 0.0004s
== AddDomainToParameter: migrated (0.0005s)

== ChangeReportFieldTypeToText: migrating

== ChangeReportFieldTypeToText: migrated (0.0002s)

== ChangeHostBuildDefaultToFalse: migrating

– change_column(:hosts, :build, :boolean, {:default=>false})
-> 0.0064s
rake aborted!
An error has occurred, this and all later migrations canceled:

changes is defined by ActiveRecord
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in
instance_method_already_implemented?' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in
each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in
each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in
define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:inrespond_to?’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:ineach’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:ininitialize’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in
new' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:inbuild_association’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:500:in
create_record' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1127:inwith_scope’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in
send' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:increate_record’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:271:in
create' /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:inwrite_audit’
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:414:in
_run_audit_callbacks' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:insend’
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in
run_callbacks' /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:inwrite_audit’
/usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:206:in
audit_update' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:415:in_run_update_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:281:in
update' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:257:increate_or_update’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:273:in
create_or_update' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:519:in_run_save_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:273:in
create_or_update' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:40:insave’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/validations.rb:43:in
save' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods/dirty.rb:21:insave’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:240:in
save' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:292:inwith_transaction_returning_status’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:207:intransaction’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:290:in
with_transaction_returning_status' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:240:insave’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:251:in
rollback_active_record_state!' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/transactions.rb:239:insave’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:123:in
`update_attribute’
/usr/share/foreman/db/migrate/20090916053824_change_host_build_defau

> Hello,
>
> An error occur during "db:migrate" if Foreman database is shared with
> Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I
> tried with both MySQL and Postgresql. On a different setup, upgrade from
> 0.4 to 1.0 is OK even with an existant database.
>
> Some relevant information:
>
> - There is a problem with 2 files:
>
> /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb
> /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb
>
> - Theses files are identical in /usr/share/foreman/migrate in version 0.4
> and 1.0
>
> - If I comment them, db:migrate is OK (but database is inconsistent)
>
> - If I delete "self" before "up" and "down" db:migrate is OK (I don't know
> what it implies as a Ruby newbie)
>
> Any ideas ? Thanks.
>
> Paul (fr)
>
>
> [root@puppet ~]# su - foreman -s /bin/bash -c
> /usr/share/foreman/extras/dbmigrate
> Libvirt binding are missing - hypervisor management is disabled
> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10:
> warning: already initialized constant ENC_NONE
> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11:
> warning: already initialized constant ENC_EUC
> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12:
> warning: already initialized constant ENC_SJIS
> /usr/lib/ruby/gems/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
> == CreateHosts: migrating
> ====================================================
> – add_column(:hosts, :mac, :string, {:default=>"", :limit=>17})
> -> 0.0010s
> – add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17})
> -> 0.0007s
> – add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15})
> -> 0.0007s
> – add_column(:hosts, :sp_name, :string, {:default=>""})
> -> 0.0006s
> – add_column(:hosts, :root_pass, :string, {:limit=>64})
> -> 0.0003s
> – add_column(:hosts, :serial, :string, {:limit=>12})
> -> 0.0003s
> – add_column(:hosts, :puppetmaster, :string)
> -> 0.0004s
> – add_column(:hosts, :puppet_status, :integer, {:null=>false,
> :default=>0})
> -> 0.0033s
> – add_column(:hosts, :domain_id, :integer)
> -> 0.0004s
> – add_column(:hosts, :architecture_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :operatingsystem_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :environment_id, :integer)
> -> 0.0004s
> – add_column(:hosts, :subnet_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :sp_subnet_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :ptable_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :medium_id, :integer)
> -> 0.0003s
> – add_column(:hosts, :build, :boolean, {:default=>true})
> -> 0.0006s
> – add_column(:hosts, :comment, :text)
> -> 0.0003s
> – add_column(:hosts, :disk, :text)
> -> 0.0004s
> – add_column(:hosts, :installed_at, :datetime)
> -> 0.0003s
> == CreateHosts: migrated (0.0137s)
> ===========================================
>
> == AddAuditsTable: migrating
> =================================================
> – create_table(:audits, {:force=>true})
> NOTICE: CREATE TABLE will create implicit sequence "audits_id_seq" for
> serial column "audits.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "audits_pkey" for table "audits"
> -> 0.0051s
> – add_index(:audits, [:auditable_id, :auditable_type],
> {:name=>"auditable_index"})
> -> 0.0019s
> – add_index(:audits, [:user_id, :user_type], {:name=>"user_index"})
> -> 0.0022s
> – add_index(:audits, :created_at)
> -> 0.0024s
> – add_index(:audits, [:auditable_parent_id, :auditable_parent_type],
> {:name=>"auditable_parent_index"})
> -> 0.0025s
> == AddAuditsTable: migrated (0.0143s)
> ========================================
>
> == CreateArchitectures: migrating
> ============================================
> – create_table(:architectures)
> NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq"
> for serial column "architectures.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "architectures_pkey" for table "architectures"
> -> 0.0029s
> – create_table(:architectures_operatingsystems, {:id=>false})
> -> 0.0005s
> == CreateArchitectures: migrated (0.0036s)
> ===================================
>
> == CreateMedia: migrating
> ====================================================
> – create_table(:media)
> NOTICE: CREATE TABLE will create implicit sequence "media_id_seq" for
> serial column "media.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "media_pkey"
> for table "media"
> -> 0.0027s
> == CreateMedia: migrated (0.0152s)
> ===========================================
>
> == CreateDomains: migrating
> ==================================================
> – create_table(:domains)
> NOTICE: CREATE TABLE will create implicit sequence "domains_id_seq" for
> serial column "domains.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "domains_pkey" for table "domains"
> -> 0.0038s
> == CreateDomains: migrated (0.0038s)
> =========================================
>
> == CreateSubnets: migrating
> ==================================================
> – create_table(:subnets)
> NOTICE: CREATE TABLE will create implicit sequence "subnets_id_seq" for
> serial column "subnets.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "subnets_pkey" for table "subnets"
> -> 0.0038s
> == CreateSubnets: migrated (0.0038s)
> =========================================
>
> == CreateOperatingsystems: migrating
> =========================================
> – create_table(:operatingsystems)
> NOTICE: CREATE TABLE will create implicit sequence
> "operatingsystems_id_seq" for serial column "operatingsystems.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "operatingsystems_pkey" for table "operatingsystems"
> -> 0.0026s
> == CreateOperatingsystems: migrated (0.0027s)
> ================================
>
> == CreateModels: migrating
> ===================================================
> – create_table(:models)
> NOTICE: CREATE TABLE will create implicit sequence "models_id_seq" for
> serial column "models.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "models_pkey" for table "models"
> -> 0.0035s
> – add_column(:hosts, :model_id, :integer)
> -> 0.0003s
> == CreateModels: migrated (0.0039s)
> ==========================================
>
> == CreateEnvironments: migrating
> =============================================
> – create_table(:environments)
> NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq"
> for serial column "environments.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "environments_pkey" for table "environments"
> -> 0.0023s
> – create_table(:environments_puppetclasses, {:id=>false})
> -> 0.0006s
> == CreateEnvironments: migrated (0.0031s)
> ====================================
>
> == CreateReports: migrating
> ==================================================
> – create_table(:reports)
> NOTICE: CREATE TABLE will create implicit sequence "reports_id_seq" for
> serial column "reports.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "reports_pkey" for table "reports"
> -> 0.0035s
> == CreateReports: migrated (0.0036s)
> =========================================
>
> == CreatePtables: migrating
> ==================================================
> – create_table(:ptables)
> NOTICE: CREATE TABLE will create implicit sequence "ptables_id_seq" for
> serial column "ptables.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "ptables_pkey" for table "ptables"
> -> 0.0038s
> – create_table(:operatingsystems_ptables, {:id=>false})
> -> 0.0006s
> == CreatePtables: migrated (0.0134s)
> =========================================
>
> == CreatePuppetclasses: migrating
> ============================================
> – create_table(:puppetclasses)
> NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq"
> for serial column "puppetclasses.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "puppetclasses_pkey" for table "puppetclasses"
> -> 0.0039s
> – create_table(:hosts_puppetclasses, {:id=>false})
> -> 0.0006s
> – create_table(:operatingsystems_puppetclasses, {:id=>false})
> -> 0.0006s
> == CreatePuppetclasses: migrated (0.0053s)
> ===================================
>
> == CreateParameters: migrating
> ===============================================
> – create_table(:parameters)
> NOTICE: CREATE TABLE will create implicit sequence "parameters_id_seq" for
> serial column "parameters.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "parameters_pkey" for table "parameters"
> -> 0.0039s
> == CreateParameters: migrated (0.0040s)
> ======================================
>
> == CreateAuthSources: migrating
> ==============================================
> – create_table(:auth_sources)
> NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq"
> for serial column "auth_sources.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "auth_sources_pkey" for table "auth_sources"
> -> 0.0045s
> == CreateAuthSources: migrated (0.0045s)
> =====================================
>
> == CreateHostgroups: migrating
> ===============================================
> – create_table(:hostgroups)
> NOTICE: CREATE TABLE will create implicit sequence "hostgroups_id_seq" for
> serial column "hostgroups.id"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "hostgroups_pkey" for table "hostgroups"
> -> 0.0024s
> – create_table(:hostgroups_puppetclasses, {:id=>false})
> -> 0.0006s
> – add_column(:hosts, :hostgroup_id, :integer)
> -> 0.0004s
> – add_column(:parameters, :hostgroup_id, :integer)
> -> 0.0003s
> == CreateHostgroups: migrated (0.0040s)
> ======================================
>
> == AddTypeToParameter: migrating
> =============================================
> – add_column(:parameters, :type, :string)
> -> 0.0003s
> == AddTypeToParameter: migrated (0.0004s)
> ====================================
>
> == AddDomainToParameter: migrating
> ===========================================
> – add_column(:parameters, :domain_id, :integer)
> -> 0.0004s
> == AddDomainToParameter: migrated (0.0005s)
> ==================================
>
> == ChangeReportFieldTypeToText: migrating
> ====================================
> == ChangeReportFieldTypeToText: migrated (0.0002s)
> ===========================
>
> == ChangeHostBuildDefaultToFalse: migrating
> ==================================
> – change_column(:hosts, :build, :boolean, {:default=>false})
> -> 0.0064s
> rake aborted!
> An error has occurred, this and all later migrations canceled:
>
> changes is defined by ActiveRecord
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in
> instance_method_already_implemented?' > /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:in >define_attribute_methods'
> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in
> each' > /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >define_attribute_methods'
> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in
> each' > /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >define_attribute_methods'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in
> define_attribute_methods' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:in >respond_to?'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
> populate_with_current_scope_attributes' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >each'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
> populate_with_current_scope_attributes' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:in >initialize'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in
> new' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in >build_association'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:500:in
> create_record' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1127:in >with_scope'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in
> send' > /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in >create_record'
> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:271:in
> create' > /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >write_audit'
> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:414:in
> _run_audit_callbacks' > /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in >send'
> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in
> run_callbacks' > /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >write_audit'
> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:206:

··· On Thu, Aug 9, 2012 at 3:45 PM, p.ochon wrote:

@Lard: I found this solution but it's hard to explain to boss that we have
to loose data when we do a fresh install whereas we don't in case of
upgrade from 0.4 to 1.0 :S

@Brian & Sam: Yes reproductable on Postgres and MySQL so not a mysql gem
issue. More probably an activerecord one which some versions are known to
be not compatible with Puppet. But it isn't the case of version 3.0.15
(dependency of version 1.0) so what ??

It's reproducable on both Postgres and MySQL so I don't think that's the
issue.

I am going to debug this later today and will report back.

-Sam

··· On Thu, Aug 9, 2012 at 8:45 AM, p.ochon wrote:

Hello,

An error occur during “db:migrate” if Foreman database is shared with
Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried
with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to
1.0 is OK even with an existant database.

Some relevant information:

  • There is a problem with 2 files:

/usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb
/usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb

  • Theses files are identical in /usr/share/foreman/migrate in version 0.4
    and 1.0

  • If I comment them, db:migrate is OK (but database is inconsistent)

  • If I delete “self” before “up” and “down” db:migrate is OK (I don’t know
    what it implies as a Ruby newbie)

Any ideas ? Thanks.

Paul (fr)

[root@puppet ~]# su - foreman -s /bin/bash -c
/usr/share/foreman/extras/dbmigrate
Libvirt binding are missing - hypervisor management is disabled
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10:
warning: already initialized constant ENC_NONE
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11:
warning: already initialized constant ENC_EUC
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12:
warning: already initialized constant ENC_SJIS
/usr/lib/ruby/gems/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
== CreateHosts: migrating

– add_column(:hosts, :mac, :string, {:default=>"", :limit=>17})
-> 0.0010s
– add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17})
-> 0.0007s
– add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15})
-> 0.0007s
– add_column(:hosts, :sp_name, :string, {:default=>""})
-> 0.0006s
– add_column(:hosts, :root_pass, :string, {:limit=>64})
-> 0.0003s
– add_column(:hosts, :serial, :string, {:limit=>12})
-> 0.0003s
– add_column(:hosts, :puppetmaster, :string)
-> 0.0004s
– add_column(:hosts, :puppet_status, :integer, {:null=>false,
:default=>0})
-> 0.0033s
– add_column(:hosts, :domain_id, :integer)
-> 0.0004s
– add_column(:hosts, :architecture_id, :integer)
-> 0.0003s
– add_column(:hosts, :operatingsystem_id, :integer)
-> 0.0003s
– add_column(:hosts, :environment_id, :integer)
-> 0.0004s
– add_column(:hosts, :subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :sp_subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :ptable_id, :integer)
-> 0.0003s
– add_column(:hosts, :medium_id, :integer)
-> 0.0003s
– add_column(:hosts, :build, :boolean, {:default=>true})
-> 0.0006s
– add_column(:hosts, :comment, :text)
-> 0.0003s
– add_column(:hosts, :disk, :text)
-> 0.0004s
– add_column(:hosts, :installed_at, :datetime)
-> 0.0003s
== CreateHosts: migrated (0.0137s)

== AddAuditsTable: migrating

– create_table(:audits, {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence “audits_id_seq” for
serial column “audits.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"audits_pkey” for table “audits”
-> 0.0051s
– add_index(:audits, [:auditable_id, :auditable_type],
{:name=>“auditable_index”})
-> 0.0019s
– add_index(:audits, [:user_id, :user_type], {:name=>“user_index”})
-> 0.0022s
– add_index(:audits, :created_at)
-> 0.0024s
– add_index(:audits, [:auditable_parent_id, :auditable_parent_type],
{:name=>“auditable_parent_index”})
-> 0.0025s
== AddAuditsTable: migrated (0.0143s)

== CreateArchitectures: migrating

– create_table(:architectures)
NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq"
for serial column “architectures.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"architectures_pkey” for table “architectures”
-> 0.0029s
– create_table(:architectures_operatingsystems, {:id=>false})
-> 0.0005s
== CreateArchitectures: migrated (0.0036s)

== CreateMedia: migrating

– create_table(:media)
NOTICE: CREATE TABLE will create implicit sequence “media_id_seq” for
serial column "media.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "media_pkey"
for table “media”
-> 0.0027s
== CreateMedia: migrated (0.0152s)

== CreateDomains: migrating

– create_table(:domains)
NOTICE: CREATE TABLE will create implicit sequence “domains_id_seq” for
serial column “domains.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"domains_pkey” for table “domains”
-> 0.0038s
== CreateDomains: migrated (0.0038s)

== CreateSubnets: migrating

– create_table(:subnets)
NOTICE: CREATE TABLE will create implicit sequence “subnets_id_seq” for
serial column “subnets.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"subnets_pkey” for table “subnets”
-> 0.0038s
== CreateSubnets: migrated (0.0038s)

== CreateOperatingsystems: migrating

– create_table(:operatingsystems)
NOTICE: CREATE TABLE will create implicit sequence
"operatingsystems_id_seq" for serial column “operatingsystems.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"operatingsystems_pkey” for table “operatingsystems”
-> 0.0026s
== CreateOperatingsystems: migrated (0.0027s)

== CreateModels: migrating

– create_table(:models)
NOTICE: CREATE TABLE will create implicit sequence “models_id_seq” for
serial column “models.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"models_pkey” for table “models”
-> 0.0035s
– add_column(:hosts, :model_id, :integer)
-> 0.0003s
== CreateModels: migrated (0.0039s)

== CreateEnvironments: migrating

– create_table(:environments)
NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq"
for serial column “environments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"environments_pkey” for table “environments”
-> 0.0023s
– create_table(:environments_puppetclasses, {:id=>false})
-> 0.0006s
== CreateEnvironments: migrated (0.0031s)

== CreateReports: migrating

– create_table(:reports)
NOTICE: CREATE TABLE will create implicit sequence “reports_id_seq” for
serial column “reports.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"reports_pkey” for table “reports”
-> 0.0035s
== CreateReports: migrated (0.0036s)

== CreatePtables: migrating

– create_table(:ptables)
NOTICE: CREATE TABLE will create implicit sequence “ptables_id_seq” for
serial column “ptables.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"ptables_pkey” for table “ptables”
-> 0.0038s
– create_table(:operatingsystems_ptables, {:id=>false})
-> 0.0006s
== CreatePtables: migrated (0.0134s)

== CreatePuppetclasses: migrating

– create_table(:puppetclasses)
NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq"
for serial column “puppetclasses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"puppetclasses_pkey” for table “puppetclasses”
-> 0.0039s
– create_table(:hosts_puppetclasses, {:id=>false})
-> 0.0006s
– create_table(:operatingsystems_puppetclasses, {:id=>false})
-> 0.0006s
== CreatePuppetclasses: migrated (0.0053s)

== CreateParameters: migrating

– create_table(:parameters)
NOTICE: CREATE TABLE will create implicit sequence “parameters_id_seq” for
serial column “parameters.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"parameters_pkey” for table “parameters”
-> 0.0039s
== CreateParameters: migrated (0.0040s)

== CreateAuthSources: migrating

– create_table(:auth_sources)
NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq"
for serial column “auth_sources.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"auth_sources_pkey” for table “auth_sources”
-> 0.0045s
== CreateAuthSources: migrated (0.0045s)

== CreateHostgroups: migrating

– create_table(:hostgroups)
NOTICE: CREATE TABLE will create implicit sequence “hostgroups_id_seq” for
serial column “hostgroups.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"hostgroups_pkey” for table “hostgroups”
-> 0.0024s
– create_table(:hostgroups_puppetclasses, {:id=>false})
-> 0.0006s
– add_column(:hosts, :hostgroup_id, :integer)
-> 0.0004s
– add_column(:parameters, :hostgroup_id, :integer)
-> 0.0003s
== CreateHostgroups: migrated (0.0040s)

== AddTypeToParameter: migrating

– add_column(:parameters, :type, :string)
-> 0.0003s
== AddTypeToParameter: migrated (0.0004s)

== AddDomainToParameter: migrating

– add_column(:parameters, :domain_id, :integer)
-> 0.0004s
== AddDomainToParameter: migrated (0.0005s)

== ChangeReportFieldTypeToText: migrating

== ChangeReportFieldTypeToText: migrated (0.0002s)

== ChangeHostBuildDefaultToFalse: migrating

– change_column(:hosts, :build, :boolean, {:default=>false})
-> 0.0064s
rake aborted!
An error has occurred, this and all later migrations canceled:

changes is defined by ActiveRecord
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in
instance_method_already_implemented?' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in
each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in
each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in
define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:inrespond_to?’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:ineach’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in
populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:ininitialize’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in
new' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:inbuild_association’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:500:in
create_record' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1127:inwith_scope’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in
send' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:increate_record’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:271:in
create' /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:inwrite_audit’
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:414:in
_run_audit_callbacks' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:insend’
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in
run_callbacks' /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:inwrite_audit’
/usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:206:in
audit_update' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:415:in_run_update_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:281:in
`update’
/usr/lib/ruby/gems/1.8/gems/activereco

>
>
>
>
>> Hello,
>
>
<snip>

> rake aborted!
>> An error has occurred, this and all later migrations canceled:
>>
>> changes is defined by ActiveRecord
>>
>
> my guess is that you have some leftovers in your foreman dir, double check
> you dont have any directories in foreman/vendor.
>
> if thats not the case, we might need to force not to run auditing while we
> are in migrations.
>
>
I ran into this exact problem with a fresh Foreman install sharing the
database with my puppet 3 test box.

I was using the Ubuntu packages, which does install into foreman/vendor.

··· On Thursday, August 9, 2012 7:56:04 AM UTC-5, ohad wrote: > On Thu, Aug 9, 2012 at 3:45 PM, p.ochon <ochon...@gmail.com >wrote:

Ohad

It was a fresh install, no /usr/share/foreman/vendor directory.

Puppet/Foreman db shared
0.4 -> 1.0 : OK
null -> 1.0 : NOK

Puppet/Foreman db separated
0.4 -> 1.0 : OK
null -> 1.0 : OK

Also tried to pick all migration scripts of version 0.4 + the difference to
version 1.0 (from 20111124095053_rename_changes_to_audited_changes) with no
success.

··· Le jeudi 9 août 2012 14:56:04 UTC+2, ohad a écrit : > > > > On Thu, Aug 9, 2012 at 3:45 PM, p.ochon <ochon...@gmail.com >wrote: > >> Hello, >> >> An error occur during "db:migrate" if Foreman database is shared with >> Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I >> tried with both MySQL and Postgresql. On a different setup, upgrade from >> 0.4 to 1.0 is OK even with an existant database. >> >> Some relevant information: >> >> - There is a problem with 2 files: >> >> /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb >> /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb >> >> - Theses files are identical in /usr/share/foreman/migrate in version 0.4 >> and 1.0 >> >> - If I comment them, db:migrate is OK (but database is inconsistent) >> >> - If I delete "self" before "up" and "down" db:migrate is OK (I don't >> know what it implies as a Ruby newbie) >> >> Any ideas ? Thanks. >> >> Paul (fr) >> >> >> [root@puppet ~]# su - foreman -s /bin/bash -c >> /usr/share/foreman/extras/dbmigrate >> Libvirt binding are missing - hypervisor management is disabled >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: >> warning: already initialized constant ENC_NONE >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: >> warning: already initialized constant ENC_EUC >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: >> warning: already initialized constant ENC_SJIS >> /usr/lib/ruby/gems/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 >> == CreateHosts: migrating >> ==================================================== >> -- add_column(:hosts, :mac, :string, {:default=>"", :limit=>17}) >> -> 0.0010s >> -- add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17}) >> -> 0.0007s >> -- add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15}) >> -> 0.0007s >> -- add_column(:hosts, :sp_name, :string, {:default=>""}) >> -> 0.0006s >> -- add_column(:hosts, :root_pass, :string, {:limit=>64}) >> -> 0.0003s >> -- add_column(:hosts, :serial, :string, {:limit=>12}) >> -> 0.0003s >> -- add_column(:hosts, :puppetmaster, :string) >> -> 0.0004s >> -- add_column(:hosts, :puppet_status, :integer, {:null=>false, >> :default=>0}) >> -> 0.0033s >> -- add_column(:hosts, :domain_id, :integer) >> -> 0.0004s >> -- add_column(:hosts, :architecture_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :operatingsystem_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :environment_id, :integer) >> -> 0.0004s >> -- add_column(:hosts, :subnet_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :sp_subnet_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :ptable_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :medium_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :build, :boolean, {:default=>true}) >> -> 0.0006s >> -- add_column(:hosts, :comment, :text) >> -> 0.0003s >> -- add_column(:hosts, :disk, :text) >> -> 0.0004s >> -- add_column(:hosts, :installed_at, :datetime) >> -> 0.0003s >> == CreateHosts: migrated (0.0137s) >> =========================================== >> >> == AddAuditsTable: migrating >> ================================================= >> -- create_table(:audits, {:force=>true}) >> NOTICE: CREATE TABLE will create implicit sequence "audits_id_seq" for >> serial column "audits.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "audits_pkey" for table "audits" >> -> 0.0051s >> -- add_index(:audits, [:auditable_id, :auditable_type], >> {:name=>"auditable_index"}) >> -> 0.0019s >> -- add_index(:audits, [:user_id, :user_type], {:name=>"user_index"}) >> -> 0.0022s >> -- add_index(:audits, :created_at) >> -> 0.0024s >> -- add_index(:audits, [:auditable_parent_id, :auditable_parent_type], >> {:name=>"auditable_parent_index"}) >> -> 0.0025s >> == AddAuditsTable: migrated (0.0143s) >> ======================================== >> >> == CreateArchitectures: migrating >> ============================================ >> -- create_table(:architectures) >> NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq" >> for serial column "architectures.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "architectures_pkey" for table "architectures" >> -> 0.0029s >> -- create_table(:architectures_operatingsystems, {:id=>false}) >> -> 0.0005s >> == CreateArchitectures: migrated (0.0036s) >> =================================== >> >> == CreateMedia: migrating >> ==================================================== >> -- create_table(:media) >> NOTICE: CREATE TABLE will create implicit sequence "media_id_seq" for >> serial column "media.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "media_pkey" for table "media" >> -> 0.0027s >> == CreateMedia: migrated (0.0152s) >> =========================================== >> >> == CreateDomains: migrating >> ================================================== >> -- create_table(:domains) >> NOTICE: CREATE TABLE will create implicit sequence "domains_id_seq" for >> serial column "domains.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "domains_pkey" for table "domains" >> -> 0.0038s >> == CreateDomains: migrated (0.0038s) >> ========================================= >> >> == CreateSubnets: migrating >> ================================================== >> -- create_table(:subnets) >> NOTICE: CREATE TABLE will create implicit sequence "subnets_id_seq" for >> serial column "subnets.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "subnets_pkey" for table "subnets" >> -> 0.0038s >> == CreateSubnets: migrated (0.0038s) >> ========================================= >> >> == CreateOperatingsystems: migrating >> ========================================= >> -- create_table(:operatingsystems) >> NOTICE: CREATE TABLE will create implicit sequence >> "operatingsystems_id_seq" for serial column "operatingsystems.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "operatingsystems_pkey" for table "operatingsystems" >> -> 0.0026s >> == CreateOperatingsystems: migrated (0.0027s) >> ================================ >> >> == CreateModels: migrating >> =================================================== >> -- create_table(:models) >> NOTICE: CREATE TABLE will create implicit sequence "models_id_seq" for >> serial column "models.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "models_pkey" for table "models" >> -> 0.0035s >> -- add_column(:hosts, :model_id, :integer) >> -> 0.0003s >> == CreateModels: migrated (0.0039s) >> ========================================== >> >> == CreateEnvironments: migrating >> ============================================= >> -- create_table(:environments) >> NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq" >> for serial column "environments.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "environments_pkey" for table "environments" >> -> 0.0023s >> -- create_table(:environments_puppetclasses, {:id=>false}) >> -> 0.0006s >> == CreateEnvironments: migrated (0.0031s) >> ==================================== >> >> == CreateReports: migrating >> ================================================== >> -- create_table(:reports) >> NOTICE: CREATE TABLE will create implicit sequence "reports_id_seq" for >> serial column "reports.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "reports_pkey" for table "reports" >> -> 0.0035s >> == CreateReports: migrated (0.0036s) >> ========================================= >> >> == CreatePtables: migrating >> ================================================== >> -- create_table(:ptables) >> NOTICE: CREATE TABLE will create implicit sequence "ptables_id_seq" for >> serial column "ptables.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "ptables_pkey" for table "ptables" >> -> 0.0038s >> -- create_table(:operatingsystems_ptables, {:id=>false}) >> -> 0.0006s >> == CreatePtables: migrated (0.0134s) >> ========================================= >> >> == CreatePuppetclasses: migrating >> ============================================ >> -- create_table(:puppetclasses) >> NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq" >> for serial column "puppetclasses.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "puppetclasses_pkey" for table "puppetclasses" >> -> 0.0039s >> -- create_table(:hosts_puppetclasses, {:id=>false}) >> -> 0.0006s >> -- create_table(:operatingsystems_puppetclasses, {:id=>false}) >> -> 0.0006s >> == CreatePuppetclasses: migrated (0.0053s) >> =================================== >> >> == CreateParameters: migrating >> =============================================== >> -- create_table(:parameters) >> NOTICE: CREATE TABLE will create implicit sequence "parameters_id_seq" >> for serial column "parameters.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "parameters_pkey" for table "parameters" >> -> 0.0039s >> == CreateParameters: migrated (0.0040s) >> ====================================== >> >> == CreateAuthSources: migrating >> ============================================== >> -- create_table(:auth_sources) >> NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq" >> for serial column "auth_sources.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "auth_sources_pkey" for table "auth_sources" >> -> 0.0045s >> == CreateAuthSources: migrated (0.0045s) >> ===================================== >> >> == CreateHostgroups: migrating >> =============================================== >> -- create_table(:hostgroups) >> NOTICE: CREATE TABLE will create implicit sequence "hostgroups_id_seq" >> for serial column "hostgroups.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "hostgroups_pkey" for table "hostgroups" >> -> 0.0024s >> -- create_table(:hostgroups_puppetclasses, {:id=>false}) >> -> 0.0006s >> -- add_column(:hosts, :hostgroup_id, :integer) >> -> 0.0004s >> -- add_column(:parameters, :hostgroup_id, :integer) >> -> 0.0003s >> == CreateHostgroups: migrated (0.0040s) >> ====================================== >> >> == AddTypeToParameter: migrating >> ============================================= >> -- add_column(:parameters, :type, :string) >> -> 0.0003s >> == AddTypeToParameter: migrated (0.0004s) >> ==================================== >> >> == AddDomainToParameter: migrating >> =========================================== >> -- add_column(:parameters, :domain_id, :integer) >> -> 0.0004s >> == AddDomainToParameter: migrated (0.0005s) >> ================================== >> >> == ChangeReportFieldTypeToText: migrating >> ==================================== >> == ChangeReportFieldTypeToText: migrated (0.0002s) >> =========================== >> >> == ChangeHostBuildDefaultToFalse: migrating >> ================================== >> -- change_column(:hosts, :build, :boolean, {:default=>false}) >> -> 0.0064s >> rake aborted! >> An error has occurred, this and all later migrations canceled: >> >> changes is defined by ActiveRecord >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in >> `instance_method_already_implemented?' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:in >> `respond_to?' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `populate_with_current_scope_attributes' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `populate_with_current_scope_attributes' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:in >> `initialize' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in >> `new' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in >> `build_association' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:500:in >> `create_record' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1127:in >> `with_scope' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in >> `send' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in >> `create_record' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:271:in >> `create' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >> `write_audit' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:414:in >> `_run_audit_callbacks' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in >> `send' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in >> `run_callbacks' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >> `write_audit' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:206:in >> `audit_update' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:415:in >> `_run_update_callbacks' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:281:in >> `update' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:257:

Hey,

I had the exact same problem.
Assuming you are not interested in your already existing storeconfigs. Initialise the foreman db first (on a fresh db) and then set puppet to that database. It's something to do with rails v3 which foreman 1 uses.

I think that's how i fixed it at least.

Cheers,

Lard

··· On 09/08/2012, at 11:36 PM, p.ochon wrote:

It was a fresh install, no /usr/share/foreman/vendor directory.

Puppet/Foreman db shared
0.4 -> 1.0 : OK
null -> 1.0 : NOK

Puppet/Foreman db separated
0.4 -> 1.0 : OK
null -> 1.0 : OK

Also tried to pick all migration scripts of version 0.4 + the difference to version 1.0 (from 20111124095053_rename_changes_to_audited_changes) with no success.

Le jeudi 9 août 2012 14:56:04 UTC+2, ohad a écrit :

On Thu, Aug 9, 2012 at 3:45 PM, p.ochon ochon...@gmail.com wrote:
Hello,

An error occur during “db:migrate” if Foreman database is shared with Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to 1.0 is OK even with an existant database.

Some relevant information:

  • There is a problem with 2 files:
    /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb
    /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb

  • Theses files are identical in /usr/share/foreman/migrate in version 0.4 and 1.0

  • If I comment them, db:migrate is OK (but database is inconsistent)

  • If I delete “self” before “up” and “down” db:migrate is OK (I don’t know what it implies as a Ruby newbie)

Any ideas ? Thanks.

Paul (fr)

[root@puppet ~]# su - foreman -s /bin/bash -c /usr/share/foreman/extras/dbmigrate
Libvirt binding are missing - hypervisor management is disabled
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: warning: already initialized constant ENC_NONE
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: warning: already initialized constant ENC_EUC
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: warning: already initialized constant ENC_SJIS
/usr/lib/ruby/gems/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
== CreateHosts: migrating ====================================================
– add_column(:hosts, :mac, :string, {:default=>"", :limit=>17})
-> 0.0010s
– add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17})
-> 0.0007s
– add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15})
-> 0.0007s
– add_column(:hosts, :sp_name, :string, {:default=>""})
-> 0.0006s
– add_column(:hosts, :root_pass, :string, {:limit=>64})
-> 0.0003s
– add_column(:hosts, :serial, :string, {:limit=>12})
-> 0.0003s
– add_column(:hosts, :puppetmaster, :string)
-> 0.0004s
– add_column(:hosts, :puppet_status, :integer, {:null=>false, :default=>0})
-> 0.0033s
– add_column(:hosts, :domain_id, :integer)
-> 0.0004s
– add_column(:hosts, :architecture_id, :integer)
-> 0.0003s
– add_column(:hosts, :operatingsystem_id, :integer)
-> 0.0003s
– add_column(:hosts, :environment_id, :integer)
-> 0.0004s
– add_column(:hosts, :subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :sp_subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :ptable_id, :integer)
-> 0.0003s
– add_column(:hosts, :medium_id, :integer)
-> 0.0003s
– add_column(:hosts, :build, :boolean, {:default=>true})
-> 0.0006s
– add_column(:hosts, :comment, :text)
-> 0.0003s
– add_column(:hosts, :disk, :text)
-> 0.0004s
– add_column(:hosts, :installed_at, :datetime)
-> 0.0003s
== CreateHosts: migrated (0.0137s) ===========================================

== AddAuditsTable: migrating =================================================
– create_table(:audits, {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence “audits_id_seq” for serial column "audits.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “audits_pkey” for table “audits”
-> 0.0051s
– add_index(:audits, [:auditable_id, :auditable_type], {:name=>“auditable_index”})
-> 0.0019s
– add_index(:audits, [:user_id, :user_type], {:name=>“user_index”})
-> 0.0022s
– add_index(:audits, :created_at)
-> 0.0024s
– add_index(:audits, [:auditable_parent_id, :auditable_parent_type], {:name=>“auditable_parent_index”})
-> 0.0025s
== AddAuditsTable: migrated (0.0143s) ========================================

== CreateArchitectures: migrating ============================================
– create_table(:architectures)
NOTICE: CREATE TABLE will create implicit sequence “architectures_id_seq” for serial column "architectures.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “architectures_pkey” for table “architectures”
-> 0.0029s
– create_table(:architectures_operatingsystems, {:id=>false})
-> 0.0005s
== CreateArchitectures: migrated (0.0036s) ===================================

== CreateMedia: migrating ====================================================
– create_table(:media)
NOTICE: CREATE TABLE will create implicit sequence “media_id_seq” for serial column "media.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “media_pkey” for table “media”
-> 0.0027s
== CreateMedia: migrated (0.0152s) ===========================================

== CreateDomains: migrating ==================================================
– create_table(:domains)
NOTICE: CREATE TABLE will create implicit sequence “domains_id_seq” for serial column "domains.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “domains_pkey” for table “domains”
-> 0.0038s
== CreateDomains: migrated (0.0038s) =========================================

== CreateSubnets: migrating ==================================================
– create_table(:subnets)
NOTICE: CREATE TABLE will create implicit sequence “subnets_id_seq” for serial column "subnets.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “subnets_pkey” for table “subnets”
-> 0.0038s
== CreateSubnets: migrated (0.0038s) =========================================

== CreateOperatingsystems: migrating =========================================
– create_table(:operatingsystems)
NOTICE: CREATE TABLE will create implicit sequence “operatingsystems_id_seq” for serial column "operatingsystems.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “operatingsystems_pkey” for table “operatingsystems”
-> 0.0026s
== CreateOperatingsystems: migrated (0.0027s) ================================

== CreateModels: migrating ===================================================
– create_table(:models)
NOTICE: CREATE TABLE will create implicit sequence “models_id_seq” for serial column "models.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “models_pkey” for table “models”
-> 0.0035s
– add_column(:hosts, :model_id, :integer)
-> 0.0003s
== CreateModels: migrated (0.0039s) ==========================================

== CreateEnvironments: migrating =============================================
– create_table(:environments)
NOTICE: CREATE TABLE will create implicit sequence “environments_id_seq” for serial column "environments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “environments_pkey” for table “environments”
-> 0.0023s
– create_table(:environments_puppetclasses, {:id=>false})
-> 0.0006s
== CreateEnvironments: migrated (0.0031s) ====================================

== CreateReports: migrating ==================================================
– create_table(:reports)
NOTICE: CREATE TABLE will create implicit sequence “reports_id_seq” for serial column "reports.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “reports_pkey” for table “reports”
-> 0.0035s
== CreateReports: migrated (0.0036s) =========================================

== CreatePtables: migrating ==================================================
– create_table(:ptables)
NOTICE: CREATE TABLE will create implicit sequence “ptables_id_seq” for serial column "ptables.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “ptables_pkey” for table “ptables”
-> 0.0038s
– create_table(:operatingsystems_ptables, {:id=>false})
-> 0.0006s
== CreatePtables: migrated (0.0134s) =========================================

== CreatePuppetclasses: migrating ============================================
– create_table(:puppetclasses)
NOTICE: CREATE TABLE will create implicit sequence “puppetclasses_id_seq” for serial column "puppetclasses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “puppetclasses_pkey” for table “puppetclasses”
-> 0.0039s
– create_table(:hosts_puppetclasses, {:id=>false})
-> 0.0006s
– create_table(:operatingsystems_puppetclasses, {:id=>false})
-> 0.0006s
== CreatePuppetclasses: migrated (0.0053s) ===================================

== CreateParameters: migrating ===============================================
– create_table(:parameters)
NOTICE: CREATE TABLE will create implicit sequence “parameters_id_seq” for serial column "parameters.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “parameters_pkey” for table “parameters”
-> 0.0039s
== CreateParameters: migrated (0.0040s) ======================================

== CreateAuthSources: migrating ==============================================
– create_table(:auth_sources)
NOTICE: CREATE TABLE will create implicit sequence “auth_sources_id_seq” for serial column "auth_sources.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “auth_sources_pkey” for table “auth_sources”
-> 0.0045s
== CreateAuthSources: migrated (0.0045s) =====================================

== CreateHostgroups: migrating ===============================================
– create_table(:hostgroups)
NOTICE: CREATE TABLE will create implicit sequence “hostgroups_id_seq” for serial column "hostgroups.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index “hostgroups_pkey” for table “hostgroups”
-> 0.0024s
– create_table(:hostgroups_puppetclasses, {:id=>false})
-> 0.0006s
– add_column(:hosts, :hostgroup_id, :integer)
-> 0.0004s
– add_column(:parameters, :hostgroup_id, :integer)
-> 0.0003s
== CreateHostgroups: migrated (0.0040s) ======================================

== AddTypeToParameter: migrating =============================================
– add_column(:parameters, :type, :string)
-> 0.0003s
== AddTypeToParameter: migrated (0.0004s) ====================================

== AddDomainToParameter: migrating ===========================================
– add_column(:parameters, :domain_id, :integer)
-> 0.0004s
== AddDomainToParameter: migrated (0.0005s) ==================================

== ChangeReportFieldTypeToText: migrating ====================================
== ChangeReportFieldTypeToText: migrated (0.0002s) ===========================

== ChangeHostBuildDefaultToFalse: migrating ==================================
– change_column(:hosts, :build, :boolean, {:default=>false})
-> 0.0064s
rake aborted!
An error has occurred, this and all later migrations canceled:

changes is defined by ActiveRecord
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in instance_method_already_implemented?' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in each' /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:inrespond_to?’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:ineach’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in populate_with_current_scope_attributes' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:ininitialize’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in `new’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/act

Hello Sam,

Did you have the time to debug this issue ?

Cheers,

Paul

··· Le vendredi 10 août 2012 17:44:39 UTC+2, Sam Kottler a écrit : > > It's reproducable on both Postgres and MySQL so I don't think that's the > issue. > > I am going to debug this later today and will report back. > > -Sam > > On Thu, Aug 9, 2012 at 8:45 AM, p.ochon <ochon...@gmail.com >wrote: > >> Hello, >> >> An error occur during "db:migrate" if Foreman database is shared with >> Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried >> with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to >> 1.0 is OK even with an existant database. >> >> Some relevant information: >> >> - There is a problem with 2 files: >> >> /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb >> /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb >> >> - Theses files are identical in /usr/share/foreman/migrate in version 0.4 >> and 1.0 >> >> - If I comment them, db:migrate is OK (but database is inconsistent) >> >> - If I delete "self" before "up" and "down" db:migrate is OK (I don't >> know what it implies as a Ruby newbie) >> >> Any ideas ? Thanks. >> >> Paul (fr) >> >> >> [root@puppet ~]# su - foreman -s /bin/bash -c >> /usr/share/foreman/extras/dbmigrate >> Libvirt binding are missing - hypervisor management is disabled >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: >> warning: already initialized constant ENC_NONE >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: >> warning: already initialized constant ENC_EUC >> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: >> warning: already initialized constant ENC_SJIS >> /usr/lib/ruby/gems/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 >> == CreateHosts: migrating >> ==================================================== >> -- add_column(:hosts, :mac, :string, {:default=>"", :limit=>17}) >> -> 0.0010s >> -- add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17}) >> -> 0.0007s >> -- add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15}) >> -> 0.0007s >> -- add_column(:hosts, :sp_name, :string, {:default=>""}) >> -> 0.0006s >> -- add_column(:hosts, :root_pass, :string, {:limit=>64}) >> -> 0.0003s >> -- add_column(:hosts, :serial, :string, {:limit=>12}) >> -> 0.0003s >> -- add_column(:hosts, :puppetmaster, :string) >> -> 0.0004s >> -- add_column(:hosts, :puppet_status, :integer, {:null=>false, >> :default=>0}) >> -> 0.0033s >> -- add_column(:hosts, :domain_id, :integer) >> -> 0.0004s >> -- add_column(:hosts, :architecture_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :operatingsystem_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :environment_id, :integer) >> -> 0.0004s >> -- add_column(:hosts, :subnet_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :sp_subnet_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :ptable_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :medium_id, :integer) >> -> 0.0003s >> -- add_column(:hosts, :build, :boolean, {:default=>true}) >> -> 0.0006s >> -- add_column(:hosts, :comment, :text) >> -> 0.0003s >> -- add_column(:hosts, :disk, :text) >> -> 0.0004s >> -- add_column(:hosts, :installed_at, :datetime) >> -> 0.0003s >> == CreateHosts: migrated (0.0137s) >> =========================================== >> >> == AddAuditsTable: migrating >> ================================================= >> -- create_table(:audits, {:force=>true}) >> NOTICE: CREATE TABLE will create implicit sequence "audits_id_seq" for >> serial column "audits.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "audits_pkey" for table "audits" >> -> 0.0051s >> -- add_index(:audits, [:auditable_id, :auditable_type], >> {:name=>"auditable_index"}) >> -> 0.0019s >> -- add_index(:audits, [:user_id, :user_type], {:name=>"user_index"}) >> -> 0.0022s >> -- add_index(:audits, :created_at) >> -> 0.0024s >> -- add_index(:audits, [:auditable_parent_id, :auditable_parent_type], >> {:name=>"auditable_parent_index"}) >> -> 0.0025s >> == AddAuditsTable: migrated (0.0143s) >> ======================================== >> >> == CreateArchitectures: migrating >> ============================================ >> -- create_table(:architectures) >> NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq" >> for serial column "architectures.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "architectures_pkey" for table "architectures" >> -> 0.0029s >> -- create_table(:architectures_operatingsystems, {:id=>false}) >> -> 0.0005s >> == CreateArchitectures: migrated (0.0036s) >> =================================== >> >> == CreateMedia: migrating >> ==================================================== >> -- create_table(:media) >> NOTICE: CREATE TABLE will create implicit sequence "media_id_seq" for >> serial column "media.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "media_pkey" for table "media" >> -> 0.0027s >> == CreateMedia: migrated (0.0152s) >> =========================================== >> >> == CreateDomains: migrating >> ================================================== >> -- create_table(:domains) >> NOTICE: CREATE TABLE will create implicit sequence "domains_id_seq" for >> serial column "domains.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "domains_pkey" for table "domains" >> -> 0.0038s >> == CreateDomains: migrated (0.0038s) >> ========================================= >> >> == CreateSubnets: migrating >> ================================================== >> -- create_table(:subnets) >> NOTICE: CREATE TABLE will create implicit sequence "subnets_id_seq" for >> serial column "subnets.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "subnets_pkey" for table "subnets" >> -> 0.0038s >> == CreateSubnets: migrated (0.0038s) >> ========================================= >> >> == CreateOperatingsystems: migrating >> ========================================= >> -- create_table(:operatingsystems) >> NOTICE: CREATE TABLE will create implicit sequence >> "operatingsystems_id_seq" for serial column "operatingsystems.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "operatingsystems_pkey" for table "operatingsystems" >> -> 0.0026s >> == CreateOperatingsystems: migrated (0.0027s) >> ================================ >> >> == CreateModels: migrating >> =================================================== >> -- create_table(:models) >> NOTICE: CREATE TABLE will create implicit sequence "models_id_seq" for >> serial column "models.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "models_pkey" for table "models" >> -> 0.0035s >> -- add_column(:hosts, :model_id, :integer) >> -> 0.0003s >> == CreateModels: migrated (0.0039s) >> ========================================== >> >> == CreateEnvironments: migrating >> ============================================= >> -- create_table(:environments) >> NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq" >> for serial column "environments.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "environments_pkey" for table "environments" >> -> 0.0023s >> -- create_table(:environments_puppetclasses, {:id=>false}) >> -> 0.0006s >> == CreateEnvironments: migrated (0.0031s) >> ==================================== >> >> == CreateReports: migrating >> ================================================== >> -- create_table(:reports) >> NOTICE: CREATE TABLE will create implicit sequence "reports_id_seq" for >> serial column "reports.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "reports_pkey" for table "reports" >> -> 0.0035s >> == CreateReports: migrated (0.0036s) >> ========================================= >> >> == CreatePtables: migrating >> ================================================== >> -- create_table(:ptables) >> NOTICE: CREATE TABLE will create implicit sequence "ptables_id_seq" for >> serial column "ptables.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "ptables_pkey" for table "ptables" >> -> 0.0038s >> -- create_table(:operatingsystems_ptables, {:id=>false}) >> -> 0.0006s >> == CreatePtables: migrated (0.0134s) >> ========================================= >> >> == CreatePuppetclasses: migrating >> ============================================ >> -- create_table(:puppetclasses) >> NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq" >> for serial column "puppetclasses.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "puppetclasses_pkey" for table "puppetclasses" >> -> 0.0039s >> -- create_table(:hosts_puppetclasses, {:id=>false}) >> -> 0.0006s >> -- create_table(:operatingsystems_puppetclasses, {:id=>false}) >> -> 0.0006s >> == CreatePuppetclasses: migrated (0.0053s) >> =================================== >> >> == CreateParameters: migrating >> =============================================== >> -- create_table(:parameters) >> NOTICE: CREATE TABLE will create implicit sequence "parameters_id_seq" >> for serial column "parameters.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "parameters_pkey" for table "parameters" >> -> 0.0039s >> == CreateParameters: migrated (0.0040s) >> ====================================== >> >> == CreateAuthSources: migrating >> ============================================== >> -- create_table(:auth_sources) >> NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq" >> for serial column "auth_sources.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "auth_sources_pkey" for table "auth_sources" >> -> 0.0045s >> == CreateAuthSources: migrated (0.0045s) >> ===================================== >> >> == CreateHostgroups: migrating >> =============================================== >> -- create_table(:hostgroups) >> NOTICE: CREATE TABLE will create implicit sequence "hostgroups_id_seq" >> for serial column "hostgroups.id" >> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >> "hostgroups_pkey" for table "hostgroups" >> -> 0.0024s >> -- create_table(:hostgroups_puppetclasses, {:id=>false}) >> -> 0.0006s >> -- add_column(:hosts, :hostgroup_id, :integer) >> -> 0.0004s >> -- add_column(:parameters, :hostgroup_id, :integer) >> -> 0.0003s >> == CreateHostgroups: migrated (0.0040s) >> ====================================== >> >> == AddTypeToParameter: migrating >> ============================================= >> -- add_column(:parameters, :type, :string) >> -> 0.0003s >> == AddTypeToParameter: migrated (0.0004s) >> ==================================== >> >> == AddDomainToParameter: migrating >> =========================================== >> -- add_column(:parameters, :domain_id, :integer) >> -> 0.0004s >> == AddDomainToParameter: migrated (0.0005s) >> ================================== >> >> == ChangeReportFieldTypeToText: migrating >> ==================================== >> == ChangeReportFieldTypeToText: migrated (0.0002s) >> =========================== >> >> == ChangeHostBuildDefaultToFalse: migrating >> ================================== >> -- change_column(:hosts, :build, :boolean, {:default=>false}) >> -> 0.0064s >> rake aborted! >> An error has occurred, this and all later migrations canceled: >> >> changes is defined by ActiveRecord >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in >> `instance_method_already_implemented?' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in >> `define_attribute_methods' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:in >> `respond_to?' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `populate_with_current_scope_attributes' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `each' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >> `populate_with_current_scope_attributes' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1411:in >> `initialize' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in >> `new' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/reflection.rb:173:in >> `build_association' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:500:in >> `create_record' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1127:in >> `with_scope' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in >> `send' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:499:in >> `create_record' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/associations/association_collection.rb:271:in >> `create' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >> `write_audit' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:414:in >> `_run_audit_callbacks' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in >> `send' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:94:in >> `run_callbacks' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:218:in >> `write_audit' >> /usr/lib/ruby/gems/1.8/gems/audited-3.0.0.rc1/lib/audited/auditor.rb:206:in >> `audit_update' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:415:in >> `_run_update_callbacks' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:281:in >> `update' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:257:in >> `create_or_update' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:273:in >> `create_or_update' >> /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.15/lib/active_support/callbacks.rb:519:in >> `_run_save_callbacks' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/callbacks.rb:273:in >> `create_or_update' >> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/persistence.rb:40:in >> `save'

Wondering if this is a mysql vs mysql2 gem issue? -Brian

··· On Fri, Aug 10, 2012 at 7:30 AM, Lard Farnwell wrote: > Hey, > > I had the exact same problem. > Assuming you are not interested in your already existing storeconfigs. > Initialise the foreman db first (on a fresh db) and then set puppet to that > database. It's something to do with rails v3 which foreman 1 uses. > > I think that's how i fixed it at least. > > Cheers, > > Lard > > > On 09/08/2012, at 11:36 PM, p.ochon wrote: > > It was a fresh install, no /usr/share/foreman/vendor directory. > > Puppet/Foreman db shared > 0.4 -> 1.0 : OK > null -> 1.0 : NOK > > Puppet/Foreman db separated > 0.4 -> 1.0 : OK > null -> 1.0 : OK > > Also tried to pick all migration scripts of version 0.4 + the difference to > version 1.0 (from 20111124095053_rename_changes_to_audited_changes) with no > success. > > > Le jeudi 9 août 2012 14:56:04 UTC+2, ohad a écrit : >> >> >> >> On Thu, Aug 9, 2012 at 3:45 PM, p.ochon wrote: >>> >>> Hello, >>> >>> An error occur during "db:migrate" if Foreman database is shared with >>> Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried >>> with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to >>> 1.0 is OK even with an existant database. >>> >>> Some relevant information: >>> >>> - There is a problem with 2 files: >>> >>> /usr/share/foreman/migrate/20090916053824_change_host_build_default_to_false.rb >>> /usr/share/foreman/migrate/20110301154453_add_managed_to_hosts.rb >>> >>> - Theses files are identical in /usr/share/foreman/migrate in version 0.4 >>> and 1.0 >>> >>> - If I comment them, db:migrate is OK (but database is inconsistent) >>> >>> - If I delete "self" before "up" and "down" db:migrate is OK (I don't >>> know what it implies as a Ruby newbie) >>> >>> Any ideas ? Thanks. >>> >>> Paul (fr) >>> >>> >>> [root@puppet ~]# su - foreman -s /bin/bash -c >>> /usr/share/foreman/extras/dbmigrate >>> Libvirt binding are missing - hypervisor management is disabled >>> >>> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: >>> warning: already initialized constant ENC_NONE >>> >>> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: >>> warning: already initialized constant ENC_EUC >>> >>> /usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: >>> warning: already initialized constant ENC_SJIS >>> >>> /usr/lib/ruby/gems/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 >>> == CreateHosts: migrating >>> ==================================================== >>> -- add_column(:hosts, :mac, :string, {:default=>"", :limit=>17}) >>> -> 0.0010s >>> -- add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17}) >>> -> 0.0007s >>> -- add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15}) >>> -> 0.0007s >>> -- add_column(:hosts, :sp_name, :string, {:default=>""}) >>> -> 0.0006s >>> -- add_column(:hosts, :root_pass, :string, {:limit=>64}) >>> -> 0.0003s >>> -- add_column(:hosts, :serial, :string, {:limit=>12}) >>> -> 0.0003s >>> -- add_column(:hosts, :puppetmaster, :string) >>> -> 0.0004s >>> -- add_column(:hosts, :puppet_status, :integer, {:null=>false, >>> :default=>0}) >>> -> 0.0033s >>> -- add_column(:hosts, :domain_id, :integer) >>> -> 0.0004s >>> -- add_column(:hosts, :architecture_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :operatingsystem_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :environment_id, :integer) >>> -> 0.0004s >>> -- add_column(:hosts, :subnet_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :sp_subnet_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :ptable_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :medium_id, :integer) >>> -> 0.0003s >>> -- add_column(:hosts, :build, :boolean, {:default=>true}) >>> -> 0.0006s >>> -- add_column(:hosts, :comment, :text) >>> -> 0.0003s >>> -- add_column(:hosts, :disk, :text) >>> -> 0.0004s >>> -- add_column(:hosts, :installed_at, :datetime) >>> -> 0.0003s >>> == CreateHosts: migrated (0.0137s) >>> =========================================== >>> >>> == AddAuditsTable: migrating >>> ================================================= >>> -- create_table(:audits, {:force=>true}) >>> NOTICE: CREATE TABLE will create implicit sequence "audits_id_seq" for >>> serial column "audits.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "audits_pkey" for table "audits" >>> -> 0.0051s >>> -- add_index(:audits, [:auditable_id, :auditable_type], >>> {:name=>"auditable_index"}) >>> -> 0.0019s >>> -- add_index(:audits, [:user_id, :user_type], {:name=>"user_index"}) >>> -> 0.0022s >>> -- add_index(:audits, :created_at) >>> -> 0.0024s >>> -- add_index(:audits, [:auditable_parent_id, :auditable_parent_type], >>> {:name=>"auditable_parent_index"}) >>> -> 0.0025s >>> == AddAuditsTable: migrated (0.0143s) >>> ======================================== >>> >>> == CreateArchitectures: migrating >>> ============================================ >>> -- create_table(:architectures) >>> NOTICE: CREATE TABLE will create implicit sequence "architectures_id_seq" >>> for serial column "architectures.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "architectures_pkey" for table "architectures" >>> -> 0.0029s >>> -- create_table(:architectures_operatingsystems, {:id=>false}) >>> -> 0.0005s >>> == CreateArchitectures: migrated (0.0036s) >>> =================================== >>> >>> == CreateMedia: migrating >>> ==================================================== >>> -- create_table(:media) >>> NOTICE: CREATE TABLE will create implicit sequence "media_id_seq" for >>> serial column "media.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "media_pkey" for table "media" >>> -> 0.0027s >>> == CreateMedia: migrated (0.0152s) >>> =========================================== >>> >>> == CreateDomains: migrating >>> ================================================== >>> -- create_table(:domains) >>> NOTICE: CREATE TABLE will create implicit sequence "domains_id_seq" for >>> serial column "domains.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "domains_pkey" for table "domains" >>> -> 0.0038s >>> == CreateDomains: migrated (0.0038s) >>> ========================================= >>> >>> == CreateSubnets: migrating >>> ================================================== >>> -- create_table(:subnets) >>> NOTICE: CREATE TABLE will create implicit sequence "subnets_id_seq" for >>> serial column "subnets.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "subnets_pkey" for table "subnets" >>> -> 0.0038s >>> == CreateSubnets: migrated (0.0038s) >>> ========================================= >>> >>> == CreateOperatingsystems: migrating >>> ========================================= >>> -- create_table(:operatingsystems) >>> NOTICE: CREATE TABLE will create implicit sequence >>> "operatingsystems_id_seq" for serial column "operatingsystems.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "operatingsystems_pkey" for table "operatingsystems" >>> -> 0.0026s >>> == CreateOperatingsystems: migrated (0.0027s) >>> ================================ >>> >>> == CreateModels: migrating >>> =================================================== >>> -- create_table(:models) >>> NOTICE: CREATE TABLE will create implicit sequence "models_id_seq" for >>> serial column "models.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "models_pkey" for table "models" >>> -> 0.0035s >>> -- add_column(:hosts, :model_id, :integer) >>> -> 0.0003s >>> == CreateModels: migrated (0.0039s) >>> ========================================== >>> >>> == CreateEnvironments: migrating >>> ============================================= >>> -- create_table(:environments) >>> NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq" >>> for serial column "environments.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "environments_pkey" for table "environments" >>> -> 0.0023s >>> -- create_table(:environments_puppetclasses, {:id=>false}) >>> -> 0.0006s >>> == CreateEnvironments: migrated (0.0031s) >>> ==================================== >>> >>> == CreateReports: migrating >>> ================================================== >>> -- create_table(:reports) >>> NOTICE: CREATE TABLE will create implicit sequence "reports_id_seq" for >>> serial column "reports.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "reports_pkey" for table "reports" >>> -> 0.0035s >>> == CreateReports: migrated (0.0036s) >>> ========================================= >>> >>> == CreatePtables: migrating >>> ================================================== >>> -- create_table(:ptables) >>> NOTICE: CREATE TABLE will create implicit sequence "ptables_id_seq" for >>> serial column "ptables.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "ptables_pkey" for table "ptables" >>> -> 0.0038s >>> -- create_table(:operatingsystems_ptables, {:id=>false}) >>> -> 0.0006s >>> == CreatePtables: migrated (0.0134s) >>> ========================================= >>> >>> == CreatePuppetclasses: migrating >>> ============================================ >>> -- create_table(:puppetclasses) >>> NOTICE: CREATE TABLE will create implicit sequence "puppetclasses_id_seq" >>> for serial column "puppetclasses.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "puppetclasses_pkey" for table "puppetclasses" >>> -> 0.0039s >>> -- create_table(:hosts_puppetclasses, {:id=>false}) >>> -> 0.0006s >>> -- create_table(:operatingsystems_puppetclasses, {:id=>false}) >>> -> 0.0006s >>> == CreatePuppetclasses: migrated (0.0053s) >>> =================================== >>> >>> == CreateParameters: migrating >>> =============================================== >>> -- create_table(:parameters) >>> NOTICE: CREATE TABLE will create implicit sequence "parameters_id_seq" >>> for serial column "parameters.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "parameters_pkey" for table "parameters" >>> -> 0.0039s >>> == CreateParameters: migrated (0.0040s) >>> ====================================== >>> >>> == CreateAuthSources: migrating >>> ============================================== >>> -- create_table(:auth_sources) >>> NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq" >>> for serial column "auth_sources.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "auth_sources_pkey" for table "auth_sources" >>> -> 0.0045s >>> == CreateAuthSources: migrated (0.0045s) >>> ===================================== >>> >>> == CreateHostgroups: migrating >>> =============================================== >>> -- create_table(:hostgroups) >>> NOTICE: CREATE TABLE will create implicit sequence "hostgroups_id_seq" >>> for serial column "hostgroups.id" >>> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index >>> "hostgroups_pkey" for table "hostgroups" >>> -> 0.0024s >>> -- create_table(:hostgroups_puppetclasses, {:id=>false}) >>> -> 0.0006s >>> -- add_column(:hosts, :hostgroup_id, :integer) >>> -> 0.0004s >>> -- add_column(:parameters, :hostgroup_id, :integer) >>> -> 0.0003s >>> == CreateHostgroups: migrated (0.0040s) >>> ====================================== >>> >>> == AddTypeToParameter: migrating >>> ============================================= >>> -- add_column(:parameters, :type, :string) >>> -> 0.0003s >>> == AddTypeToParameter: migrated (0.0004s) >>> ==================================== >>> >>> == AddDomainToParameter: migrating >>> =========================================== >>> -- add_column(:parameters, :domain_id, :integer) >>> -> 0.0004s >>> == AddDomainToParameter: migrated (0.0005s) >>> ================================== >>> >>> == ChangeReportFieldTypeToText: migrating >>> ==================================== >>> == ChangeReportFieldTypeToText: migrated (0.0002s) >>> =========================== >>> >>> == ChangeHostBuildDefaultToFalse: migrating >>> ================================== >>> -- change_column(:hosts, :build, :boolean, {:default=>false}) >>> -> 0.0064s >>> rake aborted! >>> An error has occurred, this and all later migrations canceled: >>> >>> changes is defined by ActiveRecord >>> >>> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:23:in >>> `instance_method_already_implemented?' >>> >>> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:280:in >>> `define_attribute_methods' >>> >>> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >>> `each' >>> >>> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:279:in >>> `define_attribute_methods' >>> >>> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >>> `each' >>> >>> /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_model/attribute_methods.rb:278:in >>> `define_attribute_methods' >>> >>> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:13:in >>> `define_attribute_methods' >>> >>> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/attribute_methods.rb:51:in >>> `respond_to?' >>> >>> /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/active_record/base.rb:1874:in >>> `populate_with_current_scope_attribut

Hi Paul,

I did some more debugging on this issue and it has to do with the audit
gem's interaction with the existing table created on the puppetmaster.
There is an issue that has been open for a while, but I'm not sure how to
move forward on this. Ohad, any advice?

-Sam

··· On Mon, Aug 20, 2012 at 5:48 AM, p.ochon wrote:

Hello Sam,

Did you have the time to debug this issue ?

Cheers,

Paul

Le vendredi 10 août 2012 17:44:39 UTC+2, Sam Kottler a écrit :

It’s reproducable on both Postgres and MySQL so I don’t think that’s the
issue.

I am going to debug this later today and will report back.

-Sam

On Thu, Aug 9, 2012 at 8:45 AM, p.ochon ochon...@gmail.com wrote:

Hello,

An error occur during “db:migrate” if Foreman database is shared with
Puppet and not empty. I use Puppet 2.7.18 with Apache/Passenger and I tried
with both MySQL and Postgresql. On a different setup, upgrade from 0.4 to
1.0 is OK even with an existant database.

Some relevant information:

  • There is a problem with 2 files:
    /usr/share/foreman/migrate/20090916053824_change_host_
    build_default_to_false.rb
    /usr/share/foreman/migrate/**20110301154453_add_managed_to_**hosts.rb

  • Theses files are identical in /usr/share/foreman/migrate in version
    0.4 and 1.0

  • If I comment them, db:migrate is OK (but database is inconsistent)

  • If I delete “self” before “up” and “down” db:migrate is OK (I don’t
    know what it implies as a Ruby newbie)

Any ideas ? Thanks.

Paul (fr)

[root@puppet ~]# su - foreman -s /bin/bash -c /usr/share/foreman/extras/
**dbmigrate
Libvirt binding are missing - hypervisor management is disabled
/usr/lib/ruby/gems/1.8/gems/**ruby_parser-2.3.1/lib/ruby_**parser_extras.rb:10:
warning: already initialized constant ENC_NONE
/usr/lib/ruby/gems/1.8/gems/**ruby_parser-2.3.1/lib/ruby_**parser_extras.rb:11:
warning: already initialized constant ENC_EUC
/usr/lib/ruby/gems/1.8/gems/**ruby_parser-2.3.1/lib/ruby_**parser_extras.rb:12:
warning: already initialized constant ENC_SJIS
/usr/lib/ruby/gems/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
== CreateHosts: migrating ==============================

– add_column(:hosts, :mac, :string, {:default=>"", :limit=>17})
-> 0.0010s
– add_column(:hosts, :sp_mac, :string, {:default=>"", :limit=>17})
-> 0.0007s
– add_column(:hosts, :sp_ip, :string, {:default=>"", :limit=>15})
-> 0.0007s
– add_column(:hosts, :sp_name, :string, {:default=>""})
-> 0.0006s
– add_column(:hosts, :root_pass, :string, {:limit=>64})
-> 0.0003s
– add_column(:hosts, :serial, :string, {:limit=>12})
-> 0.0003s
– add_column(:hosts, :puppetmaster, :string)
-> 0.0004s
– add_column(:hosts, :puppet_status, :integer, {:null=>false,
:default=>0})
-> 0.0033s
– add_column(:hosts, :domain_id, :integer)
-> 0.0004s
– add_column(:hosts, :architecture_id, :integer)
-> 0.0003s
– add_column(:hosts, :operatingsystem_id, :integer)
-> 0.0003s
– add_column(:hosts, :environment_id, :integer)
-> 0.0004s
– add_column(:hosts, :subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :sp_subnet_id, :integer)
-> 0.0003s
– add_column(:hosts, :ptable_id, :integer)
-> 0.0003s
– add_column(:hosts, :medium_id, :integer)
-> 0.0003s
– add_column(:hosts, :build, :boolean, {:default=>true})
-> 0.0006s
– add_column(:hosts, :comment, :text)
-> 0.0003s
– add_column(:hosts, :disk, :text)
-> 0.0004s
– add_column(:hosts, :installed_at, :datetime)
-> 0.0003s
== CreateHosts: migrated (0.0137s) ==============================**

== AddAuditsTable: migrating ==============================**

– create_table(:audits, {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence “audits_id_seq” for
serial column “audits.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"audits_pkey” for table “audits”
-> 0.0051s
– add_index(:audits, [:auditable_id, :auditable_type],
{:name=>“auditable_index”})
-> 0.0019s
– add_index(:audits, [:user_id, :user_type], {:name=>“user_index”})
-> 0.0022s
– add_index(:audits, :created_at)
-> 0.0024s
– add_index(:audits, [:auditable_parent_id, :auditable_parent_type],
{:name=>"auditable_parent_index"})
-> 0.0025s
== AddAuditsTable: migrated (0.0143s) ==============================

== CreateArchitectures: migrating ==============================**

– create_table(:architectures)
NOTICE: CREATE TABLE will create implicit sequence
"architectures_id_seq" for serial column “architectures.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"architectures_pkey” for table “architectures”
-> 0.0029s
– create_table(:architectures_**operatingsystems, {:id=>false})
-> 0.0005s
== CreateArchitectures: migrated (0.0036s) ==============================
**=====

== CreateMedia: migrating ==============================**

– create_table(:media)
NOTICE: CREATE TABLE will create implicit sequence “media_id_seq” for
serial column “media.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"media_pkey” for table “media”
-> 0.0027s
== CreateMedia: migrated (0.0152s) ==============================**

== CreateDomains: migrating ==============================**

– create_table(:domains)
NOTICE: CREATE TABLE will create implicit sequence “domains_id_seq” for
serial column “domains.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"domains_pkey” for table “domains”
-> 0.0038s
== CreateDomains: migrated (0.0038s) ==============================**

== CreateSubnets: migrating ==============================**

– create_table(:subnets)
NOTICE: CREATE TABLE will create implicit sequence “subnets_id_seq” for
serial column “subnets.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"subnets_pkey” for table “subnets”
-> 0.0038s
== CreateSubnets: migrated (0.0038s) ==============================**

== CreateOperatingsystems: migrating ==============================**

– create_table(:operatingsystems)
NOTICE: CREATE TABLE will create implicit sequence
"operatingsystems_id_seq" for serial column “operatingsystems.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"operatingsystems_pkey” for table “operatingsystems”
-> 0.0026s
== CreateOperatingsystems: migrated (0.0027s)
==============================
==

== CreateModels: migrating ==============================**

– create_table(:models)
NOTICE: CREATE TABLE will create implicit sequence “models_id_seq” for
serial column “models.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"models_pkey” for table “models”
-> 0.0035s
– add_column(:hosts, :model_id, :integer)
-> 0.0003s
== CreateModels: migrated (0.0039s) ==============================**

== CreateEnvironments: migrating ==============================**

– create_table(:environments)
NOTICE: CREATE TABLE will create implicit sequence "environments_id_seq"
for serial column “environments.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"environments_pkey” for table “environments”
-> 0.0023s
– create_table(:environments_**puppetclasses, {:id=>false})
-> 0.0006s
== CreateEnvironments: migrated (0.0031s) ==============================
**======

== CreateReports: migrating ==============================**

– create_table(:reports)
NOTICE: CREATE TABLE will create implicit sequence “reports_id_seq” for
serial column “reports.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"reports_pkey” for table “reports”
-> 0.0035s
== CreateReports: migrated (0.0036s) ==============================**

== CreatePtables: migrating ==============================**

– create_table(:ptables)
NOTICE: CREATE TABLE will create implicit sequence “ptables_id_seq” for
serial column “ptables.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"ptables_pkey” for table “ptables”
-> 0.0038s
– create_table(:operatingsystems_ptables, {:id=>false})
-> 0.0006s
== CreatePtables: migrated (0.0134s) ==============================

== CreatePuppetclasses: migrating ==============================**

– create_table(:puppetclasses)
NOTICE: CREATE TABLE will create implicit sequence
"puppetclasses_id_seq" for serial column “puppetclasses.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"puppetclasses_pkey” for table “puppetclasses”
-> 0.0039s
– create_table(:hosts_**puppetclasses, {:id=>false})
-> 0.0006s
– create_table(:**operatingsystems_**puppetclasses, {:id=>false})
-> 0.0006s
== CreatePuppetclasses: migrated (0.0053s) ==============================
**=====

== CreateParameters: migrating ==============================**

– create_table(:parameters)
NOTICE: CREATE TABLE will create implicit sequence "parameters_id_seq"
for serial column “parameters.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"parameters_pkey” for table “parameters”
-> 0.0039s
== CreateParameters: migrated (0.0040s) ==============================**

== CreateAuthSources: migrating ==============================**

– create_table(:auth_sources)
NOTICE: CREATE TABLE will create implicit sequence "auth_sources_id_seq"
for serial column “auth_sources.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"auth_sources_pkey” for table “auth_sources”
-> 0.0045s
== CreateAuthSources: migrated (0.0045s) ==============================*
*=======

== CreateHostgroups: migrating ==============================**

– create_table(:hostgroups)
NOTICE: CREATE TABLE will create implicit sequence "hostgroups_id_seq"
for serial column “hostgroups.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"hostgroups_pkey” for table “hostgroups”
-> 0.0024s
– create_table(:hostgroups_puppetclasses, {:id=>false})
-> 0.0006s
– add_column(:hosts, :hostgroup_id, :integer)
-> 0.0004s
– add_column(:parameters, :hostgroup_id, :integer)
-> 0.0003s
== CreateHostgroups: migrated (0.0040s) ==============================

== AddTypeToParameter: migrating ==============================**

– add_column(:parameters, :type, :string)
-> 0.0003s
== AddTypeToParameter: migrated (0.0004s) ==============================
**======

== AddDomainToParameter: migrating ==============================**

– add_column(:parameters, :domain_id, :integer)
-> 0.0004s
== AddDomainToParameter: migrated (0.0005s)
==============================**====

== ChangeReportFieldTypeToText: migrating ==============================
**======
== ChangeReportFieldTypeToText: migrated (0.0002s)

== ChangeHostBuildDefaultToFalse: migrating
==============================**====
– change_column(:hosts, :build, :boolean, {:default=>false})
-> 0.0064s
rake aborted!
An error has occurred, this and all later migrations canceled:

changes is defined by ActiveRecord
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/
active_record/attribute_**methods.rb:23:in instance_method_already_** implemented?' /usr/lib/ruby/gems/1.8/gems/**activemodel-3.0.15/lib/active_** model/attribute_methods.rb:**280:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_
model/attribute_methods.rb:**279:in each' /usr/lib/ruby/gems/1.8/gems/**activemodel-3.0.15/lib/active_** model/attribute_methods.rb:**279:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.15/lib/active_
model/attribute_methods.rb:**278:in each' /usr/lib/ruby/gems/1.8/gems/**activemodel-3.0.15/lib/active_** model/attribute_methods.rb:**278:indefine_attribute_methods’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/
active_record/attribute_**methods.rb:13:in define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/** active_record/attribute_**methods.rb:51:inrespond_to?’
/usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/**active_record/base.rb:1874:in
populate_with_current_scope_**attributes' /usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/**active_record/base.rb:1874:ineach’
/usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/**active_record/base.rb:1874:in
populate_with_current_scope_**attributes' /usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/**active_record/base.rb:1411:ininitialize’
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.15/lib/
active_record/reflection.rb:**173:in new' /usr/lib/ruby/gems/1.8/gems/**activerecord-3.0.15/lib/** active_record/reflection.rb:**173:in