public function down()
 {
     $conn = Doctrine_Manager::connection();
     $export = $conn->export;
     $export->alterTable('community_topic_comment', array('add' => array('updated_at' => array('type' => 'timestamp', 'notnull' => false))));
     $export->alterTable('community_topic', array('remove' => array('topic_updated_at' => array())));
     $export->alterTable('community_topic_comment', array('change' => array('member_id' => array('definition' => array('type' => 'integer', 'notnull' => true)))));
     $export->alterTable('community_topic', array('change' => array('member_id' => array('definition' => array('type' => 'integer', 'notnull' => true)))));
     $export->dropForeignKey('community_topic_comment', 'community_topic_comment_FK_2');
     $export->dropForeignKey('community_topic', 'community_topic_FK_2');
     $export->createForeignKey('community_topic_comment', array('name' => 'community_topic_comment_FK_2', 'local' => 'member_id', 'foreign' => 'id', 'foreignTable' => 'member'));
     $export->createForeignKey('community_topic', array('name' => 'community_topic_FK_2', 'local' => 'member_id', 'foreign' => 'id', 'foreignTable' => 'member'));
     $communityTopicComments = CommunityTopicCommentPeer::doSelect(new Criteria());
     foreach ($communityTopicComments as $communityTopicComment) {
         $communityTopicComment->setUpdatedAt($communityTopic->getCreatedAt());
         $communityTopicComment->save();
     }
 }
 public function up()
 {
     $conn = Doctrine_Manager::connection();
     $export = $conn->export;
     $export->alterTable('community_topic_comment', array('add' => array('number' => array('type' => 'integer', 'default' => 0, 'notnull' => true))));
     $communityTopics = CommunityTopicPeer::doSelect(new Criteria());
     foreach ($communityTopics as $communityTopic) {
         $criteria = new Criteria();
         $criteria->add(CommunityTopicCommentPeer::COMMUNITY_TOPIC_ID, $communityTopic->getId());
         $criteria->addAscendingOrderByColumn(CommunityTopicCommentPeer::CREATED_AT);
         $communityTopicComments = CommunityTopicCommentPeer::doSelect($criteria);
         $i = 0;
         foreach ($communityTopicComments as $communityTopicComment) {
             $i++;
             $communityTopicComment->setNumber($i);
             $communityTopicComment->save();
         }
     }
     $export->alterTable('community_topic_comment', array('change' => array('number' => array('definition' => array('type' => 'integer', 'notnull' => true)))));
 }