Foreman upgrade to 1.4

Hello @all,

I tried to upgrade Foreman to version 1.4 but the db_migrate task is
failing:

$ foreman-rake db:migrate
== ChangeNameIndexOnFactName: migrating

··· ====================================== -- remove_index(:fact_names, {:column=>:name, :unique=>true}) rake aborted! An error has occurred, all later migrations canceled:

Index name ‘index_fact_names_on_name’ on table ‘fact_names’ does not exist

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
$ foreman-rake db:seed
You have 10 pending migrations:
20131021152315 ChangeNameIndexOnFactName
20131104132542 UpdateForemanUrl
20131107094849 AddAncestryToFactNames
20131122150434 AddPxegrubLocalbootTemplate
20131127112625 RenameSeededTemplates
20131204174455 AddDescriptionToOperatingsystem
20131223120945 AddUserdataFlagToImages
20131224153518 CreateComputeProfiles
20131224153743 CreateComputeAttributes
20131224154836 AddComputeProfileToHostgroup
Run rake db:migrate to update your database then try again.
$

So I guess there are migrations missing in the database. Can anyone give me
a hint how to solve this one? Thanks!

Regards Thomas

Linux … enjoy the ride!

Curious, we added this in an earlier migration
"20130520161514_add_unique_constraint_to_fact_name" which has been there
for some time. I wonder if there was an error running this migration
the first time, which means it got part way through, failed on a later
step and now you're seeing an error on the first step as the index it
removes is now missing.

If you're able to restore the original DB and re-run the migrations from
the start, we might get a better idea of what's happening.

Alternatively, you could try editing
db/migrate/20131021152315_change_name_index_on_fact_name.rb and add a
"rescue nil" to the end of line 3, then see if it continues.

··· On 29/01/14 15:24, Thomas Bendler wrote: > Hello @all, > > I tried to upgrade Foreman to version 1.4 but the db_migrate task is > failing: > > $ foreman-rake db:migrate > == ChangeNameIndexOnFactName: migrating > ====================================== > -- remove_index(:fact_names, {:column=>:name, :unique=>true}) > rake aborted! > An error has occurred, all later migrations canceled: > > Index name 'index_fact_names_on_name' on table 'fact_names' does not exist


Dominic Cleal
Red Hat Engineering

Hi Dominic,

tried the second method because (yes I know) I don't have a backup
available. It skiped the step and failed during creation of an index (which
is, I guess, related to UTF8):

$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 138
Server version: 5.1.69 Source distribution

Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.

> SELECT default_character_set_name FROM information_schema.SCHEMATA S
WHERE schema_name = "foreman";

··· +----------------------------+ > default_character_set_name | +----------------------------+ > utf8 | +----------------------------+ 1 row in set (0.00 sec)

exit
Bye
$ foreman-rake db:seed
You have 10 pending migrations:
20131021152315 ChangeNameIndexOnFactName
20131104132542 UpdateForemanUrl
20131107094849 AddAncestryToFactNames
20131122150434 AddPxegrubLocalbootTemplate
20131127112625 RenameSeededTemplates
20131204174455 AddDescriptionToOperatingsystem
20131223120945 AddUserdataFlagToImages
20131224153518 CreateComputeProfiles
20131224153743 CreateComputeAttributes
20131224154836 AddComputeProfileToHostgroup
Run rake db:migrate to update your database then try again.
$ foreman-rake db:migrate
== ChangeNameIndexOnFactName: migrating
======================================
– remove_index(:fact_names, {:column=>:name, :unique=>true})
– add_index(:fact_names, [:name, :type], {:unique=>true, :length=>254})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Specified key was too long; max key length is 1000 bytes:
CREATE UNIQUE INDEX index_fact_names_on_name_and_type ON fact_names
(name(254), type(254))

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
$

I checked Google for converting back to latin1 but didn’t find proper
howtos. Any other suggestion? Reducing the length maybe?

Regards Thomas

2014-01-29 Dominic Cleal dcleal@redhat.com:

On 29/01/14 15:24, Thomas Bendler wrote:

Hello @all,

I tried to upgrade Foreman to version 1.4 but the db_migrate task is
failing:

$ foreman-rake db:migrate
== ChangeNameIndexOnFactName: migrating

– remove_index(:fact_names, {:column=>:name, :unique=>true})
rake aborted!
An error has occurred, all later migrations canceled:

Index name ‘index_fact_names_on_name’ on table ‘fact_names’ does not
exist

Curious, we added this in an earlier migration
"20130520161514_add_unique_constraint_to_fact_name" which has been there
for some time. I wonder if there was an error running this migration
the first time, which means it got part way through, failed on a later
step and now you’re seeing an error on the first step as the index it
removes is now missing.

If you’re able to restore the original DB and re-run the migrations from
the start, we might get a better idea of what’s happening.

Alternatively, you could try editing
db/migrate/20131021152315_change_name_index_on_fact_name.rb and add a
"rescue nil" to the end of line 3, then see if it continues.


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


Linux … enjoy the ride!

Hi Dominic,

got that solved, switched foreman database in MySQL to InnoDB. After this
change db:migrate finished without further errors.

Regards Thomas

··· 2014-01-30 Thomas Bendler :

Hi Dominic,

tried the second method because (yes I know) I don’t have a backup
available. It skiped the step and failed during creation of an index (which
is, I guess, related to UTF8):

$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 138
Server version: 5.1.69 Source distribution

Copyright © 2000, 2013, Oracle and/or its affiliates. All rights
reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input
statement.

SELECT default_character_set_name FROM information_schema.SCHEMATA
S WHERE schema_name = “foreman”;
±---------------------------+
default_character_set_name |
±---------------------------+
utf8 |
±---------------------------+
1 row in set (0.00 sec)

exit
Bye
$ foreman-rake db:seed
You have 10 pending migrations:
20131021152315 ChangeNameIndexOnFactName
20131104132542 UpdateForemanUrl
20131107094849 AddAncestryToFactNames
20131122150434 AddPxegrubLocalbootTemplate
20131127112625 RenameSeededTemplates
20131204174455 AddDescriptionToOperatingsystem
20131223120945 AddUserdataFlagToImages
20131224153518 CreateComputeProfiles
20131224153743 CreateComputeAttributes
20131224154836 AddComputeProfileToHostgroup
Run rake db:migrate to update your database then try again.
$ foreman-rake db:migrate
== ChangeNameIndexOnFactName: migrating
======================================
– remove_index(:fact_names, {:column=>:name, :unique=>true})
– add_index(:fact_names, [:name, :type], {:unique=>true, :length=>254})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Specified key was too long; max key length is 1000 bytes:
CREATE UNIQUE INDEX index_fact_names_on_name_and_type ON fact_names
(name(254), type(254))

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
$

I checked Google for converting back to latin1 but didn’t find proper
howtos. Any other suggestion? Reducing the length maybe?

Regards Thomas

2014-01-29 Dominic Cleal dcleal@redhat.com:

On 29/01/14 15:24, Thomas Bendler wrote:

Hello @all,

I tried to upgrade Foreman to version 1.4 but the db_migrate task is
failing:

$ foreman-rake db:migrate
== ChangeNameIndexOnFactName: migrating

– remove_index(:fact_names, {:column=>:name, :unique=>true})
rake aborted!
An error has occurred, all later migrations canceled:

Index name ‘index_fact_names_on_name’ on table ‘fact_names’ does not
exist

Curious, we added this in an earlier migration
"20130520161514_add_unique_constraint_to_fact_name" which has been there
for some time. I wonder if there was an error running this migration
the first time, which means it got part way through, failed on a later
step and now you’re seeing an error on the first step as the index it
removes is now missing.

If you’re able to restore the original DB and re-run the migrations from
the start, we might get a better idea of what’s happening.

Alternatively, you could try editing
db/migrate/20131021152315_change_name_index_on_fact_name.rb and add a
"rescue nil" to the end of line 3, then see if it continues.


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


Linux … enjoy the ride!


Linux … enjoy the ride!