Redmine 3.0.1 from 2.6.0

Added by James H about 5 years ago

Hello,

I'm trying to update my dev box from 2.6.0 to 3.0.1.

I am on Windows, mainly 7 and server.
I have done several upgrades from 2.x to 2.x but not any major release upgrades yet.

I upgraded the Redmine files, updated the gems, and when I get the point where I am trying to db migrate, it gives me an error saying that:

Mysql2::Error: Table 'email_addresses' already exists: CREATE TABLE `email_addre
sses` (`id` int(11) auto_increment PRIMARY KEY, `user_id` int(11) NOT NULL, `add
ress` varchar(255) NOT NULL, `is_default` tinyint(1) DEFAULT 0 NOT NULL, `notify
` tinyint(1) DEFAULT 1 NOT NULL, `created_on` datetime NOT NULL, `updated_on` da
tetime NOT NULL) ENGINE=InnoDBC:/redmine4/db/migrate/20150113194759_create_email
_addresses.rb:3:in `change'
D:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I thought the db migrate handles already existing tables... so whats the issue???

Replies (5)

RE: Redmine 3.0.1 from 2.6.0 - Added by Leonel Iturralde about 5 years ago

Reading a little about rails db:migrate in

http://stackoverflow.com/questions/842162/is-rake-dbmigrate-the-correct-command-to-re-sync-schema-rb-with-your-database-s

One of the answers says that

I've found that occasionally, when things get a little weird, you'll find yourself in a situation where Rails will want >to run a migration that it ought rightly to be considering already done (the table already exists, etc). You can mark a >migration as done by finding its number (the number part at the beginning of the filename), going into mysql and >issuing a query like so:

insert into schema_migrations values('20090521153438');

(or whatever the number of your migration is)

So my suggestion is to try adding that migration to schema_migrations table.

RE: Redmine 3.0.1 from 2.6.0 - Added by James H about 5 years ago

Hmmm.. interesting.

OK so, I have the email_addresses table, but at this point, it only has one entry in it for the default admin account.

I added the schema migration for 20150113194759 for create email addresses
There are 4 more migrations left:
  1. populate email addresses
  2. remove users mail
  3. add email addresses user id index
  4. replace move issues permission

db migrate results in successful rake until the "add email addresses user id index" migration

== 20150113211532 PopulateEmailAddresses: migrating ===========================
== 20150113211532 PopulateEmailAddresses: migrated (0.1140s) ==================

== 20150113213922 RemoveUsersMail: migrating ==================================
-- remove_column(:users, :mail)
   -> 0.4320s
== 20150113213922 RemoveUsersMail: migrated (0.4340s) =========================

== 20150113213955 AddEmailAddressesUserIdIndex: migrating =====================
-- add_index(:email_addresses, :user_id)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Index name 'index_email_addresses_on_user_id' on table 'email_addresses' already
 existsC:/redmine4/db/migrate/20150113213955_add_email_addresses_user_id_index.r
b:3:in `up'
D:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

"Add email addresses user id index".rb:

class AddEmailAddressesUserIdIndex < ActiveRecord::Migration
  def up
    add_index :email_addresses, :user_id
  end

  def down
    remove_index :email_addresses, :user_id
  end
end

Im not sure what this is supposed to do...
My email address table has now been populated fully and the users table no longer has the email address field. It also has the index/user_id filled in.
What is this one supposed to do?? Not sure if I can safely skip this one too.

RE: Redmine 3.0.1 from 2.6.0 - Added by Leonel Iturralde about 5 years ago

Skip that one too it is already created

RE: Redmine 3.0.1 from 2.6.0 - Added by James H about 5 years ago

worked. awesome. thanks for the help!

RE: Redmine 3.0.1 from 2.6.0 - Added by li gh about 5 years ago

James H wrote:

Hello,

I'm trying to update my dev box from 2.6.0 to 3.0.1.

I am on Windows, mainly 7 and server.
I have done several upgrades from 2.x to 2.x but not any major release upgrades yet.

I upgraded the Redmine files, updated the gems, and when I get the point where I am trying to db migrate, it gives me an error saying that:

[...]

I thought the db migrate handles already existing tables... so whats the issue???

Great!

(1-5/5)