Added WorkItems as a new subject for TrackedTimeEntries.
- Made TrackedTimeEntries polymorphic to belong to both Lecture and WorkItems models - Added associated migrations for existing data - Added to administrate UI
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
class MakeTrackedTimeEntryPolymorphic < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_reference :tracked_time_entries, :subject, polymorphic: true
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
TrackedTimeEntry.all.each do |entry|
|
||||
entry.update!(subject: Lecture.find(entry.lecture_id))
|
||||
end
|
||||
end
|
||||
|
||||
dir.down do
|
||||
TrackedTimeEntry.all.each do |entry|
|
||||
entry.update!(lecture_id: entry.subject_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class RemoveLectureAssociation < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
remove_reference :tracked_time_entries, :lecture, null: false, foreign_key: true
|
||||
change_column_null :tracked_time_entries, :subject_id, false
|
||||
change_column_null :tracked_time_entries, :subject_type, false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user