[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/upgrades/ -> 0_17_inc.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # Changes applied to 0.17 database to give us ____
  21  
  22      # --------------------------------------------------------
  23      # $Id: 0_17_inc.php,v 1.14.16.1 2007-10-13 22:35:08 giallu Exp $
  24      # --------------------------------------------------------
  25  ?>
  26  <?php
  27      require( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'db_table_names_inc.php' );
  28  
  29      $upgrades = array();
  30  
  31      $upgrades[] = new SQLUpgrade(
  32          '0.17-jf-1',
  33          'Printing Preference Table',
  34          "CREATE TABLE IF NOT EXISTS $t_user_print_pref_table (user_id int(7) unsigned zerofill NOT ".
  35            "NULL default '0000000', print_pref varchar(27) NOT NULL default '', PRIMARY KEY ".
  36            "(user_id))" );
  37  
  38      $upgrades[] = new FunctionUpgrade(
  39          '0.17-jf-2',
  40          'Bug history',
  41          'upgrade_0_17_jf_2' );
  42  
  43  	function upgrade_0_17_jf_2() {
  44          global $t_bug_history_table;
  45  
  46          if ( !db_field_exists( 'type', $t_bug_history_table ) ) {
  47              $query = "ALTER TABLE $t_bug_history_table ADD type INT(2) NOT NULL";
  48  
  49              $result = @db_query( $query );
  50  
  51              if ( false == $result ) {
  52                  return false;
  53              }
  54          }
  55  
  56          return true;
  57      }
  58  
  59      $upgrades[] = new FunctionUpgrade(
  60          '0.17-jf-3',
  61          'Auto-assigning of bugs for a default user per category',
  62          'upgrade_0_17_jf_3' );
  63  
  64  	function upgrade_0_17_jf_3() {
  65          global $t_project_category_table;
  66  
  67          if ( !db_field_exists( 'user_id', $t_project_category_table ) ) {
  68              $query = "ALTER TABLE $t_project_category_table ADD user_id INT(7) NOT NULL";
  69  
  70              $result = @db_query( $query );
  71  
  72              if ( false == $result ) {
  73                  return false;
  74              }
  75          }
  76  
  77          return true;
  78      }
  79  
  80      $upgrades[] = new FunctionUpgrade(
  81          '0.17-jf-4',
  82          'Private news support',
  83          'upgrade_0_17_jf_4' );
  84  
  85  	function upgrade_0_17_jf_4() {
  86          global $t_news_table;
  87  
  88          if ( !db_field_exists( 'view_state', $t_news_table ) ) {
  89              $query = "ALTER TABLE $t_news_table ADD view_state INT(2) DEFAULT '10' NOT NULL
  90                          AFTER last_modified";
  91  
  92              $result = @db_query( $query );
  93  
  94              if ( false == $result ) {
  95                  return false;
  96              }
  97          }
  98  
  99          return true;
 100      }
 101  
 102      $upgrades[] = new FunctionUpgrade(
 103          '0.17-jf-5',
 104          'Allow news items to stay at the top',
 105          'upgrade_0_17_jf_5' );
 106  
 107  	function upgrade_0_17_jf_5() {
 108          global $t_news_table;
 109  
 110          if ( !db_field_exists( 'announcement', $t_news_table ) ) {
 111              $query = "ALTER TABLE $t_news_table ADD announcement INT(1) NOT NULL AFTER view_state";
 112  
 113              $result = @db_query( $query );
 114  
 115              if ( false == $result ) {
 116                  return false;
 117              }
 118          }
 119  
 120          return true;
 121      }
 122  
 123      $upgrades[] = new FunctionUpgrade(
 124          '0.17-jf-6',
 125          'relationship support',
 126          'upgrade_0_17_jf_6' );
 127  
 128  	function upgrade_0_17_jf_6() {
 129          global $t_bug_relationship_table;
 130  
 131          if ( !db_field_exists( 'id', $t_bug_relationship_table ) ) {
 132              $query = "ALTER TABLE $t_bug_relationship_table ADD id INT(7) UNSIGNED ZEROFILL NOT
 133                          NULL AUTO_INCREMENT PRIMARY KEY FIRST";
 134  
 135              $result = @db_query( $query );
 136  
 137              if ( false == $result ) {
 138                  return false;
 139              }
 140          }
 141  
 142          return true;
 143      }
 144  
 145      $upgrades[] = new SQLUpgrade(
 146          '0.17-custom-field-1',
 147          'Add mantis_custom_field_table',
 148          "CREATE TABLE IF NOT EXISTS $t_custom_field_table (
 149            id int(3) NOT NULL auto_increment,
 150            name varchar(64) NOT NULL default '',
 151            type int(2) NOT NULL default '0',
 152            possible_values varchar(255) NOT NULL default '',
 153            default_value varchar(255) NOT NULL default '',
 154            valid_regexp varchar(255) NOT NULL default '',
 155            access_level_r int(2) NOT NULL default '0',
 156            access_level_rw int(2) NOT NULL default '0',
 157            length_min int(3) NOT NULL default '0',
 158            length_max int(3) NOT NULL default '0',
 159            advanced int(1) NOT NULL default '0',
 160            PRIMARY KEY (id),
 161            KEY name (name))" );
 162  
 163      $upgrades[] = new SQLUpgrade(
 164          '0.17-custom-field-2',
 165          'Add mantis_custom_field_string_table',
 166          "CREATE TABLE IF NOT EXISTS $t_custom_field_string_table (
 167            field_id int(3) NOT NULL,
 168            bug_id int(7) NOT NULL,
 169            value varchar(255) NOT NULL default '',
 170            PRIMARY KEY (field_id,bug_id))" );
 171  
 172      $upgrades[] = new SQLUpgrade(
 173          '0.17-custom-field-3',
 174          'Add mantis_custom_field_project_table',
 175          "CREATE TABLE IF NOT EXISTS $t_custom_field_project_table (
 176            field_id int(3) NOT NULL,
 177            project_id int(7) unsigned NOT NULL,
 178            sequence int(2) NOT NULL default '0',
 179            PRIMARY KEY (field_id,project_id))" );
 180  
 181      $upgrades[] = new SQLUpgrade(
 182          '0.17-jf-7',
 183          'Drop mantis_project_customization_table',
 184          "DROP TABLE IF EXISTS mantis_project_customization_table" );
 185  
 186      $upgrades[] = new SQLUpgrade(
 187          '0.17-jf-8',
 188          'Drop votes column of mantis_bug_table',
 189          "ALTER TABLE $t_bug_table DROP COLUMN votes" );
 190  
 191      $upgrades[] = new SQLUpgrade(
 192          '0.17-jf-9',
 193          'Add primary key on mantis_project_version_table',
 194          "ALTER IGNORE TABLE $t_project_version_table ADD PRIMARY KEY (project_id,version)" );
 195  
 196      $upgrades[] = new SQLUpgrade(
 197          '0.17-jf-10',
 198          'Add primary key on mantis_project_user_list_table',
 199          "ALTER IGNORE TABLE $t_project_user_list_table ADD PRIMARY KEY (project_id,user_id)" );
 200  
 201      $upgrades[] = new SQLUpgrade(
 202          '0.17-jf-11',
 203          'Add primary key on mantis_project_category_table',
 204          "ALTER IGNORE TABLE $t_project_category_table ADD PRIMARY KEY (project_id,category)" );
 205  
 206      $upgrades[] = new SQLUpgrade(
 207          '0.17-jf-12',
 208          'Add primary key on mantis_bug_monitor_table',
 209          "ALTER IGNORE TABLE $t_bug_monitor_table ADD PRIMARY KEY (user_id,bug_id)" );
 210  
 211      $upgrades[] = new SQLUpgrade(
 212          '0.17-jf-13',
 213          'Remove zerofill on mantis_bug_file_table.id',
 214          "ALTER TABLE $t_bug_file_table
 215              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 216  
 217      $upgrades[] = new SQLUpgrade(
 218          '0.17-jf-14',
 219          'Remove zerofill on mantis_bug_file_table.bug_id',
 220          "ALTER TABLE $t_bug_file_table
 221              MODIFY bug_id int(7) unsigned NOT NULL" );
 222  
 223      $upgrades[] = new SQLUpgrade(
 224          '0.17-jf-15',
 225          'Remove zerofill on mantis_bug_history_table.user_id',
 226          "ALTER TABLE $t_bug_history_table
 227              MODIFY user_id int(7) unsigned NOT NULL" );
 228  
 229      $upgrades[] = new SQLUpgrade(
 230          '0.17-jf-16',
 231          'Remove zerofill on mantis_bug_history_table.bug_id',
 232          "ALTER TABLE $t_bug_history_table
 233              MODIFY bug_id int(7) unsigned NOT NULL" );
 234  
 235      $upgrades[] = new SQLUpgrade(
 236          '0.17-jf-17',
 237          'Remove zerofill on mantis_bug_monitor_table.user_id',
 238          "ALTER TABLE $t_bug_monitor_table
 239              MODIFY user_id int(7) unsigned NOT NULL" );
 240  
 241      $upgrades[] = new SQLUpgrade(
 242          '0.17-jf-18',
 243          'Remove zerofill on mantis_bug_relationship_table.id',
 244          "ALTER TABLE $t_bug_relationship_table
 245              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 246  
 247      $upgrades[] = new SQLUpgrade(
 248          '0.17-jf-19',
 249          'Remove zerofill on mantis_bug_relationship_table.source_bug_id',
 250          "ALTER TABLE $t_bug_relationship_table
 251              MODIFY source_bug_id int(7) unsigned NOT NULL default 0" );
 252  
 253      $upgrades[] = new SQLUpgrade(
 254          '0.17-jf-20',
 255          'Remove zerofill on mantis_bug_relationship_table.destination_bug_id',
 256          "ALTER TABLE $t_bug_relationship_table
 257              MODIFY destination_bug_id int(7) unsigned NOT NULL default 0" );
 258  
 259      $upgrades[] = new SQLUpgrade(
 260          '0.17-jf-21',
 261          'Remove zerofill on mantis_bug_table.id',
 262          "ALTER TABLE $t_bug_table
 263              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 264  
 265      $upgrades[] = new SQLUpgrade(
 266          '0.17-jf-22',
 267          'Remove zerofill on mantis_bug_table.project_id',
 268          "ALTER TABLE $t_bug_table
 269              MODIFY project_id int(7) unsigned NOT NULL" );
 270  
 271      $upgrades[] = new SQLUpgrade(
 272          '0.17-jf-23',
 273          'Remove zerofill on mantis_bug_table.reporter_id',
 274          "ALTER TABLE $t_bug_table
 275              MODIFY reporter_id int(7) unsigned NOT NULL default 0" );
 276  
 277      $upgrades[] = new SQLUpgrade(
 278          '0.17-jf-24',
 279          'Remove zerofill on mantis_bug_table.handler_id',
 280          "ALTER TABLE $t_bug_table
 281              MODIFY handler_id int(7) unsigned NOT NULL default 0" );
 282  
 283      $upgrades[] = new SQLUpgrade(
 284          '0.17-jf-25',
 285          'Remove zerofill on mantis_bug_table.duplicate_id',
 286          "ALTER TABLE $t_bug_table
 287              MODIFY duplicate_id int(7) unsigned NOT NULL default 0" );
 288  
 289      $upgrades[] = new SQLUpgrade(
 290          '0.17-jf-26',
 291          'Remove zerofill on mantis_bug_table.bug_text_id',
 292          "ALTER TABLE $t_bug_table
 293              MODIFY bug_text_id int(7) unsigned NOT NULL" );
 294  
 295      $upgrades[] = new SQLUpgrade(
 296          '0.17-jf-27',
 297          'Remove zerofill on mantis_bug_table.profile_id',
 298          "ALTER TABLE $t_bug_table
 299              MODIFY profile_id int(7) unsigned NOT NULL default 0" );
 300  
 301      $upgrades[] = new SQLUpgrade(
 302          '0.17-jf-28',
 303          'Remove zerofill on mantis_bug_text_table.id',
 304          "ALTER TABLE $t_bug_text_table
 305              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 306  
 307      $upgrades[] = new SQLUpgrade(
 308          '0.17-jf-29',
 309          'Remove zerofill on mantis_bugnote_table.id',
 310          "ALTER TABLE $t_bugnote_table
 311              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 312  
 313      $upgrades[] = new SQLUpgrade(
 314          '0.17-jf-30',
 315          'Remove zerofill on mantis_bugnote_table.bug_id',
 316          "ALTER TABLE $t_bugnote_table
 317              MODIFY bug_id int(7) unsigned NOT NULL" );
 318  
 319      $upgrades[] = new SQLUpgrade(
 320          '0.17-jf-31',
 321          'Remove zerofill on mantis_bugnote_table.reporter_id',
 322          "ALTER TABLE $t_bugnote_table
 323              MODIFY reporter_id int(7) unsigned NOT NULL" );
 324  
 325      $upgrades[] = new SQLUpgrade(
 326          '0.17-jf-32',
 327          'Remove zerofill on mantis_bugnote_table.bugnote_text_id',
 328          "ALTER TABLE $t_bugnote_table
 329              MODIFY bugnote_text_id int(7) unsigned NOT NULL" );
 330  
 331      $upgrades[] = new SQLUpgrade(
 332          '0.17-jf-33',
 333          'Remove zerofill on mantis_bugnote_text_table.id',
 334          "ALTER TABLE $t_bugnote_text_table
 335              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 336  
 337      $upgrades[] = new SQLUpgrade(
 338          '0.17-jf-34',
 339          'Remove zerofill on mantis_news_table.id',
 340          "ALTER TABLE $t_news_table
 341              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 342  
 343      $upgrades[] = new SQLUpgrade(
 344          '0.17-jf-35',
 345          'Remove zerofill on mantis_news_table.project_id',
 346          "ALTER TABLE $t_news_table
 347              MODIFY project_id int(7) unsigned NOT NULL default 0" );
 348  
 349      $upgrades[] = new SQLUpgrade(
 350          '0.17-jf-36',
 351          'Remove zerofill on mantis_news_table.poster_id',
 352          "ALTER TABLE $t_news_table
 353              MODIFY poster_id int(7) unsigned zerofill NOT NULL" );
 354  
 355      $upgrades[] = new SQLUpgrade(
 356          '0.17-jf-37',
 357          'Remove zerofill on mantis_project_category_table.project_id',
 358          "ALTER TABLE $t_project_category_table
 359              MODIFY project_id int(7) unsigned NOT NULL" );
 360  
 361      $upgrades[] = new SQLUpgrade(
 362          '0.17-jf-38',
 363          'Remove zerofill on mantis_project_file_table.id',
 364          "ALTER TABLE $t_project_file_table
 365              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 366  
 367      $upgrades[] = new SQLUpgrade(
 368          '0.17-jf-39',
 369          'Remove zerofill on mantis_project_file_table.project_id',
 370          "ALTER TABLE $t_project_file_table
 371              MODIFY project_id int(7) unsigned NOT NULL" );
 372  
 373      $upgrades[] = new SQLUpgrade(
 374          '0.17-jf-40',
 375          'Remove zerofill on mantis_project_table.id',
 376          "ALTER TABLE $t_project_table
 377              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 378  
 379      $upgrades[] = new SQLUpgrade(
 380          '0.17-jf-41',
 381          'Remove zerofill on mantis_project_user_list_table.project_id',
 382          "ALTER TABLE $t_project_user_list_table
 383              MODIFY project_id int(7) unsigned NOT NULL" );
 384  
 385      $upgrades[] = new SQLUpgrade(
 386          '0.17-jf-42',
 387          'Remove zerofill on mantis_project_user_list_table.user_id',
 388          "ALTER TABLE $t_project_user_list_table
 389              MODIFY user_id int(7) unsigned NOT NULL" );
 390  
 391      $upgrades[] = new SQLUpgrade(
 392          '0.17-jf-43',
 393          'Remove zerofill on mantis_project_version_table.project_id',
 394          "ALTER TABLE $t_project_version_table
 395              MODIFY project_id int(7) unsigned NOT NULL" );
 396  
 397      $upgrades[] = new SQLUpgrade(
 398          '0.17-jf-44',
 399          'Remove zerofill on mantis_user_pref_table.id',
 400          "ALTER TABLE $t_user_pref_table
 401              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 402  
 403      $upgrades[] = new SQLUpgrade(
 404          '0.17-jf-45',
 405          'Remove zerofill on mantis_user_pref_table.user_id',
 406          "ALTER TABLE $t_user_pref_table
 407              MODIFY user_id int(7) unsigned NOT NULL" );
 408  
 409      $upgrades[] = new SQLUpgrade(
 410          '0.17-jf-46',
 411          'Remove zerofill on mantis_user_pref_table.project_id',
 412          "ALTER TABLE $t_user_pref_table
 413              MODIFY project_id int(7) unsigned NOT NULL default 0" );
 414  
 415      $upgrades[] = new SQLUpgrade(
 416          '0.17-jf-47',
 417          'Remove zerofill on mantis_user_pref_table.default_profile',
 418          "ALTER TABLE $t_user_pref_table
 419              MODIFY default_profile int(7) unsigned NOT NULL default 0" );
 420  
 421      $upgrades[] = new SQLUpgrade(
 422          '0.17-jf-48',
 423          'Remove zerofill on mantis_user_pref_table.default_project',
 424          "ALTER TABLE $t_user_pref_table
 425              MODIFY default_project int(7) unsigned NOT NULL default 0" );
 426  
 427      $upgrades[] = new SQLUpgrade(
 428          '0.17-jf-49',
 429          'Remove zerofill on mantis_user_print_pref_table.user_id',
 430          "ALTER TABLE $t_user_print_pref_table
 431              MODIFY user_id int(7) unsigned NOT NULL" );
 432  
 433      $upgrades[] = new SQLUpgrade(
 434          '0.17-jf-50',
 435          'Remove zerofill on mantis_user_profile_table.id',
 436          "ALTER TABLE $t_user_profile_table
 437              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 438  
 439      $upgrades[] = new SQLUpgrade(
 440          '0.17-jf-51',
 441          'Remove zerofill on mantis_user_profile_table.user_id',
 442          "ALTER TABLE $t_user_profile_table
 443              MODIFY user_id int(7) unsigned NOT NULL" );
 444  
 445      $upgrades[] = new SQLUpgrade(
 446          '0.17-jf-52',
 447          'Remove zerofill on mantis_user_table.id',
 448          "ALTER TABLE $t_user_table
 449              MODIFY id int(7) unsigned NOT NULL auto_increment" );
 450  
 451      # The following are all changes that were goofed somewhere between 0.13 and here
 452      # In some cases, changes were made in db_upgrade scripts but not applied to the
 453      #  database that was used to generate db_generate.  These upgrades all attempt to
 454      #  make sure that all users end up with identical databases from this point on,
 455      #  no matter what version they originally installed.
 456  
 457      $upgrades[] = new SQLUpgrade(
 458          '0.17-compat-1',
 459          'Set default for mantis_bug_file_table.date_added (incorrect for 0.15 installs)',
 460          "ALTER TABLE $t_bug_file_table
 461            MODIFY date_added datetime
 462            DEFAULT '1970-01-01 00:00:01'
 463            NOT NULL" );
 464  
 465      $upgrades[] = new SQLUpgrade(
 466          '0.17-compat-2',
 467          'Correct values for mantis_bug_file_table.date_added (incorrect for 0.15 installs)',
 468          "UPDATE $t_bug_file_table
 469            SET date_added='1970-01-01 00:00:01'
 470            WHERE date_added='0000-00-00 00:00:00'" );
 471  
 472      $upgrades[] = new SQLUpgrade(
 473          '0.17-compat-3',
 474          'Set default for mantis_project_file_table.date_added (incorrect for 0.15 installs)',
 475          "ALTER TABLE $t_project_file_table
 476            MODIFY date_added datetime
 477            DEFAULT '1970-01-01 00:00:01'
 478            NOT NULL" );
 479  
 480      $upgrades[] = new SQLUpgrade(
 481          '0.17-compat-4',
 482          'Correct values for mantis_project_file_table.date_added (incorrect for 0.15 installs)',
 483          "UPDATE $t_project_file_table
 484            SET date_added='1970-01-01 00:00:01'
 485            WHERE date_added='0000-00-00 00:00:00'" );
 486  
 487      $upgrades[] = new SQLUpgrade(
 488          '0.17-compat-5',
 489          'Set default for mantis_bug_table.build (incorrect for 0.16 installs)',
 490          "ALTER TABLE $t_bug_table
 491            MODIFY build varchar(32)
 492            DEFAULT ''
 493            NOT NULL" );
 494  
 495      $upgrades[] = new SQLUpgrade(
 496          '0.17-compat-6',
 497          'Correct values for mantis_bug_table.build (incorrect for 0.16 installs)',
 498          "UPDATE $t_bug_table
 499            SET build=''
 500            WHERE build='0'" );
 501  
 502      $upgrades[] = new SQLUpgrade(
 503          '0.17-compat-7',
 504          'Set default for mantis_user_table.date_created (incorrect for < 0.17 installs)',
 505          "ALTER TABLE $t_user_table
 506            MODIFY date_created datetime
 507            DEFAULT '1970-01-01 00:00:01'
 508            NOT NULL" );
 509  
 510      $upgrades[] = new SQLUpgrade(
 511          '0.17-compat-8',
 512          'Correct values for mantis_user_table.date_created (incorrect for < 0.17 installs)',
 513          "UPDATE $t_user_table
 514            SET date_created='1970-01-01 00:00:01'
 515            WHERE date_created='0000-00-00 00:00:00'" );
 516  
 517      $upgrades[] = new SQLUpgrade(
 518          '0.17-compat-9',
 519          'Set default for mantis_project_table.enabled to 1 (incorrect for < 0.17 installs)',
 520          "ALTER TABLE $t_project_table
 521            MODIFY enabled INT(1)
 522            NOT NULL
 523            DEFAULT '1'" );
 524  
 525      $upgrades[] = new SQLUpgrade(
 526          '0.17-compat-10',
 527          'Set default for mantis_news_table.date_posted (incorrect for < 0.17 installs)',
 528          "ALTER TABLE $t_news_table
 529            MODIFY date_posted datetime
 530            NOT NULL
 531            DEFAULT '1970-01-01 00:00:01'" );
 532  
 533      $upgrades[] = new SQLUpgrade(
 534          '0.17-compat-11',
 535          'Correct values for mantis_news_table.date_posted (incorrect for < 0.17 installs)',
 536          "UPDATE $t_news_table
 537            SET date_posted='1970-01-01 00:00:01'
 538            WHERE date_posted='0000-00-00 00:00:00'" );
 539  
 540      $upgrades[] = new SQLUpgrade(
 541          '0.17-compat-12',
 542          'Set default for mantis_bug_table.date_submitted (incorrect for < 0.17 installs)',
 543          "ALTER TABLE $t_bug_table
 544            MODIFY date_submitted datetime
 545            NOT NULL
 546            DEFAULT '1970-01-01 00:00:01'" );
 547  
 548      $upgrades[] = new SQLUpgrade(
 549          '0.17-compat-13',
 550          'Correct values for mantis_bug_table.date_submitted (incorrect for < 0.17 installs)',
 551          "UPDATE $t_bug_table
 552            SET date_submitted='1970-01-01 00:00:01'
 553            WHERE date_submitted='0000-00-00 00:00:00'" );
 554  
 555      $upgrades[] = new SQLUpgrade(
 556          '0.17-compat-14',
 557          'Set default for mantis_bugnote_table.date_submitted (incorrect for < 0.17 installs)',
 558          "ALTER TABLE $t_bugnote_table
 559            MODIFY date_submitted datetime
 560            NOT NULL
 561            DEFAULT '1970-01-01 00:00:01'" );
 562  
 563      $upgrades[] = new SQLUpgrade(
 564          '0.17-compat-15',
 565          'Correct values for mantis_bugnote_table.date_submitted (incorrect for < 0.17 installs)',
 566          "UPDATE $t_bugnote_table
 567            SET date_submitted='1970-01-01 00:00:01'
 568            WHERE date_submitted='0000-00-00 00:00:00'" );
 569  
 570      # This was added in db_upgrade.sql going from 0.14 to 0.15 but not
 571      # added to db_generate.sql.  This means that users who installed from
 572      # versions after 0.15 don't have it but those from before do.
 573      # Because of this, we need a function instead of an SQL statement so
 574      # that users from before upgrading with this will not get an error
 575      # about the key already existing.
 576      $upgrades[] = new FunctionUpgrade(
 577          '0.17-compat-16',
 578          'Add unique index to cookie_string if it is not already there (incorrect for > 0.14)',
 579          'upgrade_0_17_compat_16' );
 580  
 581  	function upgrade_0_17_compat_16() {
 582          global $t_user_table;
 583          $query = "DESCRIBE $t_user_table cookie_string";
 584  
 585          $result = db_query( $query );
 586  
 587          $t_row = db_fetch_array( $result );
 588  
 589          $t_key = isset( $t_row['Key'] ) ? $t_row['Key'] : $t_row['key'];
 590  
 591          if ( 'UNI' != $t_key ) {
 592              $query = "ALTER IGNORE TABLE $t_user_table
 593                          ADD UNIQUE cookie_string (cookie_string)";
 594  
 595              $result = @db_query( $query );
 596  
 597              if ( false == $result ) {
 598                  return false;
 599              }
 600          }
 601  
 602          return true;
 603      }
 604  
 605      $upgrades[] = new FunctionUpgrade(
 606          '0.17-compat-17',
 607          'Remove mantis_project_version_table.ver_order (incorrect for < 0.15)',
 608          'upgrade_0_17_compat_17' );
 609  
 610  	function upgrade_0_17_compat_17() {
 611          global $t_project_version_table;
 612          $query = "DESCRIBE $t_project_version_table";
 613  
 614          $result = db_query( $query );
 615  
 616          $count = db_num_rows( $result );
 617  
 618          for ( $i=0 ; $i < $count ; $i++ ) {
 619              $t_row = db_fetch_array( $result );
 620  
 621              $t_field = isset( $t_row['Field'] ) ? $t_row['Field'] : $t_row['field'];
 622              if ( $t_field == 'ver_order' ) {
 623                  $query = "ALTER TABLE $t_project_version_table
 624                              DROP ver_order";
 625  
 626                  $result = @db_query( $query );
 627  
 628                  if ( false == $result ) {
 629                      return false;
 630                  }
 631  
 632                  break;
 633              }
 634          }
 635  
 636          return true;
 637      }
 638  
 639      $upgrades[] = new SQLUpgrade(
 640          '0.17-compat-18',
 641          'Remove users from project 0',
 642          "DELETE FROM $t_project_user_list_table
 643            WHERE project_id=0" );
 644  
 645      $upgrades[] = new FunctionUpgrade(
 646          '0.17-vb-19',
 647          'Add id field to bug history table',
 648          'upgrade_0_17_vb_19' );
 649  
 650  	function upgrade_0_17_vb_19() {
 651          global $t_bug_history_table;
 652  
 653          if ( !db_field_exists( 'id', $t_bug_history_table ) ) {
 654              $query = "ALTER TABLE $t_bug_history_table ADD id INT(7) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
 655  
 656              $result = @db_query( $query );
 657  
 658              if ( false == $result ) {
 659                  return false;
 660              }
 661          }
 662  
 663          return true;
 664      }
 665  
 666      return $upgrades;
 667  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics