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

Mark Wu markplace at gmail.com
Fri Mar 31 07:57:05 GMT 2006


BTW, I just did the installation test, and did not test the upgrade process
...

The code looks weird.  I will take a look.

Mark 

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net 
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of 
> mark at devel.lifetype.net
> Sent: Friday, March 31, 2006 3:29 PM
> To: plog-svn at devel.lifetype.net
> Subject: [pLog-svn] r3167 - in plog/trunk: . install
> 
> Author: mark
> Date: 2006-03-31 07:29:18 +0000 (Fri, 31 Mar 2006) New Revision: 3167
> 
> Modified:
>    plog/trunk/install/changes_10_11.properties.php
>    plog/trunk/install/dbschemas.properties.php
>    plog/trunk/wizard.php
> Log:
> Now we can specify the table type (or options) in schema files.
> 
> We can use:
> 
> 1. $Tables["tablename"]["schema"] to represent the table 
> create/change sql 2. $Tables["tablename"]["options"] to 
> represent the table create options.
> 
> These modification apply to changes_10_11.properties.php and 
> dbschemas.properties.php these two files.
> 
> I also modify the wizard.php to adapt the new changes.
> 
> Only one problem, I suppose different kind of database will 
> have different dbschema file. So, I did not specify the 
> ["options"] is for mysql, oracle or mssql.
> 
> Modified: plog/trunk/install/changes_10_11.properties.php
> ===================================================================
> --- plog/trunk/install/changes_10_11.properties.php	
> 2006-03-31 02:51:36 UTC (rev 3166)
> +++ plog/trunk/install/changes_10_11.properties.php	
> 2006-03-31 07:29:18 UTC (rev 3167)
> @@ -1,10 +1,10 @@
>  <?php
>  
> -$Changes["Deletions"] = Array(
> +$Changes["Deletions"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}articles DROP COLUMN category_id"
>  );
>  
> -$Changes["Articles"] = Array(    
> +$Changes["Articles"]["schema"] = Array(    
>      "ALTER TABLE {dbprefix}articles ADD COLUMN num_comments 
> INTEGER(10) NOT NULL DEFAULT 0",
>      "ALTER TABLE {dbprefix}articles ADD COLUMN 
> num_nonspam_comments INTEGER(10) NOT NULL DEFAULT 0",
>      "ALTER TABLE {dbprefix}articles ADD COLUMN 
> num_trackbacks INTEGER(10) NOT NULL DEFAULT 0", @@ -13,15 +13,15 @@
>      "ALTER TABLE {dbprefix}articles ADD COLUMN 
> in_summary_page TINYINT(10) NOT NULL DEFAULT 1", 
>      "ALTER TABLE {dbprefix}articles ADD COLUMN 
> modification_date TIMESTAMP(14) NOT NULL"
>  );
> -$Changes["Article Categories"] = Array(
> +$Changes["Article Categories"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}articles_categories ADD COLUMN 
> num_articles INTEGER(10) NOT NULL DEFAULT 0",
>      "ALTER TABLE {dbprefix}articles_categories ADD COLUMN 
> num_published_articles INTEGER(10) NOT NULL DEFAULT 0"
>  );
> -$Changes["Article Comments"] = Array(
> +$Changes["Article Comments"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}articles_comments ADD COLUMN type 
> INTEGER(2) NOT NULL DEFAULT 1",
>      "ALTER TABLE {dbprefix}articles_comments ADD COLUMN 
> blog_id INTEGER(10) NOT NULL DEFAULT 0",  ); 
> -$Changes["Blogs"] = Array(
> +$Changes["Blogs"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}blogs ADD COLUMN create_date 
> TIMESTAMP(14)",
>      "ALTER TABLE {dbprefix}blogs ADD COLUMN last_update_date 
> TIMESTAMP(14)",
>      "ALTER TABLE {dbprefix}blogs ADD COLUMN num_posts 
> INT(10) NOT NULL DEFAULT 0", @@ -31,14 +31,14 @@
>      "ALTER TABLE {dbprefix}blogs ADD COLUMN blog_category_id 
> INT(4) NOT NULL DEFAULT 0",
>      "ALTER TABLE {dbprefix}blogs ADD COLUMN custom_domain 
> VARCHAR(50)"    
>  );
> -$Changes["Gallery Albums"] = Array(
> +$Changes["Gallery Albums"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN 
> num_resources INT(10)",
>      "ALTER TABLE {dbprefix}gallery_albums ADD COLUMN 
> num_children INT(10)"
>  );
> -$Changes["Links Categories"] = Array(
> +$Changes["Links Categories"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}mylinks_categories ADD COLUMN 
> num_links INT(10)"
>  );
> -$Changes["Users"] = Array(
> +$Changes["Users"]["schema"] = Array(
>      "ALTER TABLE {dbprefix}users ADD COLUMN site_admin INT(10)"
>  );
>  
> 
> Modified: plog/trunk/install/dbschemas.properties.php
> ===================================================================
> --- plog/trunk/install/dbschemas.properties.php	
> 2006-03-31 02:51:36 UTC (rev 3166)
> +++ plog/trunk/install/dbschemas.properties.php	
> 2006-03-31 07:29:18 UTC (rev 3167)
> @@ -1,6 +1,6 @@
> -<?php
> +<?php
>  
> -$Tables["articles"] = "
> +$Tables["articles"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    category_id I(10) UNSIGNED NOTNULL DEFAULT '0',
>    date T(14) NOTNULL,
> @@ -23,11 +23,12 @@
>    INDEX user_id (user_id),
>    INDEX slug (slug),
>    INDEX blog_id_slug (blog_id,slug),
> -  INDEX blog_id_slug_category_id (blog_id, slug, category_id)
> +  INDEX blog_id_slug_category_id (blog_id, slug, category_id),
>    INDEX global_category_status (global_category_id, status)  ";
> +$Tables["articles"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["articles_categories"] = "
> +$Tables["articles_categories"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    name C(255) NOTNULL DEFAULT '',
>    url C(255) NOTNULL DEFAULT '',
> @@ -40,13 +41,14 @@
>    mangled_name C(255) NOTNULL DEFAULT '',
>    num_articles I(10) NOTNULL DEFAULT 0,
>    num_published_articles I(10) NOTNULL DEFAULT 0
> -  INDEX parent_id (parent_id),
> -  INDEX blog_id (blog_id),
> +  INDEX parent_id (parent_id),
> +  INDEX blog_id (blog_id),
>    INDEX mangled_name (mangled_name)
>  ";
> +$Tables["articles_categories"]["options"] = "TYPE=MyISAM";
>  
>  
> -$Tables["articles_comments"] = "
> +$Tables["articles_comments"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    article_id I(10) UNSIGNED NOTNULL DEFAULT 0,
>    blog_id I(10) UNSIGNED NOTNULL DEFAULT 0,
> @@ -73,8 +75,9 @@
>    FULLTEXT normalized_text (normalized_text),
>    FULLTEXT normalized_topic (normalized_topic)
>  ";
> +$Tables["articles_comments"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["articles_notifications"] = "
> +$Tables["articles_notifications"]["schema"] = "
>    id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>    blog_id I(10) NOTNULL DEFAULT '0',
>    user_id I(10) NOTNULL DEFAULT '0',
> @@ -83,8 +86,9 @@
>    INDEX user_id (user_id),
>    INDEX blog_id (blog_id)
>  ";
> +$Tables["articles_notifications"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["blogs"] = "
> +$Tables["blogs"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT INDEX PRIMARY,
>    blog varchar(50) NOTNULL DEFAULT '',
>    owner_id I(10) UNSIGNED NOTNULL DEFAULT '0',
> @@ -105,8 +109,9 @@
>    INDEX blog_category_id(blog_category_id),
>    INDEX custom_domain(custom_domain)
>  ";
> +$Tables["blogs"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["mylinks"] = "
> +$Tables["mylinks"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    category_id I(10) UNSIGNED NOTNULL DEFAULT '0',
>    url C(255) NOTNULL DEFAULT '',
> @@ -119,8 +124,9 @@
>    INDEX blog_id (blog_id),
>    INDEX category_id (category_id)
>  ";
> +$Tables["mylinks"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["mylinks_categories"] = "
> +$Tables["mylinks_categories"]["schema"] = "
>    id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>    name varchar(100) NOTNULL DEFAULT '',
>    blog_id I(10) NOTNULL DEFAULT '0',
> @@ -129,14 +135,16 @@
>    num_links I(10) NOTNULL DEFAULT '0',
>    INDEX blog_id (blog_id)
>  ";
> +$Tables["mylinks_categories"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["permissions"] = "
> +$Tables["permissions"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    permission varchar(25) NOTNULL DEFAULT '',
>    description varchar(100) NOTNULL DEFAULT ''
>  ";
> +$Tables["permissions"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["referers"] = "
> +$Tables["referers"]["schema"] = "
>    id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>    url X NOTNULL,
>    article_id I(10) NOTNULL DEFAULT '0',
> @@ -147,8 +155,9 @@
>    INDEX blog_id (blog_id),
>    INDEX blog_id_article_id (blog_id, article_id)
>  ";
> +$Tables["referers"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["users"] = "
> +$Tables["users"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    user varchar(15) NOTNULL DEFAULT '',
>    password varchar(32) NOTNULL DEFAULT '',
> @@ -161,8 +170,9 @@
>    site_admin I(10) NOTNULL DEFAULT '0',
>    UNIQUE user (user)
>  ";
> +$Tables["users"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["users_permissions"] = "
> +$Tables["users_permissions"]["schema"] = "
>    id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>    user_id I(10) UNSIGNED NOTNULL DEFAULT '0',
>    blog_id I(10) UNSIGNED NOTNULL DEFAULT '0',
> @@ -171,16 +181,17 @@
>    INDEX blog_id (blog_id),
>    INDEX user_id_permission_id (user_id,permission_id)
>  ";
> +$Tables["users_permissions"]["options"] = "TYPE=MyISAM";
>  
> -
> -$Tables["config"] = "
> +$Tables["config"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     config_key C(255) NOTNULL DEFAULT '' PRIMARY,
>     config_value X NOTNULL,
>     value_type I(3) DEFAULT '0'
>  ";
> +$Tables["config"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["filtered_content"] = "
> +$Tables["filtered_content"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     reg_exp X,
>     blog_id I(10) NOTNULL DEFAULT '0',
> @@ -188,8 +199,9 @@
>     date T(14) NOTNULL,
>     INDEX blog_id (blog_id)
>  ";
> +$Tables["filtered_content"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["host_blocking_rules"] = "
> +$Tables["host_blocking_rules"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     reason X,
>     date T(14) NOTNULL,
> @@ -200,8 +212,9 @@
>     host varchar(15) DEFAULT '0.0.0.0',
>     INDEX blog_id (blog_id)
>  ";
> +$Tables["host_blocking_rules"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["gallery_resources"] = "
> +$Tables["gallery_resources"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     owner_id I(10) NOTNULL DEFAULT '0',
>     album_id I(10) NOTNULL DEFAULT '0',
> @@ -223,8 +236,9 @@
>     INDEX resource_type (resource_type),
>     FULLTEXT normalized_description (normalized_description)
>  ";
> +$Tables["gallery_resources"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["gallery_albums"] = "
> +$Tables["gallery_albums"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     owner_id I(10) NOTNULL DEFAULT '0',
>     description X NOTNULL,
> @@ -247,16 +261,18 @@
>     FULLTEXT normalized_description (normalized_description),
>     FULLTEXT normalized_fields (normalized_name, 
> normalized_description)
>  ";
> +$Tables["gallery_albums"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["bayesian_filter_info"] = "
> +$Tables["bayesian_filter_info"]["schema"] = "
>     id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>     blog_id I(10) UNSIGNED DEFAULT NULL,
>     total_spam I(10) UNSIGNED DEFAULT NULL,
>     total_nonspam I(10) UNSIGNED DEFAULT NULL,
>     INDEX blog_id (blog_id)
>  ";
> +$Tables["bayesian_filter_info"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["bayesian_tokens"] = "
> +$Tables["bayesian_tokens"]["schema"] = "
>     id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>     blog_id I(10) UNSIGNED DEFAULT NULL,
>     token char(100) DEFAULT NULL,
> @@ -266,13 +282,15 @@
>     INDEX blog_id (blog_id),
>     INDEX token (token)
>  ";
> +$Tables["bayesian_tokens"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["article_categories_link"] = "
> +$Tables["article_categories_link"]["schema"] = "
>     article_id I(10) NOTNULL PRIMARY,
>     category_id I(10) NOTNULL PRIMARY
>  ";
> +$Tables["article_categories_link"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["custom_fields_definition"] = "
> +$Tables["custom_fields_definition"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     field_name C(255) NOTNULL DEFAULT '' PRIMARY,
>     field_description X NOTNULL,
> @@ -283,8 +301,9 @@
>     hidden I1 DEFAULT 1,
>     INDEX blog_id (blog_id)
>  ";
> +$Tables["custom_fields_definition"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["custom_fields_values"] = "
> +$Tables["custom_fields_values"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     field_id I(10) NOTNULL DEFAULT '0',
>     field_value X NOTNULL,
> @@ -297,8 +316,9 @@
>     INDEX field_id (field_id),
>     INDEX blog_id_article_id (blog_id, article_id)
>  ";
> +$Tables["custom_fields_values"]["options"] = "TYPE=MyISAM";
>  
> -$Tables["articles_text"] = "
> +$Tables["articles_text"]["schema"] = "
>     id I(10) NOTNULL AUTOINCREMENT PRIMARY,
>     article_id I(10) NOTNULL DEFAULT 0,
>     text X NOTNULL DEFAULT '',
> @@ -311,8 +331,9 @@
>     FULLTEXT normalized_topic (normalized_topic),
>     FULLTEXT normalized_fields (normalized_text, normalized_topic)
>  ";
> +$Tables["articles_text"]["options"] = "TYPE=MyISAM";
>     
> -$Tables["phpbb2_users"] = "
> +$Tables["phpbb2_users"]["schema"] = "
>     id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>     phpbb_id I(10) UNSIGNED NOTNULL,
>     full_name C(255) NOTNULL DEFAULT '',
> @@ -322,8 +343,9 @@
>     status I(10) NOTNULL DEFAULT 0,
>     UNIQUE phpbb_id(phpbb_id)
>  ";
> +$Tables["phpbb2_users"]["options"] = "TYPE=MyISAM";
>     
> -$Tables["blog_categories"] = "
> +$Tables["blog_categories"]["schema"] = "
>     id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>     name C(255) NOTNULL DEFAULT '',
>     description C(255) NOTNULL DEFAULT '',
> @@ -333,8 +355,9 @@
>     num_active_blogs I(10) NOTNULL DEFAULT '0',
>     INDEX mangled_name(mangled_name)
>  ";
> +$Tables["blog_categories"]["options"] = "TYPE=MyISAM";
>     
> -$Tables["global_articles_categories"] = "
> +$Tables["global_articles_categories"]["schema"] = "
>     id I(10) UNSIGNED NOTNULL AUTOINCREMENT PRIMARY,
>     name C(255) NOTNULL DEFAULT '',
>     description C(255) NOTNULL DEFAULT '',
> @@ -344,5 +367,6 @@
>     num_active_articles I(10) NOTNULL DEFAULT '0',
>     INDEX mangled_name(mangled_name)
>  ";
> -
> +$Tables["global_articles_categories"]["options"] = "TYPE=MyISAM";
> +
>  ?>
> \ No newline at end of file
> 
> Modified: plog/trunk/wizard.php
> ===================================================================
> --- plog/trunk/wizard.php	2006-03-31 02:51:36 UTC (rev 3166)
> +++ plog/trunk/wizard.php	2006-03-31 07:29:18 UTC (rev 3167)
> @@ -702,8 +702,17 @@
>              $errors = false;            
>              
>              foreach( $Tables as $name => $table ) {
> -                $sqlarray = $dict->CreateTableSQL( 
> $this->_dbPrefix.$name, $table, array( "MYSQL" => "TYPE=MyISAM" ) );
> -                
> +            	$upperName = $dict->upperName;
> +            	$tableSchema = $table["schema"];
> +            	if ( isset( $table["options"] ) )
> +            	{
> +            		$tableOptions = $table["options"];
> +            		$options = array ( $upperName => 
> $tableOptions );
> +            	} else {
> +            		$options = array ();
> +                }
> +                $sqlarray = $dict->CreateTableSQL( 
> $this->_dbPrefix.$name, $tableSchema, $options );
> +
>                  // each table may need more than one sql 
> query because of indexes, triggers, etc...
>                  $ok = true;
>                  foreach( $sqlarray as $sql ) {
> @@ -1108,16 +1117,21 @@
>              // ---
>              $dict = NewDataDictionary( $this->_db );            
>              $errors = false;
> -            foreach( $Tables as $name => $table ) {
> +            foreach( $Changes as $name => $change ) {
>                  $errorMessage = "";
> -                
> +            	$upperName = $dict->upperName;
> +            	$changeSchema = $change["schema"];
> +            	if ( isset( $change["options"] ) )
> +            	{
> +            		$changeOptions = $change["options"];
> +            		$options = array ( $upperName => 
> $changeOptions );
> +            	} else {
> +            		$options = array ();
> +                }
> +               
>                  // generate the code with the changes for the table
> -                $sqlarray = $dict->ChangeTableSQL( 
> $this->_dbPrefix.$name, $table );
> +                $sqlarray = $dict->ChangeTableSQL( 
> $this->_dbPrefix.$name, $changeSchema, $options );
>                  
> -                echo "===";
> -                print_r($sqlarray);
> -                echo "===";
> -                
>                  //print("<hr/><pre>");
>                  foreach( $sqlarray as $sql ) {
>                      //print($sql."<br/>");
> 
> _______________________________________________
> 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