root/dev/common/autoupgrade.php @ 123

Revision 123, 5.0 KB (checked in by exi, 14 years ago)

Admin: admin_mapoptions.php now deletes all regioncache images on submit of new values.
SQL: default inxed for kb3_ships_values.shp_id is now primary key.
Killlists should now properly show the old date format.
Fixed a typo in admin_mapoptions.tpl.
Added debug code to class.map.php.
The killmail importer should now work also with 1 killmail per request.

Line 
1<?php
2require_once("db.php");
3function check_commenttable()
4{
5    $qry = new DBQuery();
6    $query = 'select count(*) from kb3_comments';
7    $result = mysql_query($query);
8    if ($result)
9    {
10        check_commenttablerow();
11        return;
12    }
13    $query = 'CREATE TABLE `kb3_comments` (
14`ID` INT NOT NULL AUTO_INCREMENT ,
15`kll_id` INT NOT NULL ,
16`comment` TEXT NOT NULL ,
17`name` TINYTEXT NOT NULL ,
18`posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL,
19PRIMARY KEY ( `ID` )
20) TYPE = MYISAM';
21    $qry->execute($query);
22}
23
24function check_commenttablerow()
25{
26    $qry = new DBQuery();
27    $query = 'select posttime from kb3_comments limit 1';
28    $result = mysql_query($query);
29    if ($result)
30    {
31        $query = 'ALTER TABLE `kb3_comments` CHANGE `ID` `id` INT( 11 ) NOT NULL AUTO_INCREMENT';
32        $qry->execute($query);
33        return;
34    }
35    $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL';
36    $qry->execute($query);
37}
38
39function check_shipvaltable()
40{
41    $qry = new DBQuery();
42    $query = 'select count(*) from kb3_ships_values';
43    $result = mysql_query($query);
44    if ($result)
45    {
46        return;
47    }
48    $query = 'CREATE TABLE `kb3_ships_values` (
49`shp_id` INT( 11 ) NOT NULL ,
50`shp_value` BIGINT( 4 ) NOT NULL ,
51PRIMARY KEY ( `shp_id` )
52) TYPE = MYISAM ;';
53    $qry->execute($query);
54    $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=257 limit 1');
55    $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=252 limit 1');
56    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=266 limit 1');
57    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=275 limit 1');
58    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=272 limit 1');
59    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=246 limit 1');
60    $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=249 limit 1');
61    $qry->execute('UPDATE kb3_ships set shp_techlevel = 2 where shp_class = 22');
62}
63
64function check_invdetail()
65{
66    $qry = new DBQuery();
67    $query = 'select ind_sec_status from kb3_inv_detail limit 1';
68    $qry->execute($query);
69    $len = mysql_field_len($qry->resid_,0);
70    if ($len == 4)
71    {
72        $query = 'ALTER TABLE `kb3_inv_detail` CHANGE `ind_sec_status` `ind_sec_status` VARCHAR(5)';
73        $qry->execute($query);
74    }
75}
76
77function check_pilots()
78{
79    $qry = new DBQuery();
80    $query = 'select plt_name from kb3_pilots limit 1';
81    $qry->execute($query);
82    $len = mysql_field_len($qry->resid_,0);
83    if ($len == 32)
84    {
85        $query = 'ALTER TABLE `kb3_pilots` CHANGE `plt_name` `plt_name` VARCHAR(64) NOT NULL';
86        $qry->execute($query);
87    }
88}
89
90function check_contracts()
91{
92    $qry = new DBQuery();
93    $query = 'select ctd_sys_id from kb3_contract_details limit 1';
94    $result = mysql_query($query);
95    if ($result)
96    {
97        return;
98    }
99    $qry->execute('ALTER TABLE `kb3_contract_details` ADD `ctd_sys_id` INT(11) NOT NULL DEFAULT \'0\'');
100
101    $qry->execute('SHOW columns from `kb3_contract_details` like \'ctd_ctr_id\'');
102    $arr = $qry->getRow();
103    if ($arr['Key'] == 'PRI')
104    {
105        return;
106    }
107    $qry->execute('ALTER TABLE `kb3_contract_details` ADD INDEX (`ctd_ctr_id`) ');
108}
109function check_index()
110{
111    $qry = new DBQuery();
112    $qry->execute('SHOW columns from kb3_item_types like \'itt_id\'');
113    $arr = $qry->getRow();
114    if ($arr['Key'] == 'PRI')
115    {
116        return;
117    }
118    $qry->execute('ALTER TABLE `kb3_item_types` ADD PRIMARY KEY ( `itt_id` ) ');
119}
120function check_tblstrct1()
121{
122    $qry = new DBQuery();
123    $query = 'select shp_description from kb3_ships limit 1';
124    $result = mysql_query($query);
125    if (!$result)
126    {
127        return;
128    }
129    $query = 'ALTER TABLE `kb3_ships` DROP `shp_description`';
130    $qry->execute($query);
131}
132function check_tblstrct2()
133{
134    $qry = new DBQuery();
135    $query = 'select itm_description from kb3_items limit 1';
136    $result = mysql_query($query);
137    if (!$result)
138    {
139        return;
140    }
141    $query = 'ALTER TABLE `kb3_items` DROP `itm_description`';
142    $qry->execute($query);
143}
144function check_tblstrct3()
145{
146    $qry = new DBQuery();
147    $query = 'select Value from kb3_items limit 1';
148    $result = mysql_query($query);
149    if ($result)
150    {
151        $query = 'ALTER TABLE `kb3_items` CHANGE `Value` `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\'';
152        $qry->execute($query);
153    }
154}
155function check_tblstrct4()
156{
157    $qry = new DBQuery();
158    $query = 'select itm_value from kb3_items limit 1';
159    $result = mysql_query($query);
160    if ($result)
161    {
162        return;
163    }
164    $query = 'ALTER TABLE `kb3_items` ADD `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\'';
165    $qry->execute($query);
166    $qry->execute('ALTER TABLE `kb3_items` CHANGE `itm_externalid` `itm_externalid` INT( 11 ) NOT NULL DEFAULT \'0\'');
167}
168?>
Note: See TracBrowser for help on using the browser.