/
dbup.php
151 lines (128 loc) · 6.97 KB
/
dbup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<html>
<body>
<?php
require 'authorisation.php';
$link = db_connect();
$key = 0;
$result = mysql_query("select svKey from schema_version");
if (mysql_num_rows($result) > 0)
{
$key = mysql_result($result,0);
}
$altarr = [];
$altarr[0] = [
# "alter table tblCompetition add column comEntryRestrict enum ('open', 'registered') default 'open'",
# "alter table tblCompetition add column comLocked integer default 0",
# "alter table tblFormula modify column forClass enum ('gap', 'ozgap', 'pwc', 'sahpa', 'nzl', 'ggap', 'nogap')",
# "alter table tblTrack add index indTrack (traPk)",
# "alter table tblTask modify column tasTaskType enum ('free', 'speedrun', 'race', 'olc', 'free-bearing', 'speedrun-interval', 'airgain', 'aat')",
# "alter table tblShortestRoute add column ssrCumulativeDist double default 0.0",
# "alter table tblGlider add column gliClass enum('PG', 'HG') default 'PG'",
# "alter table tblTrack modify column traDHV enum('1','1/2','2','2/3','competition','floater','kingpost','open','rigid') default 'competition'",
# "alter table tblTrack add index indPilot (pilPk)",
# "alter table tblWaypoint add index indTraTime (traPk,wptTime)",
"alter table tblUserSession modify column useSessTime timestamp default CURRENT_TIMESTAMP",
"alter table tblUserSession modify column useLastTime timestamp",
"alter table tblAirspaceWaypoint add column awpAngleStart float",
"alter table tblAirspaceWaypoint add column awpAngleEnd float",
"alter table tblAirspaceWaypoint add column awpRadius float",
"alter table tblRegistration add column gliPk integer",
];
$altarr[1] = [
'alter table tblFormula add column forStoppedGlideBonus double default 0.0',
'alter table tblFormula add column forHeightArrBonus double default 0.0',
'alter table tblFormula add column forHeightArrLower integer default 200',
'alter table tblFormula add column forHeightArrUpper integer default 3000',
'alter table tblRegistration add column regHours integer default 200',
];
$altarr[2] = [
'create table tblAirspaceRegion ( argPk integer not null primary key auto_increment, argRegion varchar(32) not null, argLatDecimal double not null, argLongDecimal double not null, argSize integer not null)',
'alter table tblAirspace modify column airClass enum ( "G", "C", "D", "E", "X", "R", "P", "Q", "W", "GP", "CTR" ) default "C"',
];
$altarr[3] = [
'alter table tblFormula add column forOLCPoints integer default 3',
'alter table tblFormula add column forOLCBase double default 1.4'
];
$altarr[4] = [
'alter table tblTask add column tasComment text'
];
$altarr[5] = [
'alter table tblFormula add column forDistMeasure enum ( "average", "median" ) default "average"',
'alter table tblFormula add column forWeightStart double default 0.125',
'alter table tblFormula add column forWeightArrival double default 0.175',
'alter table tblFormula add column forWeightSpeed double default 0.7',
"update tblFormula set forWeightStart=.125 , forWeightArrival=.125, forWeightSpeed=0.75 where forVersion='1998' and forClass='gap'",
"update tblFormula set forWeightStart=.25 , forWeightArrival=.25, forWeightSpeed=0.50 where forVersion='2000' and forClass='ozgap'",
"update tblFormula set forWeightStart=0 , forWeightArrival=.25, forWeightSpeed=0.75 where forVersion='2005' and forClass='ozgap'",
"update tblFormula set forWeightStart=.175 , forWeightArrival=.25, forWeightSpeed=0.575 where forVersion not in ('2000','2005') and forClass='ozgap'",
"update tblFormula set forWeightStart=0.0 , forWeightArrival=0.0, forWeightSpeed=1.0 where forClass in ('nzl', 'jtgap', 'rtgap', 'nogap')"
];
mysql_query('delete from schema_version');
mysql_query("insert into schema_version (svKey, svExtra) values (5, 'dbup')");
for ($i = $key; $i < length($altarr); $i++)
{
foreach ($altarr[$i] as $row)
{
$result = mysql_query($row) or die('Alter failed: ' . mysql_error());
}
}
if ($key < 1)
{
$query = "create table schema_version
(
svKey varchar(32) not null primary key,
svWhen timestamp not null default CURRENT_TIMESTAMP,
svExtra varchar(256)
)";
$result = mysql_query($query) or die('Schema failed: ' . mysql_error());
}
if ($key < 5)
{
$query = "create table tblLaunchSite (
lauPk integer not null primary key auto_increment,
lauLaunch varchar(32) not null,
lauRegion varchar(32) not null,
lauLatDecimal double not null,
lauLongDecimal double not null,
lauAltitude double not null
)";
$result = mysql_query($query) or die('LaunchSite failed: ' . mysql_error());
$query = "insert into tblLaunchSite (lauLaunch, lauRegion, lauLatDecimal, lauLongDecimal, lauAltitude) values
('Chelan', 'USA',47.8061,-120.041683333333,1200),
('Tiger Mtn', 'USA', 47.50145, -121.988533333333, 800),
('Woodrat', 'USA', 42.2314666666667, -123.003816666667, 1200),
('Blackheath', 'NSW', -33.64365, 150.244516666667, 1000),
('Balmoral', 'Queensland', -26.7583333333333, 152.8924, 420),
('Middle Brother', 'NSW', -31.7032666666667,152.681133333333, 450),
('Killarney', 'Queensland', -28.2948166666667, 152.34165, 940),
('Toowoomba', 'Queensland', -27.4599833333333, 151.8462, 600),
('Veslea', 'Norway', 59.6192333333333, 8.69566666666667, 620),
('Laragne', 'France', 44.2968333333333, 5.76273333333333, 1320),
('St Vincent Les Forts', 'France', 44.447116666666, 6.37201666666667, 1200),
('Manteigas', 'Portugal', 40.4026166666667,-7.45433333333333, 800),
('Ager', 'Spain', 42.0459833333333 ,0.745933333333333, 1530),
('Valle de Bravo', 'Mexico', 19.0616, -100.090116666667, 2340),
('Bayramoren', 'Turkey', 40.9710333333333,33.2099, 1280),
('Bir', 'India', 32.0598166666667,76.7444333333333, 2400),
('Piedrahita', 'Spain', 40.4220333333333, -5.30106666666667, 1900),
('Ivanhoe', 'NSW', -32.883,144.3111, 100),
('Stanwell Park', 'NSW', -34.2233833333333, 150.99925, 140),
('Paeroa', 'New Zealand', -38.37825,176.255166666667, 800),
('Nelson', 'New Zealand',-41.3435833333333,173.250316666667,500),
('Wanaka', 'New Zealand',-44.7732,169.384433333333,1000),
('Mystic','Victoria',-36.7578811646,146.965393066,800),
('Beechmont','Queensland',-28.118194,153.201639,530),
('Mt Broughton','Victoria',-37.1230963549893,145.413665771484,650),
('Conargo', 'Victoria', -35.318,145.170, 100),
('Manilla','NSW',-30.6766853333,150.610824585,860),
('Mt Lonarch', 'Victoria',-37.2584833333333,143.3397,600),
('Mt Elliot','Victoria',-36.186035,147.974553,940),
('Annecy','France',45.81405,6.24851666666667,900),
('Mt Tamborine','Queensland',-27.950278,153.181194,548),
('Pedro Bernardo', 'Spain', 40.2564333333333,-4.90571666666667,1200)";
$result = mysql_query($query) or die('insert launch failed: ' . mysql_error());
}
echo "<h1>Updated DB to verion: $key</h1>";
?>
</body>
</html>