[Affelio-cvs 808] CVS update: affelio

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 12月 10日 (土) 04:46:09 JST


Index: affelio/upgrade-10-11.cgi
diff -u affelio/upgrade-10-11.cgi:1.3 affelio/upgrade-10-11.cgi:1.4
--- affelio/upgrade-10-11.cgi:1.3	Sun Nov 20 22:05:39 2005
+++ affelio/upgrade-10-11.cgi	Sat Dec 10 04:46:09 2005
@@ -96,8 +96,47 @@
 	}
     }#block
 
+    ################################
+    #Add columns to friend tale
+    ################################
+    add_column($af, 'AFuser_CORE_friends', 'last_news_in', "INTEGER");
+    add_column($af, 'AFuser_CORE_friends', 'last_news_in', "INTEGER");
+
     print 'OK. Successfuly done.<P><B>Delete this CGI immediately!!</B>';
     exit(1);
 }
 
 
+
+sub add_column{
+    my $af= shift;
+    my $table = shift;
+    my $col = shift;
+    my $type = shift;
+
+    my $query = "SELECT $col from $table";
+    my $sth;
+    eval{
+	$sth = $af->getDB->prepare($query);
+	$sth->execute;
+    };
+    if($@){
+	print "We confirmed that table [$table] needs column [$col]<BR>";
+	my $query2 = "ALTER TABLE $table ADD COLUMN $col $type";
+	my $sth;
+	eval{
+	    $af->getDB->do($query2);
+	};
+	if($@){
+	    print 'Error occured in modifying the table<BR><BR>' .  $@;
+	    exit(1);
+	}
+	print "Successfully added [$col].<BR>";
+	
+    }else{
+	#Application table already exists.
+	#So, do nothing.
+	print "We confirmed that table [$table] already has [$col]<BR>"; 
+	print 'So, We will do nothing.<BR>';
+    }
+}


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