Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
498d3909
Commit
498d3909
authored
13 years ago
by
Eric Davis
Browse files
Options
Downloads
Plain Diff
Merge branch 'ticket/release-v2.0.0/467-journal-migration-sti-callback-bug' into release-v2.0.0
parents
0c031428
47c7e077
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
db/migrate/20100714111651_generalize_journals.rb
+13
-3
13 additions, 3 deletions
db/migrate/20100714111651_generalize_journals.rb
with
13 additions
and
3 deletions
db/migrate/20100714111651_generalize_journals.rb
+
13
−
3
View file @
498d3909
...
...
@@ -35,10 +35,14 @@ class GeneralizeJournals < ActiveRecord::Migration
Journal
.
all
.
group_by
(
&
:journaled_id
).
each_pair
do
|
id
,
journals
|
journals
.
sort_by
(
&
:created_at
).
each_with_index
do
|
j
,
idx
|
j
.
update_attribute
(
:type
,
"
#{
j
.
journalized_type
}
Journal"
)
j
.
update_attribute
(
:version
,
idx
+
1
)
# Recast the basic Journal into it's STI journalized class so callbacks work (#467)
klass_name
=
"
#{
j
.
journalized_type
}
Journal"
j
=
j
.
becomes
(
klass_name
.
constantize
)
j
.
type
=
klass_name
j
.
version
=
idx
+
1
# FIXME: Find some way to choose the right activity here
j
.
update_attribute
(
:activity_type
,
j
.
journalized_type
.
constantize
.
activity_provider_options
.
keys
.
first
)
j
.
activity_type
=
j
.
journalized_type
.
constantize
.
activity_provider_options
.
keys
.
first
j
.
save
(
false
)
end
end
...
...
@@ -46,6 +50,12 @@ class GeneralizeJournals < ActiveRecord::Migration
t
.
remove
:journalized_type
end
# Reset class and subclasses, otherwise they will try to save using older attributes
Journal
.
reset_column_information
Journal
.
send
(
:subclasses
).
each
do
|
klass
|
klass
.
reset_column_information
if
klass
.
respond_to?
(
:reset_column_information
)
end
# Build initial journals for all activity providers
providers
=
Redmine
::
Activity
.
providers
.
collect
{
|
k
,
v
|
v
.
collect
(
&
:constantize
)
}.
flatten
.
compact
.
uniq
providers
.
each
do
|
p
|
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment