Tadashi Okoshi
slash****@users*****
2006年 4月 6日 (木) 02:23:59 JST
Index: affelio/apps/diary/upgrade/index.cgi
diff -u affelio/apps/diary/upgrade/index.cgi:1.4 affelio/apps/diary/upgrade/index.cgi:1.5
--- affelio/apps/diary/upgrade/index.cgi:1.4 Wed Mar 1 17:07:18 2006
+++ affelio/apps/diary/upgrade/index.cgi Thu Apr 6 02:23:59 2006
@@ -97,6 +97,12 @@
$dbh->do("INSERT INTO $pref_table (key, value) VALUES ('max_textlen', '10000')");
$dbh->do("INSERT INTO $pref_table (key, value) VALUES ('show_author', '0')");
$dbh->do("INSERT INTO $pref_table (key, value) VALUES ('image_size', '300')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_popserv', '')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_popuser', '')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_poppass', '')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_author', '')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_lastcheck', '0')");
+ $dbh->do("INSERT INTO $pref_table (key, value) VALUES ('moblog_check_interval', '30')");
}else{
#Application table already exists.
#So, do nothing.
@@ -145,8 +151,6 @@
}
}#block
-
-
################################
#Add columns
################################
@@ -157,7 +161,17 @@
add_column($dbh, $entry_table, 'pwd', "TEXT");
add_column($dbh, $entry_table, 'draft', "INTEGER");
- ################################
+ ################################
+ #Add rows into pref_table
+ ################################
+ add_row_preftable($dbh, $pref_table, "moblog_author", "");
+ add_row_preftable($dbh, $pref_table, "moblog_popserv", "");
+ add_row_preftable($dbh, $pref_table, "moblog_popuser", "");
+ add_row_preftable($dbh, $pref_table, "moblog_poppass", "");
+ add_row_preftable($dbh, $pref_table, "moblog_lastcheck", "0");
+ add_row_preftable($dbh, $pref_table, "moblog_check_interval", "15");
+
+ ################################
#Update tables
################################
update_table($dbh, $entry_table, "c_id", "1", "NULL", "INTEGER");
@@ -174,6 +188,49 @@
+sub add_row_preftable{
+ my $dbh= shift;
+ my $pref_table= shift;
+ my $key = shift;
+ my $value = shift;
+
+ my $need =0;
+
+ my $query = "SELECT key from $pref_table where key = '$key'";
+ my $sth;
+ my @row =();
+ eval{
+ $sth = $dbh->prepare($query);
+ $sth->execute;
+ @row = $sth->fetchrow_array;
+ if(!@row){ $need = 1;}
+ };
+ if($@){
+ $need = 1;
+ }
+
+ if($need == 1){
+ print "We confirmed that pref_table needs row, key=[$key]<BR>";
+ my $query2 = "INSERT INTO $pref_table (key, value) VALUES ('$key', '$value')";
+ my $sth;
+ eval{
+ $dbh->do($query2);
+ };
+ if($@){
+ print 'Error occured in modifying the table<BR><BR>' . $@;
+ exit(1);
+ }
+ print "Successfully added row, key=[$key].<BR>";
+
+ }else{
+ #Application table already exists.
+ #So, do nothing.
+ print "We confirmed that pref_table already has row, key=[$key]<BR>";
+ print 'So, We will do nothing.<BR>';
+ }
+}
+
+
sub add_column{
my $dbh= shift;
my $table = shift;
@@ -209,6 +266,9 @@
}
+
+
+
sub update_table{
my $dbh= shift;
my $table = shift;