[Affelio-cvs 1394] CVS update: affelio

Back to archive index

Tadashi Okoshi slash****@users*****
2006年 8月 8日 (火) 08:04:36 JST


Index: affelio/upgrade.cgi
diff -u affelio/upgrade.cgi:1.15 affelio/upgrade.cgi:1.16
--- affelio/upgrade.cgi:1.15	Tue Jun  6 10:34:30 2006
+++ affelio/upgrade.cgi	Tue Aug  8 08:04:36 2006
@@ -283,18 +283,40 @@
     add_column($af, 'AFuser_CORE_friendsfriends', 'flag', "TEXT", "NULL");
 
     ################################
-    #Change AFuser_CORE_my_news.datetime from INTEGER to DATETIME (MySQL)
+    #*MySQL case*
+    #Change AFuser_CORE_my_news.datetime from INTEGER to DATETIME
     ################################
-    #TBD
-    #TBD
-    #TBD
+    if($af->{site__db_type} eq "mysql"){
+	my $query = 'ALTER TABLE AFuser_CORE_my_news MODIFY datetime DATETIME';
+        my $sth;
+	eval{
+	    $sth = $af->getDB->prepare($query);
+	    $sth->execute;
+	};
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "my_news.datetime updated. (INTEGER -> DATETIME) <BR>";
+	}
+    }
 
     ################################
-    #Change AFuser_CORE_nhgr_news.datetime from INTEGER to DATETIME (MySQL)
+    #*MySQL case*
+    #Change AFuser_CORE_nhgr_news.datetime from INTEGER to DATETIME
     ################################
-    #TBD
-    #TBD
-    #TBD
+    if($af->{site__db_type} eq "mysql"){
+	my $query = 'ALTER TABLE AFuser_CORE_nhgr_news MODIFY datetime DATETIME';
+        my $sth;
+	eval{
+	    $sth = $af->getDB->prepare($query);
+	    $sth->execute;
+	};
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "nhgr_news.datetime updated. (INTEGER -> DATETIME) <BR>";
+	}
+    }
 
     ################################
     #Add peer_type columns to SNS tables.
@@ -303,26 +325,88 @@
     add_column($af, 'AFuser_SNS_tmp_recvd_hs','peer_type',"TEXT","'Personal'");
 
     ################################
-    #MySQL case:  translate following columns to DATETIME
+    #*MySQL case*
+    #translate following columns to DATETIME
     ################################
-    #CORE_friends table
-    # lastupdated TEXT
-    # last_news_in INT
-    # last_news_out INT
-    # last_access INT
-    # count_access INT
-    # last_incoming INT
-    # last_outgoing INT
+    if($af->{site__db_type} eq "mysql"){
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY lastupdated DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.lastupdated updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY last_news_in DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.last_news_in updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY last_news_out DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.last_news_out updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY last_access DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.last_access updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY count_access DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.count_access updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY last_incoming DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.last_incoming updated. (TEXT -> DATETIME) <BR>";
+	}
+
+	do_SQL($af, "ALTER TABLE AFuser_CORE_friends MODIFY last_outgoing DATETIME");
+	if($@){
+	    print "$@<BR>";
+	}else{
+	    print "friends.last_outgoing updated. (TEXT -> DATETIME) <BR>";
+	}
+    }
 
     ################################
-    #Add attr64-attr65 to CORE_permission table
+    #Add additional profile attribute to CORE_permission table
     ################################
-    #TBD
-    #TBD
-    #TBD
-
+    {
+	my $sth = do_SQL($af, "SELECT max(aid) from AFuser_CORE_prof_attr");
+	if($@){ print "$@<BR>"; }
+	my ($maxid, $dummy) = $sth->fetchrow_array;
+	
+	open(IN, "defaults/AFuser_CORE_prof_attr.csv");
+	my $line="";
+	while($line=<IN>){
+	    chomp($line);
+	    my ($aid, $name, $type) = split(',', $line);		
+	    
+	    if($aid > $maxid){
+		do_SQL($af, "INSERT INTO AFuser_CORE_profile_attr (aid, name, type) values ($aid, '$name', $type)");
+		if($@){
+		    print "$@<BR>";
+		}else{
+		    print "Added into profile_attr table: [$aid] [$name]<BR>";
+		}
+	    }
+	}
+	close(IN); 
+    }
+    
     ################################
-    #Add attr64-attr65 to CORE_permission table
+    #Add 'af_type' column into nghr_news table
     ################################
     add_column($af, 'AFuser_SNS_CORE_nghr_news','af_type',"TEXT","'Personal'");
 
@@ -367,3 +451,18 @@
 	print 'So, We will do nothing.<BR>';
     }
 }
+
+
+###########################################################################
+sub do_SQL{
+    my $af = shift;
+    my $query = shift;
+
+    my $sth;
+    eval{
+	$sth = $af->getDB->prepare($query);
+	$sth->execute;
+    };
+    
+    return ($sth);
+}


Affelio-cvs メーリングリストの案内
Back to archive index