Closed gyhor closed 10 years ago
Unfortunately database incompatibilities are hidden under ActiveRecord interfaces; and I do not have a Postgres installation. After the delivery of the next version over which I'm working, I'll try to search for hints over the internet
Have a look at this bug report: https://github.com/rails/rails/issues/13496
As a workaround, you could comment out the offending sentence as you did and run the query by hand. The mentioned bug report also states what would be the right query for Postgres.
Rationale is: for all timelogs in timesheet (:in_timesheet => true) copy all fixed versions stored into issue attributes into the timelog's equivalent field (formerly added to track just global orders). In the following migration, :in_timesheet is going to disappear in time entries and fixed_version_id (renamed order_id) will bring the same information if not NULL.
Closing as the bug is not ours
I'll try this query and it has wrong syntax. Correct query:
UPDATE time_entries SET fixed_version_id = issues.fixed_version_id FROM issues WHERE time_entries.id IN (SELECT time_entries.id FROM time_entries INNER JOIN issues ON issues.id = time_entries.issue_id WHERE time_entries.in_timesheet = 't' AND (time_entries.fixed_version_id is NULL));
Thank you. It can work as a manual workaround for Postgres users
For postgres's users, you can modify file in plugins/redmine_app_timesheets/db/migrate/005_revert_time_entries_in_timesheet.rb
Replace line 5 (TimeEntry.joins ....) by sql = "UPDATE time_entries SET fixed_version_id = issues.fixed_version_id FROM issues WHERE time_entries.id IN ( SELECT time_entries.id FROM time_entries INNER JOIN issues ON issues.id = time_entries.issue_id WHERE time_entries.in_timesheet = 't' AND (time_entries.fixed_version_id is NULL));" connection.update(sql)
Thanks mkrzempek for the query.
Fixed in 1.3.9.
The proposed query does not work under MySql (error is: 1093 - You can't specify target table 'time_entries' for update in FROM clause), hence I implemented a switch.
Thank you
It's just for postgres's user as me ^^
Hi,
I am getting a migration error with postgres:
if I comment the update statement in "005_revert_time_entries_in_timesheet.rb" out, the migration success.
regards gyhor