drop unused course section columns

test plan:
 * ensure current specs pass, and no functionality changes

Change-Id: I7296f63421eb8041c1f33277244e6b745197e972
Reviewed-on: https://gerrit.instructure.com/11619
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Cody Cutrer 2012-06-14 19:32:03 -06:00
parent 6b218220e6
commit 1bd313db23
4 changed files with 17 additions and 9 deletions

View File

@ -598,7 +598,7 @@ class Course < ActiveRecord::Base
def update_course_section_names
return if @course_name_was == self.name || !@course_name_was
sections = self.course_sections
fields_to_possibly_rename = [:name, :section_code, :long_section_code]
fields_to_possibly_rename = [:name, :section_code]
sections.each do |section|
something_changed = false
fields_to_possibly_rename.each do |field|

View File

@ -131,16 +131,13 @@ class CourseSection < ActiveRecord::Base
# and I don't know which one is best, or which one to show.
name_had_changed = name_changed?
# Here's the current plan:
# - if it's from the SIS, long_section_code seems like the best bet
# - otherwise, just use name
# - use the method display_name to consolidate this logic
self.name ||= self.course.name if self.default_section
self.name ||= "#{self.course.name} #{Time.zone.today.to_s}"
self.section_code ||= self.name
self.long_section_code ||= self.name
if name_had_changed
self.section_code = self.name
self.long_section_code = self.name
end
end
@ -155,13 +152,11 @@ class CourseSection < ActiveRecord::Base
# The only place this is used by itself right now is when listing
# enrollments within a course
def display_name
@section_display_name ||= defined_by_sis? ?
(self.long_section_code || self.name || self.section_code) :
(self.name || self.section_code || self.long_section_code)
@section_display_name ||= self.name || self.section_code
end
def assert_course
self.course ||= Course.create!(:name => self.name || self.section_code || self.long_section_code, :root_account => self.root_account)
self.course ||= Course.create!(:name => self.name || self.section_code, :root_account => self.root_account)
end
def move_to_course(course, *opts)

View File

@ -26,7 +26,7 @@ class ActiveRecord::Base
'attachments' => %w(enrollment_id cached_s3_url s3_url_cached_at),
'calendar_events' => %w(calendar_event_repeat_id for_repeat_on),
'content_tags' => %w(sequence_position),
'course_sections' => %w(sis_cross_listed_section_id sis_cross_listed_section_sis_batch_id sticky_xlist sis_name students_can_participate_before_start_at),
'course_sections' => %w(sis_cross_listed_section_id sis_cross_listed_section_sis_batch_id sticky_xlist sis_name students_can_participate_before_start_at section_organization_name long_section_code),
'courses' => %w(section hidden_tabs sis_name sis_course_code),
'discussion_topics' => %w(authorization_list_id),
'enrollment_terms' => %w(sis_data sis_name),

View File

@ -0,0 +1,13 @@
class DropSectionOrganizationNameAndLongSectionCodeFromCourseSections < ActiveRecord::Migration
tag :postdeploy
def self.up
remove_column :course_sections, :section_organization_name
remove_column :course_sections, :long_section_code
end
def self.down
add_column :course_sections, :long_section_code, :string
add_column :course_sections, :section_organization_name, :string
end
end