protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // add your code here
     $courses = CoursePeer::doSelect(new Criteria());
     foreach ($courses as $course) {
         $division = new Division();
         $division->setName($course->getName());
         $division->setSchoolYearId($course->getSchoolYearId());
         foreach ($course->getCourseSubjects() as $course_subject) {
             $course_students = $course->getCourseStudents();
             if (isset($course_students[0])) {
                 $division->setCareerId($course_students[0]->getCareerSubject()->getCareerId());
             } else {
                 $division->setCareerId(1);
             }
             $new_course = new Course();
             $course->copyInto($new_course);
             $new_course->setName($course_subject->getSubject() . ' - ' . $course->getName());
             $new_course->save();
             $new_course_subject = new CourseSubject();
             $course_subject->copyInto($new_course_subject);
             $new_course_subject->setCourseId($new_course->getId());
             $new_course_subject->setCourseId($new_course->getId());
             $new_course_subject->save();
             $course_subject->delete();
             $c = new Criteria();
             $c->add(CourseStudentPeer::COURSE_ID, $course->getId());
             $c->addJoin(CourseStudentPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID);
             $c->add(CareerSubjectPeer::SUBJECT_ID, $new_course_subject->getSubjectId());
             $course_students = CourseStudentPeer::doSelect($c);
             foreach ($course_students as $course_student) {
                 $new_course_student = new CourseStudent();
                 $course_student->copyInto($new_course_student);
                 $new_course_student->setCourseId($new_course->getId());
                 $new_course_student->save();
                 $course_student->delete();
             }
             $division_course = new DivisionCourse();
             $division_course->setCourse($new_course);
             $division->addDivisionCourse($division_course);
         }
         try {
             $course->delete();
         } catch (Exception $e) {
         }
         try {
             $division->save();
         } catch (Exception $e) {
         }
         $this->logSection('division+', 'Division ' . $division . ' created');
     }
 }