[pLog-svn] r3484 - in plog/trunk: . install

Oscar Renalias oscar at renalias.net
Mon May 29 07:15:59 GMT 2006


Why do we need to drop these tables if we don't need them? I guess
they don't hurt if they're there but unused right?

On 5/29/06, mark at devel.lifetype.net <mark at devel.lifetype.net> wrote:
> Author: mark
> Date: 2006-05-29 06:11:20 +0000 (Mon, 29 May 2006)
> New Revision: 3484
>
> Added:
>    plog/trunk/install/changes_10_11.properties.php
> Modified:
>    plog/trunk/wizard.php
> Log:
> 1. Some code clean up.
> 2. Add $changes back and perform the post Schema Update after data changes.
>
> ** Now, the wizard will drop
> -category_id in articles
> -trackbacks.
> -my_recent
> -myrecent_categories
>
> Added: plog/trunk/install/changes_10_11.properties.php
> ===================================================================
> --- plog/trunk/install/changes_10_11.properties.php     2006-05-28 19:43:12 UTC (rev 3483)
> +++ plog/trunk/install/changes_10_11.properties.php     2006-05-29 06:11:20 UTC (rev 3484)
> @@ -0,0 +1,10 @@
> +<?php
> +
> +$Changes = Array(
> +    "ALTER TABLE {dbprefix}articles DROP COLUMN category_id",
> +    "DROP TABLE {dbprefix}trackbacks",
> +    "DROP TABLE {dbprefix}my_recent",
> +    "DROP TABLE {dbprefix}myrecent_categories"
> +);
> +
> +?>
> \ No newline at end of file
>
> Modified: plog/trunk/wizard.php
> ===================================================================
> --- plog/trunk/wizard.php       2006-05-28 19:43:12 UTC (rev 3483)
> +++ plog/trunk/wizard.php       2006-05-29 06:11:20 UTC (rev 3484)
> @@ -67,6 +67,8 @@
>      include_once( PLOG_CLASS_PATH."install/dbschemas.properties.php" );
>      // default configuration values for 1.1
>      include_once( PLOG_CLASS_PATH."install/defaultconfig.properties.php" );
> +    // post schema changes after upgrade
> +    include_once( PLOG_CLASS_PATH."install/changes_10_11.properties.php" );
>
>      define( "TEMP_FOLDER", "./tmp" );
>
> @@ -1236,7 +1238,6 @@
>          function perform()
>          {
>              global $Tables;
> -            global $Inserts;
>
>              // connect to the db
>              $this->_db = connectDb();
> @@ -1252,36 +1253,6 @@
>              }
>
>              // ---
> -            // create the new tables in 1.0
> -            // ---
> -            /*global $tables_11_new;
> -
> -            $dict = NewDataDictionary( $this->_db );
> -
> -            $errors = false;
> -            foreach( $tables_11_new as $name => $table ) {
> -
> -                $sqlarray = $dict->CreateTableSQL( $this->_dbPrefix.$name, $table );
> -
> -                // each table may need more than one sql query because of indexes, triggers, etc...
> -                $ok = true;
> -                foreach( $sqlarray as $sql ) {
> -                    $ok = ( $ok && $this->_db->Execute( $sql ));
> -                }
> -
> -                if( $ok )
> -                    $message .= "Table <strong>$name</strong> created successfully.<br/>";
> -                else {
> -                    $message .= "Error creating table $name: ".$this->_db->ErrorMsg()."<br/>";
> -                    $errors = true;
> -                }
> -            }
> -
> -            if( !$errors ) {
> -                $message .= "** New tables created successfully **<br/><br/>";
> -            }*/
> -
> -            // ---
>              // make changes to the tables that need changes, but leave it up to the data dictionary
>              // to take care of the changes
>              // ---
> @@ -1460,7 +1431,7 @@
>                      $numUpdated++;
>              }
>              $res1->Close();
> -            $this->message .= "{$numUpdated} users updated<br/>";
> +            $this->message .= "{$numUpdated} users updated.<br/>";
>              return true;
>          }
>
> @@ -1557,7 +1528,7 @@
>              }
>              $res4->Close();
>
> -            $this->message .= "{$numUpdated} articles updated<br/>";
> +            $this->message .= "{$numUpdated} articles updated.<br/>";
>              return true;
>          }
>
> @@ -1619,7 +1590,6 @@
>                  // and execute it
>                  $result = $this->db->Execute( $query );
>                  if( !$result ) {
> -                print(" cat update query error = $query<br/>");
>                      $this->message .= "Error updating category with id {$catId}<br/>";
>                  }
>                  else
> @@ -1627,7 +1597,7 @@
>              }
>              $res3->Close();
>
> -            $this->message .= "{$numUpdated} categories updated<br/>";
> +            $this->message .= "{$numUpdated} categories updated.<br/>";
>              return true;
>          }
>
> @@ -1646,12 +1616,10 @@
>              $query2 = "SELECT a.blog_id AS blog_id, COUNT(*) AS total FROM ".$this->dbPrefix."articles_comments c, ".
>                        $this->dbPrefix."articles a WHERE a.id = c.article_id AND a.status = ".POST_STATUS_PUBLISHED.
>                        " GROUP BY a.blog_id";
> -            print($query2);
>              // number of trackbacks
>              $query3 = "SELECT blog_id, COUNT(*) AS total FROM ".$this->dbPrefix."trackbacks t,".
>                        $this->dbPrefix."articles a WHERE a.id = t.article_id ".
>                        "GROUP BY a.blog_id";
> -            print($query3);
>              // list of blog ids
>              $query4 = "SELECT id FROM ".$this->dbPrefix."blogs";
>              // create_date and last_update_date
> @@ -1742,7 +1710,6 @@
>                            create_date = '{$createDate}',
>                            last_update_date = '{$lastUpdateDate}'
>                            WHERE id = {$blogId}";
> -                print("blog update query=$query<br/>");
>
>                  // and execute it
>                  $result = $this->db->Execute( $query );
> @@ -1754,7 +1721,7 @@
>              }
>              $res4->Close();
>
> -            $this->message .= "{$numUpdated} blogs updated<br/>";
> +            $this->message .= "{$numUpdated} blogs updated.<br/>";
>              return true;
>          }
>
> @@ -1843,7 +1810,6 @@
>
>                  // and execute it
>                  $result = $this->db->Execute( $query );
> -                print("cat query = $query<br/>");
>                  if( !$result ) {
>                      $this->message .= "Error updating links category with id {$catId}<br/>";
>                  }
> @@ -1852,7 +1818,7 @@
>              }
>              $res2->Close();
>
> -            $this->message .= "{$numUpdated} links categories updated<br/>";
> +            $this->message .= "{$numUpdated} links categories updated.<br/>";
>              return true;
>          }
>
> @@ -1957,10 +1923,30 @@
>              }
>              $res3->Close();
>
> -            $this->message .= "{$numUpdated} gallery albums updated successfully<br/>";
> +            $this->message .= "{$numUpdated} gallery albums updated.<br/>";
>
>              return true;
>          }
> +
> +        function postSchemaUpdate()
> +        {
> +               global $Changes;
> +
> +            foreach( $Changes as $change ) {
> +                // replace the de prefix and base url
> +                $query = str_replace( "{dbprefix}", $this->dbPrefix, $change );
> +                $result = $this->db->Execute( $query  );
> +                if( !$result ) {
> +                       $this->message .= "Error updating database schema {$query}<br/>";
> +                    return true;
> +                }
> +                $result->Close();
> +            }
> +
> +            $this->message .= "Post database schema updated.<br/>";
> +
> +            return true;
> +        }
>
>         function perform()
>         {
> @@ -1972,7 +1958,7 @@
>              $this->message = "";
>
>              $methods = Array( "updateArticleCounters", "updateCategoryCounters", "updateBlogCounters", "updateTrackbacks",
> -                              "updateLinkCategories", "updateAlbums", "updateComments", "updateAdminUsers" );
> +                              "updateLinkCategories", "updateAlbums", "updateComments", "updateAdminUsers", "postSchemaUpdate" );
>
>              foreach( $methods as $method ) {
>                  $result = $this->$method();
> @@ -1987,8 +1973,6 @@
>              // everything went fine so we can show the final page!
>              $this->_view = new WizardView( "update4" );
>
> -            print("message: ".$this->message);
> -
>              $this->_view->setValue( "message", $this->message );
>
>              return true;
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>


More information about the pLog-svn mailing list