annotate managedb.php @ 551:bed441ced78e

Improve migration and upgrade procedures.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 16 Dec 2013 01:42:48 +0200
parents e5732b25c839
children 14078b65641c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #!/usr/bin/php
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 <?
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
3 require_once "mconfig.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
4 require_once "msite.inc.php";
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
479
86ee2b42a995 Move CLI helper functions to msitegen, again.
Matti Hamalainen <ccr@tnsp.org>
parents: 426
diff changeset
6 stCheckCLIExec();
50
184a4188555c Move CLI helper functions to createdb.php, as they are now only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 47
diff changeset
7
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
8 $dbVersion = 12;
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
9 $currVersion = -1;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
10
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
11 $dbMeta = array(
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
12 "dbVersion" => array(VT_INT, $dbVersion, "Database version"),
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
13 );
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
14
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
16 //
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
17 // Site settings and defaults we put in
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
18 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 $siteDefaults = array(
268
feed47a72df4 Update some setting descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
20 "maxAttendeesHard" => array(VT_INT, 60, "Maximum attendees (HARD limit, <= 0 means no limit)"),
feed47a72df4 Update some setting descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
21 "maxAttendeesSoft" => array(VT_INT, 50, "Maximum attendees (soft limit, <= 0 means no limit)"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
158
96aae4beb558 Clean up some references to entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 150
diff changeset
23 "userTimeout" => array(VT_INT, 120, "User pages (voting) timeout in minutes"),
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
24 "admTimeout" => array(VT_INT, 15, "Administration interface timeout in minutes"),
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
25
62
101cde58b267 Add a new setting for ASCII vs. HTML table output for compo results.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
26 "showAdmin" => array(VT_BOOL, false, "Always show administration interface link on the menu"),
119
99e7569c9f4f Change the default of some boolean settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
27 "showAttendees" => array(VT_BOOL, true, "Show attendees list"),
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
28 "allowRegister" => array(VT_BOOL, false, "Enable event registration"),
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
29 "allowVoting" => array(VT_BOOL, false, "Enable voting (individual compos must be enabled as well)"),
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
30
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
31 "showResults" => array(VT_BOOL, false, "Enable results page"),
119
99e7569c9f4f Change the default of some boolean settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
32 "showResAuthors" => array(VT_BOOL, true, "Show entry authors on results page"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
34 "requireEMail" => array(VT_BOOL, false, "Require e-mail address in registrations"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
35
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
36 "showNews" => array(VT_BOOL, true, "Enable News link on main menu"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
37 "showNewsOnAbout" => array(VT_BOOL, true, "Show latest news item on About page"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
38
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
39 "registerInfoText" => array(VT_TEXT, "<p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
40 Only your <b>handle</b> and the answer to the botcheck are strictly required.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
41 If you plan on joining the IRC channel
63
922b5192b2ff Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
42 (<a href=\"irc://#fap2013@ircnet\">#fap2013 @ IRCNet</a>) or staying up to date by other means,
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
43 <b>e-mail</b> is not required either.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
44 </p>", "Registration page info text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
45
182
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
46 "registerPostText" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
47 <h1>Registration successful</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
48 <p>Now go make a demo about it!</p>",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
49 "Successful post-registration note text"),
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
50
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
51 "registerLimitExceeded" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
52 <h1>Sorry, registration disabled!</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
53 <p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
54 Registration to the event is not available at this time due to
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
55 number of attendees limit having been reached. <b>:(</b>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
56 </p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
57 ",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
58 "Registration attendee limit exceeded note text"),
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
59
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
60 "registerNotEnabled" => array(VT_TEXT, "
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
61 <h1>Sorry, registration disabled!</h1>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
62 <p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
63 Registration to the event is not enabled at this time.
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
64 </p>
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
65 ",
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
66 "Registration not enabled note text"),
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
67
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
68 "registerPostNoEmail" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
69 <h2>By the way ...</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
70 <p>As you did not specify an e-mail contact address, you'll have to get updates
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
71 and information about the location (if you don't already know it) by
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
72 some other means (IRC, for example.)</p>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
73 ", "No e-mail address registration note"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
74
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
75 "eventDescription" => array(VT_TEXT, "
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
76 <h1>Event program &amp; schedule</h1>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
77 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
78 <li><b>Aegis</b> of DSS and FAG will be performing a DJ gig.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
79 <li>.. and possible additional live acts. More info to come.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
80 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
81
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
82 <h2>Friday 30.11.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
83 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
84 <li><b>18:00</b> - <i>Doors open</i>.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
85 <li><b>22:00</b> - DJ set by Aegis.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
86 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
87
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
88 <h2>Saturday 1.12.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
89 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
90 <li><b>14:00</b> - Deadline for remote entries.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
91 <li><b>18:00</b> - Deadline for the entries delivered on location.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
92 <li><b>20:00</b> - Competitions start.</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
93 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
94
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
95 Competition schedule and voting deadline will depend on number of entries.
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
96
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
97 <h2>Sunday 2.12.</h2>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
98 <ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
99 <li><b>12:00</b> - Party over?</li>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
100 </ul>
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
101 ", "Event general description / timetables etc."),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
102
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
103
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
104 "compoDescription" => array(VT_TEXT, "
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
105 <h1>General</h1>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
106 <p class=\"notice\">
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
107 YOU <b>MUST</b> HAVE AT LEAST ONE ENTRY TO COMPETITIONS IF YOU COME TO THE PARTY.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
108 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
109
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
110 <p class=\"note\">
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
111 If there are enough entries, then AGA/OCS/ECS demos will be run in separate compos.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
112 <br />
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
113 Remote entries are welcome!
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
114 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
115
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
116 <p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
117 The compo machine will be an <b>A1200 with an 060/50 and lots of
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
118 RAM</b>. An <b>A500 1.3 512k/512k</b> will also be available if your
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
119 prod is not AGA compatible.
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
120 </p>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
121
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
122 <h1>Compos</h1>
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 11
diff changeset
123 ", "Compo general description"),
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
124
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
125
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
126 "siteInfoText" => array(VT_TEXT, "
150
4b91002a9900 Fix default header image link.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
127 <a href=\"about\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
128 <img src=\"img/fapsm.png\" alt=\"Finnish Amiga Party 2013\" class=\"logo\" /></a>
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
129 <div id=\"date\">
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
130 5.-8.12.2013<br />
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
131 Helsinki, Finland<br />
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
132 @ old location<br />
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
133 <span class=\"notice\">Entry 15 EUR + prod</span>
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
134 </div>", "Site header text"),
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
135
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
136
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
137 "newsHeader" => array(VT_TEXT, "", "News page header text"),
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
138
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
139
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
140 "aboutDescription" => array(VT_TEXT, "
9
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
141 <div style=\"text-align: center;\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
142 <img src=\"img/fap.png\" alt=\"FAP\" />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
143 <p>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
144 Pure Amiga demoscene party, all traditional Amiga compos and purely Amiga-oriented program.
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
145 <br />
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
146 <span class=\"notice\">
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
147 YOU <b>MUST</b> HAVE AT LEAST ONE ENTRY TO COMPETITIONS IF YOU COME TO THE PARTY.
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
148 </span>
fa9b66f596bb More work on settings storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
149 </p>
11
c10bf196390f Improve database initialization script.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
150 </div>",
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 120
diff changeset
151 "About page text"),
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
152
224
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
153 "voteFinishedText" => array(VT_TEXT, "
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
154 <h1>Yay, you have voted!</h1>
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
155 <p>Now go FAP some more! And make a demo about it.</p>",
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
156 "Message shown after successful voting."),
0daedbef5678 Add informational text setting for "voted" situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 220
diff changeset
157
104
c7b1eb993240 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
158 "siteMenuHeader" => array(VT_TEXT, "<div>13.FAP:&gt; <span class=\"mblink\">&#9632;</span></div>", "Site menu header text"),
47
73123e322133 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
159 "siteMenuFooter" => array(VT_TEXT, "", "Site menu footer text"),
106
324f3a415237 Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 104
diff changeset
160 "siteExtraHTML" => array(VT_TEXT, "<div id=\"sponsors\">Gentle Eye</div>", "Extra global HTML code (f.e. sponsors box)"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
163
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
164 //
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
165 // Database table definitions
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
166 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 $sqlTables = array(
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
168 // Database metadata
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
169 "dbmeta" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
170 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
171 array("vtype" , "INT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
172 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
173 array("vtext" , "TEXT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
174 array("vint" , "INT"),
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
175 array("sdesc" , "VARCHAR(128)"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
176 ),
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
177
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
178 // Site settings
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
179 "settings" => array(
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
180 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
181 array("vtype" , "INT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
182 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
183 array("vtext" , "TEXT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
184 array("vint" , "INT"),
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
185 array("sdesc" , "VARCHAR(128)"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
186 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
187
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
188 "news" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
189 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
190 array("utime" , "INT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
191 array("title" , "VARCHAR(".SET_LEN_NEWS_TITLE.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
192 array("text" , "VARCHAR(".SET_LEN_NEWS_TEXT.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
193 array("author" , "VARCHAR(".SET_LEN_NEWS_AUTHOR.")"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
194 array("persist" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
195 ),
73
c70c2650f790 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
196
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
197 "compos" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
198 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
199 array("name" , "VARCHAR(".SET_LEN_COMPO_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
200 array("description" , "VARCHAR(".SET_LEN_COMPO_DESC.")"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
201 array("visible" , "INT", "DEFAULT 0"),
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
202 array("voting" , "INT", "DEFAULT 0"),
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
203 array("show_authors" , "INT", "DEFAULT 0"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
204 array("type" , "INT", "DEFAULT 0"),
533
f872843ae396 Add file path to compo data.
Matti Hamalainen <ccr@tnsp.org>
parents: 529
diff changeset
205 array("path" , "VARCHAR(".SET_LEN_COMPO_PATH.")"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
206 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
207
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
208 "entries" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
209 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
210 array("show_id" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
211 array("name" , "VARCHAR(".SET_LEN_ENTRY_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
212 array("author" , "VARCHAR(".SET_LEN_ENTRY_AUTHOR.")"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
213 array("compo_id" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
214 array("filename" , "VARCHAR(".SET_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
215 array("info" , "VARCHAR(".SET_LEN_ENTRY_INFO.")", "DEFAULT NULL"),
527
d6726a4883a6 Add "notes" field for entries, to contain notes private to organizers.
Matti Hamalainen <ccr@tnsp.org>
parents: 525
diff changeset
216 array("notes" , "VARCHAR(".SET_LEN_ENTRY_NOTES.")", "DEFAULT NULL"),
528
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
217 array("preview_file" , "VARCHAR(".SET_LEN_ENTRY_PREVIEW_FILE.")", "DEFAULT NULL"),
dd5c5577c495 Add preview file and file type fields for entry, for screenshots etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 527
diff changeset
218 array("preview_type" , "INT", "DEFAULT 0"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
219 array("flags" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
220 ),
73
c70c2650f790 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
221
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
222 "attendees" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
223 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
224 array("regtime" , "INT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
225 array("name" , "VARCHAR(".SET_LEN_USERNAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
226 array("groups" , "VARCHAR(".SET_LEN_GROUPS.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
227 array("oneliner" , "VARCHAR(".SET_LEN_ONELINER.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
228 array("email" , "VARCHAR(".SET_LEN_EMAIL.")"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
229 array("key_id" , "INT", "DEFAULT NULL"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
230 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
231
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
232 "votekeys" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
233 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
234 array("key" , "VARCHAR(".SET_LEN_VOTEKEY.")"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
235 array("active" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
236 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
237
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
238 "votes" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
239 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
240 array("entry_id" , "INT", "DEFAULT NULL"),
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
241 array("key_id" , "INT", "DEFAULT 0"),
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
242 array("value" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
243 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
244
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
245
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
246 // Party information system tables
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
247 "display_vars" => array(
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
248 array("key" , "VARCHAR(32)", "PRIMARY KEY"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
249 array("vtype" , "INT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
250 array("vstr" , "VARCHAR(128)"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
251 array("vtext" , "TEXT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
252 array("vint" , "INT"),
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
253 array("sdesc" , "VARCHAR(128)"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
254 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
255
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
256 "display_slides" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
257 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
258 array("title" , "VARCHAR(".SET_LEN_DISP_SLIDE_TITLE.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
259 array("text" , "VARCHAR(".SET_LEN_DISP_SLIDE_TEXT.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
260 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
261
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
262 "rot_list_data" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
263 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
264 array("name" , "VARCHAR(".SET_LEN_ROT_LIST_NAME.")"),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
265 ),
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
266
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
267 "rot_list_slides" => array(
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
268 array("id" , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"),
505
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
269 array("list_id" , "INT", "DEFAULT 0"),
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
270 array("slide_id" , "INT", "DEFAULT 0"),
f66aa0cdb666 Rename some SQL table schema types (s/INTEGER/INT/)
Matti Hamalainen <ccr@tnsp.org>
parents: 504
diff changeset
271 array("order_num" , "INT", "DEFAULT 0"),
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
272 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
273 );
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
274
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
275
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
276 //
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
277 // Party information system settings / data
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
278 //
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
279 $siteDisplayVars = array(
148
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
280 "showMode" => array(VT_INT, 0, "Currently active display mode"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
281 "rotateDuration" => array(VT_INT, 15, "Slide rotation time per slide (seconds)"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
282
393
14cdbeb331b6 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 355
diff changeset
283 "tempDuration" => array(VT_INT, 5, "Temporary slide display time (minutes)"),
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
284 "tempSlide" => array(VT_INT, 0, "Temporary slide ID"),
148
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
285
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
286 "compoID" => array(VT_INT, 0, "Compo ID of current compo"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
287 "compoPrevEntry" => array(VT_INT, 0, "Previously shown compo entry"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
288 "compoCurrEntry" => array(VT_INT, 0, "Current / next compo entry to be shown"),
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
289
6d4325451570 And some more work on the info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
290 // Not user-manageable
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
291 "tempSlideSet" => array(VT_BOOL, false, "Temporary slide set"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
292
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
293 "activeSlideMode" => array(VT_INT, 0, "Current active slide display mode"),
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
294 "activeSlide" => array(VT_INT, 0, "Current active slide"),
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
295 "activeSlideExpire" => array(VT_INT, 0, "Expiration timestamp of current slide"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
296
142
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
297 "rotateList" => array(VT_INT, 0, "Current rotation list ID"),
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
298 "rotateListIndex" => array(VT_INT, 0, "Current index in rotation list"),
145
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
299
66b485431cac Change how slides are updated.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
300 "lastUpdate" => array(VT_INT, 0, "Timestamp of last slide update"),
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 );
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
303
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
304 //
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
305 // Some premade test data
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
306 //
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
307 $siteTestData = array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
308 "news" => array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
309 "utime,title,text,author",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
310 time().",%s,%s,%s",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
311 array("Today's news", "We. Are. Back.", "orgaz"),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
312 array("Good news, everybody!", "...", "The Professor"),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
313 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
314
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
315 "votekeys" => array(
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
316 "key",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
317 "%s",
120
2c594958050e Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
318 array("test1"),
2c594958050e Make test vote keys "testN" where N >= 1
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
319 array("test2"),
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
320 array("7jjnqt5z"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
321 array("c7jcfk1G"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
322 ),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
323
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
324 "attendees" => array(
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
325 "regtime,name,groups,oneliner,email",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
326 "%d,%s,%s,%s,%s",
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
327 array(time()-0, "man with no alias", "supergroup", "foo-bar", "c@supergroup.com"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
328 array(time()-15, "man with alias", "supergroup", "hi!", "c@supergroup.com"),
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
329 array(time()-30, "alias with a man", "supergroup", "mega super kewl rulets", "x@microsoft.com"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
330 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
331
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
332 "compos" => array(
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
333 "name,description,visible,voting",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
334 "%s,%s,1,1",
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
335 array("Graphics", "Anything in standard resolutions."),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
336 array("Protracker music", "Standard 4-channel Protracker MOD music."),
170
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
337 array("4k intro", "4k intro competition"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
338 ),
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
339
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
340 "entries" => array(
170
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
341 "name,author,compo_id,filename,info",
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
342 "%s,%s,%d,%s,%s",
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
343 array("Donkey Dong", "electric/extend", 1, "donkey.lbm", "amigaaaah!"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
344 array("Your kondom", "ccr/TNSP", 1, "kondom.lbm", "oh my god, it's full of cocks!"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
345 array("Penis song", "reed/flt", 2, "penis.mod", "laulu rakkaudelle"),
dffededcdd92 Add info field to entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 158
diff changeset
346 array("jenkka", "aegis", 2, "jenkka.mod", ""),
220
db433a1d22b4 Fix test data creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
347 array("Fungiform 2", "mfx", 3, "mfx-fungiform2.lzh", "OCS-only"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
348 ),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
349
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
350 "display_slides" => array(
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
351 "title,text",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
352 "%s,%s",
414
Matti Hamalainen <ccr@tnsp.org>
parents: 394
diff changeset
353 array("Next Up 4k", "<h1>Next up: 4k intro</h1><h2>4k intro compo is about to begin</h2>... in about 10 minutes."),
142
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
354 array("Astu to infodesk", "<b>Astu</b> - please come to info desk!"),
d2e9285b69ad More work on the party info system.
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
355 array("Gentle Eye mainos", "<b>Buy Amiga stuff!</b><br />Gentle Eye Oy is selling Amiga-related stuff near organizer desk!"),
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
356 ),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
357
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
358 "rot_list_data" => array(
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
359 "name",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
360 "%s",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
361 array("Main rotation"),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
362 array("Next Up"),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
363 ),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
364
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
365 "rot_list_slides" => array(
140
20ca8edfb01a Rename some settings and variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 139
diff changeset
366 "list_id,slide_id",
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
367 "%d,%d",
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
368 array(1,2),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
369 array(1,3),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
370 array(2,1),
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
371 ),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
372 );
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
88
784953d60ba5 More work on test data generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 85
diff changeset
374
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 //
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
376 // Helper functions
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 //
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
378 function stGetTableSchema($dbh, $data)
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
379 {
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
380 $res = array();
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
381 $driver = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
382
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
383 foreach ($data as $col)
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
384 {
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
385 $tmp = array();
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
386
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
387 switch ($driver)
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
388 {
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
389 case "pgsql":
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
390 foreach ($col as $elem)
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
391 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
392 // For Postgres, use SERIAL for autoincrement
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
393 if ($elem == "AUTOINCREMENT")
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
394 $tmp[1] = "SERIAL";
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
395 else
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
396 $tmp[] = $elem;
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
397 }
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
398 break;
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
399
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
400 case "mysql":
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
401 foreach ($col as $elem)
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
402 {
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
403 if ($elem != "AUTOINCREMENT")
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
404 $tmp[] = "AUTO_INCREMENT";
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
405 else
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
406 $tmp[] = $elem;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
407 }
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
408 break;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
409
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
410 case "sqlite":
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
411 $tmp = $col;
518
af2f39a1dd79 Oops, had a missing semicolon ..
Matti Hamalainen <ccr@tnsp.org>
parents: 517
diff changeset
412 break;
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
413
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
414 default:
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
415 die("Don't know how to handle PDO driver '".$driver."' yet.\n");
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
416 }
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
417
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
418 $res[] = implode(" ", $tmp);
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
419 }
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
420
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
421 return implode(", ", $res);
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
422 }
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
423
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
424
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
425 function stCreateOneTable($dbh, $name, $schema)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
426 {
549
e5732b25c839 Comment out a debug print.
Matti Hamalainen <ccr@tnsp.org>
parents: 542
diff changeset
427 // echo "CREATE TABLE ".$name ." (".$schema.")\n";
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
428 return (stDBExecSQL($dbh, "CREATE TABLE ".$name." (".$schema.")") !== FALSE) ? TRUE : FALSE;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
429 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
430
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
431
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
432 function stCreateTables($dbh, $upgrade)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434 global $sqlTables;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 echo "Creating tables...\n";
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
436 foreach ($sqlTables as $name => $schemaData)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 echo " - '".$name."'\n";
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
439 stDBExecSQL($dbh, "DROP TABLE IF EXISTS ".$name);
517
fcfd8e28a083 Start making database migration to PostgreSQL work.
Matti Hamalainen <ccr@tnsp.org>
parents: 516
diff changeset
440 if (!stCreateOneTable($dbh, $name, stGetTableSchema($dbh, $schemaData)) && !$upgrade)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 return FALSE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 return TRUE;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
447 $upgradeMappings = array(
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
448 // "" => array("key" => "", value => ""),
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
449 12 => array(
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
450 "show_authors" => array("key" => "showAuthors"),
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
451 "display_vars" => array("table" => "displayVars"),
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
452 "display_slides" => array("table" => "displaySlides"),
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
453 "rot_list_data" => array("table" => "rotationListData"),
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
454 "rot_list_slides" => array("table" => "rotationListSlides"),
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
455 ),
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
456 );
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
457
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
458
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
459 function stUpgradeMap($type, $name)
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
460 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
461 global $upgradeMappings, $currVersion, $dbVersion;
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
462
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
463 $converted = FALSE;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
464 $tmpName = $name;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
465
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
466 for ($ver = $currVersion; $ver <= $dbVersion; $ver++)
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
467 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
468 if (isset($upgradeMappings[$ver]) &&
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
469 isset($upgradeMappings[$ver][$tmpName]) &&
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
470 isset($upgradeMappings[$ver][$tmpName][$type]))
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
471 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
472 $tmpName = $upgradeMappings[$ver][$tmpName][$type];
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
473 $converted = TRUE;
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
474 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
475 }
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
476
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
477 if ($converted)
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
478 return $tmpName;
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
479 else
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
480 switch ($type)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
481 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
482 case "table": return $name;
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
483 case "key": return $name;
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
484 default: die("Invalid upgrade type '".$type."'.\n");
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
485 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
486 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
487
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
488
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
489 function stAddSettings($inDB, $outDB, $settings, $table, $upgrade)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490 {
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
491 echo ($upgrade ? "Adding settings to" : "Upgrading settings in")." '".$table."' table.";
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
492
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
493 $status = TRUE;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
494 stDBExecSQL($outDB, "BEGIN TRANSACTION");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
495
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
496 foreach ($settings as $key => $data)
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 {
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
498 $sql = false;
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
499
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
500 // Get setting type
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
501 switch ($data[0])
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 {
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 case VT_TEXT: $type = "%s"; $var = "vtext"; break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 case VT_STR: $type = "%s"; $var = "vstr"; break;
72
63a6caf59e5c Fix creation of boolean settings, and add '%b' formatter into stPrepareSQL().
Matti Hamalainen <ccr@tnsp.org>
parents: 67
diff changeset
505 case VT_BOOL: $type = "%b"; $var = "vint"; break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 case VT_INT: $type = "%d"; $var = "vint"; break;
80
e51205f2bdd0 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
507 default: die("Invalid type in default settings '".$key."', type=".$data[0]."\n");
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
510 // Check if we are upgrading
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
511 if ($upgrade)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
512 {
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
513 // Map the key, in case the name has changed
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
514 $inKey = stUpgradeMap("key", $key);
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
515 $inTable = stUpgradeMap("table", $table);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
516
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
517 if (($res = stDBFetchSQL($inDB, stDBPrepareSQL($inDB, "SELECT * FROM ".$inTable." WHERE key=%s", $inKey))) !== FALSE)
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
518 {
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
519 // Yup, upgrade the data, if we can
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
520 echo ".";
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
521
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
522 if ($res["vtype"] != $data[0])
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
523 die("Oops! Data type of '".$key."' does not match in table '".$table.". DB upgrade failed.\n");
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
524
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
525 $sql = stDBPrepareSQL($outDB,
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
526 "INSERT INTO ".$table." (key,vtype,".$var.",sdesc) VALUES (%s,%d,".$type.",%s)",
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
527 $key, $data[0], $res[$var], $data[2]);
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
528 }
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
529 }
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
530
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
531 if ($sql === false)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
532 {
515
2fc7bd9e209f Add comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 511
diff changeset
533 // Normal insertion of default data
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
534 echo "+";
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
535 $sql = stDBPrepareSQL($outDB,
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
536 "INSERT INTO ".$table." (key,vtype,".$var.",sdesc) VALUES (%s,%d,".$type.",%s)",
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
537 $key, $data[0], $data[1], $data[2]);
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
538 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
539
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
540 if (stDBExecSQL($outDB, $sql) === FALSE)
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
541 {
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
542 $status = FALSE;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
543 break;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
544 }
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
545 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
546 echo "\n";
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
547
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
548 stDBExecSQL($outDB, "COMMIT");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
549 return $status;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
550 }
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
551
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
552
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
553 function stAddTestData($outDB)
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
554 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
555 global $siteTestData;
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
556
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
557 echo "Adding test data.\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
558
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
559 $status = TRUE;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
560 stDBExecSQL($outDB, "BEGIN TRANSACTION");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
561
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
562 foreach ($siteTestData as $table => $data)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
563 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
564 echo " - ".$table."...\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
565 if (count($data) >= 3)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
566 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
567 for ($n = 2; $n < count($data); $n++)
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
568 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
569 $arr = array_merge(
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
570 array($outDB, "INSERT INTO ".$table." (".$data[0].") VALUES (".$data[1].")"),
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
571 $data[$n]);
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
572
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
573 $sql = call_user_func_array('stDBPrepareSQL', $arr);
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
574 if (stDBExecSQL($outDB, $sql) === false)
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
575 {
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
576 $status = false;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
577 break;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
578 }
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
579 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
580 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
581 else
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
582 {
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
583 echo " Invalid table / data definition.\n";
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
584 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
585 }
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
586
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
587 stDBExecSQL($outDB, "COMMIT");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
588 return $status;
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
589 }
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
590
499
408effd4e9ea Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 490
diff changeset
591
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
592 function stGetSQLTypeParam($dbh, $def, $value)
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
593 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
594 switch (substr($def, 0, 3))
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
595 {
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
596 case "INT":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
597 return intval($value);
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
598
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
599 case "VAR":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
600 case "TEX":
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
601 return $dbh->quote($value);
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
602
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
603 default: die("Unknown type ".$col[1].".\n");
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
604 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
605 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
606
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
607
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
608 function stMigrateTables($inDB, $outDB, $upgrade, $excluded)
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
609 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
610 global $sqlTables;
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
611
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
612 echo "Migrating tables...\n";
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
613 $status = TRUE;
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
614 stDBExecSQL($outDB, "BEGIN TRANSACTION");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
615
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
616 foreach ($sqlTables as $name => $schema)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
617 {
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
618 $inTable = $upgrade ? stUpgradeMap("table", $name) : $name;
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
619
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
620 if (!in_array($inTable, $excluded) && !in_array($name, $excluded))
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
621 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
622 echo " - '".$name."' ";
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
623
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
624 foreach (stDBExecSQL($inDB, "SELECT * FROM ".$inTable) as $row)
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
625 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
626 $avals = array();
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
627 $acols = array();
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
628
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
629 foreach ($schema as $col)
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
630 {
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
631 if (isset($row[$col[0]]))
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
632 {
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
633 $avals[] = stGetSQLTypeParam($outDB, $col[1], $row[$col[0]]);
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
634 $acols[] = $col[0];
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
635 }
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
636 }
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
637
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
638 $sql = "INSERT INTO ".$name." (".implode(",", $acols).") VALUES (".implode(",", $avals).")";
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
639 if (stDBExecSQL($outDB, $sql) === false)
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
640 {
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
641 $status = FALSE;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
642 break;
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
643 }
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
644 echo ".";
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
645 }
540
ab08640b4302 Improve database upgrade code.
Matti Hamalainen <ccr@tnsp.org>
parents: 533
diff changeset
646 echo "\n";
504
a491865e0684 Implement tables migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 503
diff changeset
647 }
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
648 }
519
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
649
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
650 stDBExecSQL($outDB, "COMMIT");
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
651
6aa9356ead52 Improve migration.
Matti Hamalainen <ccr@tnsp.org>
parents: 518
diff changeset
652 return $status;
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
653 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
654
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
655
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
656 function stSetDBPermissions($spec)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
657 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
658 if (substr($spec, 0, 7) == "sqlite:")
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
659 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
660 $filename = substr($spec, 7);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
661 echo
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
662 "NOTICE! It seems you have SQLite database in use, changing permission ".
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
663 "of the target file '".$filename."' to 0600, for security. You may have to ".
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
664 "loosen up that for the things to actually work, but be careful. Having your ".
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
665 "database world-readable in the web is NOT good.\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
666
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
667 if (chmod($filename, 0600) === FALSE)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
668 {
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
669 echo "ERROR! Could not set permissions of '".$filename."!\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
670 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
671 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
672 }
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
673
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
674
36
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
675 //
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
676 // Main program starts
ace577c92a32 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
677 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
678 if ($argc < 2)
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
679 {
482
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
680 echo
529
ddbc84031a7b Rename createdb.php to managedb.php
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
681 "ManageDB - Manage FAPWeb SQL database\n".
482
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
682 "(C) Copyright 2012-2013 ccr/TNSP\n".
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
683 "\n".
e0fd4c7ae8fb Update commandline help, remove the commandline option for target database
Matti Hamalainen <ccr@tnsp.org>
parents: 479
diff changeset
684 "Usage: ".$argv[0]." <mode> [args]\n".
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 "Where mode is one of following:\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 "\n".
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
687 " new <dbspec> Create a new database with given PDO spec\n".
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 " or default to the one in mconfig.inc.php\n".
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
689 "\n".
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
690 " test <dbspec> Like new, but add initial test data.\n".
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
691 "\n".
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
692 " upgrade <input_dbspec> <output_dbspec>\n".
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
693 " Upgrade current database, if possible.\n".
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
694 " Output to new database (DO NOT USE SAME as current!)\n".
516
664915ff8520 Add 'migrate' option.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
695 "\n".
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
696 " migrate <input_dbspec> <output_dbspec>\n".
516
664915ff8520 Add 'migrate' option.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
697 " Like upgrade, but no version check. Creates\n".
664915ff8520 Add 'migrate' option.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
698 " a copy of the database to the output spec.\n".
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
699 "\n";
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
700 exit;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
702
541
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
703 // Validate tables data
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
704 $errors = FALSE;
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
705 foreach ($sqlTables as $table => $data)
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
706 {
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
707 if (strtolower($table) != $table)
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
708 {
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
709 echo "Invalid table definition '".$table."', table name must be lower case.\n";
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
710 $errors = TRUE;
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
711 }
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
712
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
713 foreach ($data as $def)
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
714 if (strtolower($def[0]) != $def[0])
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
715 {
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
716 echo "Invalid table definition '".$table."', column key '".$def[0]."' must be lower case.\n";
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
717 $errors = TRUE;
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
718 }
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
719 }
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
720
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
721 if ($errors)
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
722 die("Errors in table definitions.\n");
e5a088dd3a4b Validate current table schema before actions.
Matti Hamalainen <ccr@tnsp.org>
parents: 540
diff changeset
723
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
725 // Act according to specified command
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
726 $addTestData = FALSE;
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
727 $upgrade = FALSE;
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
728
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
729 switch (stCArgLC(1))
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
730 {
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
731 case "test":
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
732 $addTestData = TRUE;
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
733
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
734 case "new":
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
735 // Try to connect to database
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
736 if (($inSpec = stCArg(2)) === false)
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
737 die("No PDO database spec specified.\n");
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
738
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
739 if (($inDB = stConnectSQLDBSpec($inSpec)) === false)
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
740 die("Could not connect to SQL database '".$inSpec."'.\n");
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
741
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
742 echo "Using database spec '".$inSpec."'.\n";
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
743
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
744 // Create tables, add defaults
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
745 if (stCreateTables($inDB, FALSE))
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
746 {
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
747 stAddSettings($inDB, $inDB, $dbMeta, "dbmeta", FALSE);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
748 stAddSettings($inDB, $inDB, $siteDefaults, "settings", FALSE);
542
8c1a53532be0 Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents: 541
diff changeset
749 stAddSettings($inDB, $inDB, $siteDisplayVars, "display_vars", FALSE);
139
75cf14ee99a7 More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
750 }
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
751
489
aa65fe63072e Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
752 if ($addTestData)
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
753 stAddTestData($inDB);
85
50d6c69836a1 Add test data mode for database creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 81
diff changeset
754
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
755 stSetDBPermissions($inSpec);
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
756 break;
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
757
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
758 case "upgrade":
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
759 $upgrade = TRUE;
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
760
516
664915ff8520 Add 'migrate' option.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
761 case "migrate":
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
762 //
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
763 // Attempt to upgrade database
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
764 //
525
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
765 if ($argc < 4)
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
766 die("Usage: ".$argv[0]." upgrade <input_dbspec> <output_dbspec>\n");
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
767
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
768 $inSpec = stCArg(2);
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
769 $outSpec = stCArg(3);
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
770
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
771 if ($outSpec == $inSpec)
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
772 die("The input and output databases CAN NOT BE SAME.\nBe VERY CAREFUL to not accidentally specify same db!\n");
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
773
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
774 echo "Using database spec '".$inSpec."'.\n";
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
775
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
776 if (($inDB = stConnectSQLDBSpec($inSpec)) === false)
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
777 die("Could not connect to SQL database '".$inSpec."'.\n");
d7302b3a479e Change database tool commandline a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 519
diff changeset
778
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
779 // Check the current version first ...
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
780 if (($currVersion = stGetDBMeta($inDB, "dbVersion")) === FALSE)
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
781 $currVersion = -1;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
782
516
664915ff8520 Add 'migrate' option.
Matti Hamalainen <ccr@tnsp.org>
parents: 515
diff changeset
783 if ($currVersion == $dbVersion && stCArgLC(1) == "upgrade")
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
784 {
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
785 echo "Database is already version ".$dbVersion.", no upgrading needed.\n";
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
786 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
787 else
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
788 {
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
789 // Okay, we shall create an upgraded version ..
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
790 if (($outDB = stConnectSQLDBSpec($outSpec)) === false)
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
791 die("Could not connect to SQL database '".$outSpec."'.\n");
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
792
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
793 echo "Database at version ".$currVersion.", upgrading to ".$dbVersion."\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
794 echo "Using OUTPUT database spec '".$outSpec."'.\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
795
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
796 // Possibly bail out incompatible upgrades here
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
797
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
798 // Create tables
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
799 if (!stCreateTables($outDB, TRUE))
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
800 exit;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
801
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
802 // Migrate data from setting tables ..
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
803 if (!stAddSettings($inDB, $outDB, $siteDefaults, "settings", $upgrade))
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
804 exit;
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
805
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
806 if (!stAddSettings($inDB, $outDB, $siteDisplayVars, "display_vars", $upgrade))
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
807 exit;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
808
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
809 stAddSettings($inDB, $outDB, $dbMeta, "dbmeta", $upgrade);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
810
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
811 // Migrate other tables
551
bed441ced78e Improve migration and upgrade procedures.
Matti Hamalainen <ccr@tnsp.org>
parents: 549
diff changeset
812 if (!stMigrateTables($inDB, $outDB, $upgrade, array("settings", "display_vars", "dbmeta")))
503
3232f682f0d2 Change how table schemas are defined, in preparation for future database
Matti Hamalainen <ccr@tnsp.org>
parents: 502
diff changeset
813 exit;
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
814
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
815 echo "Setting dbVersion.\n";
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
816 stSetDBMeta($outDB, "dbVersion", $dbVersion);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
817 echo "Upgrade complete.\n";
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
818
502
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
819 stSetDBPermissions($inSpec);
d2a38070e18f Partially refactor database upgrading .. not finished yet, and the
Matti Hamalainen <ccr@tnsp.org>
parents: 500
diff changeset
820 stSetDBPermissions($outSpec);
199
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
821 }
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
822 break;
dbc6f214b825 Work on a database upgrade function.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
823
27
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
824 default:
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
825 echo "ERROR! Invalid operation mode '".stCArg(1)."'.\n";
b27204653615 Work on adding support for entry submission.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
826 break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
827 }
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
828
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
829
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
830 //
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
831 // Clean up permissions
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
832 //
529
ddbc84031a7b Rename createdb.php to managedb.php
Matti Hamalainen <ccr@tnsp.org>
parents: 528
diff changeset
833 foreach (array("managedb.php") as $filename)
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
834 {
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
835 if (chmod($filename, 0700) === FALSE)
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
836 {
490
505f46b8bb14 Separate variable from string flow.
Matti Hamalainen <ccr@tnsp.org>
parents: 489
diff changeset
837 echo "ERROR! Could not set permissions for '".$filename."'!\n";
28
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
838 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
839 }
bf567e6402bf Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
840
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
841 ?>