Migrate DB from redmine 2.5.2 to 4.1.0

Added by Paul Ficheux 3 months ago

Hello,

I'm trying to migrate my DB from older version of redmine.

But when I execute the command bundle exec rake db:migrate RAILS_ENV=production, I've a tons of errors like :

Mysql2::Error: Duplicate column name 'issues_visibility': ALTER TABLE `roles` ADD `issues_visibility` varchar(30) DEFAULT 'default' NOT NULL

Is there a way of overwriting the duplicates column and index?

Here is my config :

Environment:
Redmine version 4.1.0.stable
Ruby version 2.7.0-p0 (2019-12-25) [x86_64-linux]
Rails version 5.2.4.1
Environment production
Database adapter Mysql2
Mailer queue ActiveJob::QueueAdapters::AsyncAdapter
Mailer delivery smtp
SCM:
Filesystem
Redmine plugins:
no plugin installed

Regards

Replies (7)

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Liane Hampe 3 months ago

Hi Paul

Generally there is a way. However, you would need a solid coding experience.

The way it would go is to find the migrations where the errors come from and manipulate the code (at least temporary) with a condition not to create the column if it already exists.

You can find some examples in dthe ActiveRecord docs:
https://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/column_exists%3f
https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html

Best,
Liane

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Paul Ficheux 3 months ago

Hi Liane,

Thanks for the quick answer.

Infortunately, my skills in ruby coding are limited...

Is there a way to migrate my DB, knowing that my previous redmine DB running on Mysql 5.1.73?

The new one runs on 8.0.19. My OS is CentOS 7.5.

Regards,

Paul

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Liane Hampe 3 months ago

Hi Paul,

Although I never haved dumped a mySQL database from Redmine 2.5.2 to import it in a mySQL database 8.0.19, I am quite sure, that it would not work.

First reason is, that you still need mySQL 5.7 at maximum. So you need to downscale your db instance, assuming it is unused so far.

Second reason is, that the database scheme has evolved over time. When you import a .sql dump of Redmine 2.5.2 the current scheme of Redmine gets overwritten. That is, you need to migrate again. And that may leed you to the point you are right now. Alternatively, the dump will not get integrated at all.

But when you have time and patience, give it a try. As I said I never have tried that before.:)

Best,
Liane

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Paul Ficheux 3 months ago

Hi Liane,

I'll try that.

But what I don't understand, is that, if I follow the procedure, I have to restore my dump, then execute "RAILS_ENV=production bundle exec rake db:migrate".

If I do that, I've a tons of errors like "Mysql2::Error: Duplicate column name 'issues_visibility': ALTER TABLE `roles` ADD `issues_visibility` varchar(30) DEFAULT 'default' NOT NULL"

The columns already exists so the migrate can't complete...

Regards,

Paul

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Liane Hampe 3 months ago

Hi Paul,

If I would sit in front of your computer, I am pretty sure to find the reason for that. Because I have stumpled a thousand times across such errors.

But with that distance between us, and hence, the weak information base, frankly speaking, I don't know what is going on your computer.

Maybe you should start coding Ruby to overcome such difficulties in the future, or update more often. :)

All the best!

Liane

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Klaus Friese 3 months ago

Hi Paul,

I just migrated a database from 2.5.0 to 4.0.4 and I just had some

encountered \r in middle of line, treated as a mere space

warnings. I saw your posting before my migration and I expected the same problems here, but it worked.

If you still have your error messages you can try this:

  • Rename column issues_visibility (and other double columns) to something like issues_visibility2
  • Do the update again
  • remove new column issues_visibility and rename the issues_visibility2 back to issues_visibility

Klaus

RE: Migrate DB from redmine 2.5.2 to 4.1.0 - Added by Paul Ficheux 3 months ago

Hi Klaus,

Finally we moved the ruby files that we don't want to be proceeded by the migration from db/migrate folder, and it's worked like a charm.

Thanks you for your answer, and thanks Liane for your time.

Regards,

Paul

(1-7/7)