Today I tried to upgrade our Retrospectiva installation from March 2009. I followed instructions in the wiki,
$ git pull
This first gave me an error message about some changeset which couldn’t be found, but with a second try, it run through without any errors.
Then I run the migrations:
$ rake RAILS_ENV=production db:migrate
(in /var/www/retrospectiva)
== CreateBaseTables: migrating ===============================================
== CreateBaseTables: migrated (0.0020s) ======================================
== RenameTansToSecureTokens: migrating =======================================
-- rename_table(:tans, :secure_tokens)
rake aborted!
An error has occurred, all later migrations canceled:
Mysql::Error: Table 'secure_tokens' already exists: RENAME TABLE `tans` TO `secure_tokens`
(See full trace by running task with --trace)
Now I’m not really sure what to do … please advise.
Would it be easier to go for a fresh installation? If so, please advise how to import our tickets from the old environment.
Very strange indeed, it seems that you have run this migration before. No need to panic or re-install, it should be easily fixable. Just open a console script/console production and call:
ActiveRecord::Migrator.get_all_versions
It the console fails, you can alternatively get the info from the DB directly via SQL:
SELECT * FROM retrospectiva.schema_migrations ORDER BY version
Please post the output.
Here you go:
Loading production environment (Rails 2.3.5)
>> ActiveRecord::Migrator.get_all_versions
=> [1, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 20080620133127, 20080620144057, 20080621122453,
20080621123529, 20080621135132, 20080622155101, 20080623174613, 20080624111936,
20080626154744, 20080627105624, 20080629090039, 20080705092553, 20080705092807,
20080706092837, 20080801102216, 20080802093955, 20081004154259, 20081005122317,
20081019094905, 20081025151029, 20081027102234, 20081115160102, 20081116113804,
20081116132927, 20081203152501, 20081213103832, 20081215174447, 20081216113731,
20081216114551, 20081230155634, 20090119162735, 20090119163053, 20090119165024,
20090124092718, 20090124092851, 20090124094802, 20090124095048]
Ok, could you please run rake db:schema:dump and attach your db/schema.rb?
This fails – guess I need to specify a password somehow (sorry, I’m not familiar with Rails):
$ rake db:schema:dump
(in /var/www/retrospectiva)
rake aborted!
Access denied for user 'root'@'localhost' (using password: NO)
(See full trace by running task with --trace)
P.S.: In db/database.yml, correct password is set for production.
It’s rake db:schema:dump RAILS_ENV=production
I see. Find file attached.
I see, not sure how you did it, but it seems your schema_migrations table is missing a few records.
Could you please open a console ruby script/console production and type:
ActiveRecord::Base.connection.insert "INSERT INTO schema_migrations (version) VALUES ('20090131181728');"
ActiveRecord::Base.connection.insert "INSERT INTO schema_migrations (version) VALUES ('20090131185651');"
ActiveRecord::Base.connection.insert "INSERT INTO schema_migrations (version) VALUES ('20090201113123');"
ActiveRecord::Base.connection.insert "INSERT INTO schema_migrations (version) VALUES ('20090201170000');" It works now, thanks a lot!