File README changed (mode: 100644) (index 5ad3d65..ebe4e09) |
24 |
24 |
# systemctl enable httpd.service |
# systemctl enable httpd.service |
25 |
25 |
# systemctl start httpd.service |
# systemctl start httpd.service |
26 |
26 |
|
|
|
27 |
|
. Install and activate xinetd (for git:// access) |
|
28 |
|
# yum install xinetd |
|
29 |
|
# systemctl enable xinetd.service |
|
30 |
|
# systemctl start xinetd.service |
|
31 |
|
|
27 |
32 |
. Install and configure PostgreSQL server |
. Install and configure PostgreSQL server |
28 |
33 |
# yum install postgresql-server |
# yum install postgresql-server |
29 |
34 |
# systemctl enable postgresql.service |
# systemctl enable postgresql.service |
30 |
35 |
# service postgresql initdb (TAKE CARE! YOU MAY DESTROY ALL YOUR DATA!) |
# service postgresql initdb (TAKE CARE! YOU MAY DESTROY ALL YOUR DATA!) |
31 |
36 |
# systemctl start postgresql.service |
# systemctl start postgresql.service |
32 |
37 |
|
|
33 |
|
. Create a rocketgit user |
|
|
38 |
|
. Create a rocketgit user and database |
34 |
39 |
# su - postgres |
# su - postgres |
35 |
40 |
$ createuser -d -R -S rocketgit |
$ createuser -d -R -S rocketgit |
36 |
|
|
|
37 |
|
. Create the database |
|
38 |
|
# su - postgres |
|
39 |
41 |
$ createdb -O rocketgit rocketgit |
$ createdb -O rocketgit rocketgit |
40 |
42 |
|
|
41 |
43 |
. Set correct rights in pg_ident.conf/pg_hba.conf and restart: |
. Set correct rights in pg_ident.conf/pg_hba.conf and restart: |
|
65 |
67 |
. Special thanks to my brother that contributed brain and time to this project. |
. Special thanks to my brother that contributed brain and time to this project. |
66 |
68 |
. Special thanks to git people for the best tool to manage sources. |
. Special thanks to git people for the best tool to manage sources. |
67 |
69 |
. Special thanks to a lot of people that came with suggestions. |
. Special thanks to a lot of people that came with suggestions. |
68 |
|
. Special thanks to gitosys, Gitorious and other projects from where I learned things. |
|
|
70 |
|
. Special thanks to gitosys, Gitorious and other projects from where I learned |
|
71 |
|
things. |
File TODO changed (mode: 100644) (index 1812b68..a3a6878) |
6 |
6 |
[ ] Check if repo_path is valid from security pov. |
[ ] Check if repo_path is valid from security pov. |
7 |
7 |
[ ] Make available the push requests. |
[ ] Make available the push requests. |
8 |
8 |
[ ] Add possibility to reject merge requests, to make them public, to delete etc. |
[ ] Add possibility to reject merge requests, to make them public, to delete etc. |
|
9 |
|
[ ] Should init.php must create db schema or we delay for the first access? |
9 |
10 |
|
|
10 |
11 |
== Normal priority == |
== Normal priority == |
11 |
12 |
[ ] |
[ ] |
|
13 |
|
[ ] rg-repos should be split in rg_repos and rg_var_lib. |
12 |
14 |
[ ] 'cop' variable is not good - I do not remember what it means! |
[ ] 'cop' variable is not good - I do not remember what it means! |
13 |
15 |
[ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced! |
[ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced! |
14 |
16 |
[ ] Changing repo name probably is not working right. |
[ ] Changing repo name probably is not working right. |
File admin/init.php changed (mode: 100644) (index d7b5809..8af30b3) |
... |
... |
$INC = dirname(__FILE__) . "/../inc"; |
9 |
9 |
require_once($INC . "/util.inc.php"); |
require_once($INC . "/util.inc.php"); |
10 |
10 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
11 |
11 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
12 |
|
require_once($INC . "/db/struct.inc.php"); |
|
|
12 |
|
require_once($INC . "/struct.inc.php"); |
13 |
13 |
require_once($INC . "/state.inc.php"); |
require_once($INC . "/state.inc.php"); |
14 |
14 |
|
|
15 |
15 |
rg_log_set_file("init.log"); |
rg_log_set_file("init.log"); |
|
... |
... |
if ($db === FALSE) { |
20 |
20 |
exit(1); |
exit(1); |
21 |
21 |
} |
} |
22 |
22 |
|
|
23 |
|
$ignore_errors = FALSE; |
|
24 |
|
$drop_tables = FALSE; |
|
25 |
|
$old_schema_ver = 0; |
|
26 |
|
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); |
|
|
23 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
27 |
24 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
28 |
|
echo "Cannot init structure (" . rg_sql_error() . ")!\n"; |
|
|
25 |
|
echo "Cannot init structure. Check the logs!\n"; |
29 |
26 |
exit(1); |
exit(1); |
30 |
27 |
} |
} |
31 |
28 |
|
|
File admin/update.php deleted (index 1a35625..0000000) |
1 |
|
<?php |
|
2 |
|
// This must be executed at every update |
|
3 |
|
error_reporting(E_ALL); |
|
4 |
|
ini_set("track_errors", "On"); |
|
5 |
|
|
|
6 |
|
require_once("/etc/rocketgit/config.php"); |
|
7 |
|
|
|
8 |
|
$INC = dirname(__FILE__) . "/../inc"; |
|
9 |
|
require_once($INC . "/util.inc.php"); |
|
10 |
|
require_once($INC . "/log.inc.php"); |
|
11 |
|
require_once($INC . "/state.inc.php"); |
|
12 |
|
require_once($INC . "/sql.inc.php"); |
|
13 |
|
require_once($INC . "/db/struct.inc.php"); |
|
14 |
|
|
|
15 |
|
rg_log_set_file($rg_log_dir . "/update.log"); |
|
16 |
|
|
|
17 |
|
echo "RocketGit: upgrading...\n"; |
|
18 |
|
|
|
19 |
|
$db = rg_sql_open($rg_sql); |
|
20 |
|
if ($db === FALSE) { |
|
21 |
|
echo "Internal error (" . rg_sql_error() . ")!\n"; |
|
22 |
|
exit(1); |
|
23 |
|
} |
|
24 |
|
|
|
25 |
|
// Get current schema version |
|
26 |
|
$old_schema_ver = rg_state_get($db, "schema_version"); |
|
27 |
|
if (empty($old_schema_ver)) |
|
28 |
|
$old_schema_ver = 1; |
|
29 |
|
echo "RocketGit: old_schema_ver=$old_schema_ver.\n"; |
|
30 |
|
|
|
31 |
|
if (rg_sql_begin($db) !== TRUE) { |
|
32 |
|
echo "RocketGit: Cannot start transaction (" . rg_sql_error() . ")!\n"; |
|
33 |
|
exit(1); |
|
34 |
|
} |
|
35 |
|
|
|
36 |
|
$ignore_errors = FALSE; |
|
37 |
|
$drop_tables = FALSE; |
|
38 |
|
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); |
|
39 |
|
if ($r !== TRUE) { |
|
40 |
|
echo "RocketGit: Cannot update schema (" . rg_sql_error() . ")!\n"; |
|
41 |
|
exit(1); |
|
42 |
|
} |
|
43 |
|
|
|
44 |
|
if (rg_state_set($db, "schema_version", $rg_sql_schema_ver) !== TRUE) { |
|
45 |
|
echo "RocketGit: Cannot set schema_version" |
|
46 |
|
. " (" . rg_state_error() . ")!\n"; |
|
47 |
|
exit(1); |
|
48 |
|
} |
|
49 |
|
|
|
50 |
|
if (rg_sql_commit($db) !== TRUE) { |
|
51 |
|
echo "RocketGit: Cannot commit transaction (" . rg_sql_error() . ")!\n"; |
|
52 |
|
exit(1); |
|
53 |
|
} |
|
54 |
|
|
|
55 |
|
echo "RocketGit: OK! New schema version is $rg_sql_schema_ver.\n"; |
|
56 |
|
?> |
|
File inc/sql.inc.php changed (mode: 100644) (index 7ca0a1c..be8a396) |
2 |
2 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
3 |
3 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
4 |
4 |
|
|
|
5 |
|
$rg_sql_conn = array(); |
|
6 |
|
|
5 |
7 |
$rg_sql_error = ""; |
$rg_sql_error = ""; |
6 |
8 |
|
|
7 |
9 |
if (!function_exists("pg_connect")) |
if (!function_exists("pg_connect")) |
|
... |
... |
function rg_sql_error() |
30 |
32 |
function rg_sql_open($str) |
function rg_sql_open($str) |
31 |
33 |
{ |
{ |
32 |
34 |
global $rg_sql_debug; |
global $rg_sql_debug; |
|
35 |
|
global $rg_sql_conn; |
|
36 |
|
|
|
37 |
|
if (isset($rg_sql_conn[$str])) |
|
38 |
|
return $rg_sql_conn[$str]; |
33 |
39 |
|
|
34 |
40 |
if ($rg_sql_debug > 0) |
if ($rg_sql_debug > 0) |
35 |
41 |
rg_log("DB: opening [$str]..."); |
rg_log("DB: opening [$str]..."); |
|
... |
... |
function rg_sql_open($str) |
46 |
52 |
return FALSE; |
return FALSE; |
47 |
53 |
} |
} |
48 |
54 |
|
|
|
55 |
|
$rg_sql_conn[$str] = $db; |
|
56 |
|
|
49 |
57 |
return $db; |
return $db; |
50 |
58 |
} |
} |
51 |
59 |
|
|
File inc/struct.inc.php renamed from inc/db/struct.inc.php (similarity 72%) (mode: 100644) (index 769176c..f0e7072) |
1 |
1 |
<?php |
<?php |
|
2 |
|
include_once($INC . "/sql.inc.php"); |
|
3 |
|
include_once($INC . "/state.inc.php"); |
|
4 |
|
include_once($INC . "/util.inc.php"); |
|
5 |
|
|
|
6 |
|
define("RG_DROP_TABLES", 1); |
|
7 |
|
define("RG_IGNORE_ERRORS", 1 << 1); |
|
8 |
|
|
2 |
9 |
$rg_sql_struct = array(); |
$rg_sql_struct = array(); |
3 |
10 |
$rg_sql_struct[1] = array(); |
$rg_sql_struct[1] = array(); |
4 |
11 |
$rg_sql_struct[1]['tables'] = array( |
$rg_sql_struct[1]['tables'] = array( |
|
... |
... |
$rg_sql_struct[4]['other'] = array( |
100 |
107 |
. " ON merge_requests (repo_id)" |
. " ON merge_requests (repo_id)" |
101 |
108 |
); |
); |
102 |
109 |
|
|
|
110 |
|
$rg_sql_struct[5] = array(); |
|
111 |
|
$rg_sql_struct[5]['tables'] = array( |
|
112 |
|
"history_push" => "CREATE TABLE history_push (" |
|
113 |
|
. "itime INT NOT NULL" |
|
114 |
|
. ", repo_id INT NOT NULL" |
|
115 |
|
. ", ip TEXT NOT NULL" |
|
116 |
|
. ", refname TEXT NOT NULL" |
|
117 |
|
. ", old_rev CHAR(40) NOT NULL" |
|
118 |
|
. ", new_rev CHAR(40) NOT NULL" |
|
119 |
|
. ")" |
|
120 |
|
); |
|
121 |
|
|
103 |
122 |
// This must be the last line |
// This must be the last line |
104 |
123 |
$rg_sql_schema_ver = count($rg_sql_struct); |
$rg_sql_schema_ver = count($rg_sql_struct); |
105 |
124 |
|
|
|
... |
... |
$rg_sql_schema_ver = count($rg_sql_struct); |
108 |
127 |
/* |
/* |
109 |
128 |
* Generate structure |
* Generate structure |
110 |
129 |
*/ |
*/ |
111 |
|
function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver) |
|
|
130 |
|
function rg_sql_struct_run($db, $flags, $old_schema_ver) |
112 |
131 |
{ |
{ |
113 |
132 |
global $rg_sql_struct; |
global $rg_sql_struct; |
114 |
133 |
global $rg_sql_schema_ver; |
global $rg_sql_schema_ver; |
115 |
134 |
|
|
116 |
|
rg_log("sql_struct_run:" |
|
|
135 |
|
$ignore_errors = ($flags & RG_IGNORE_ERRORS) ? TRUE : FALSE; |
|
136 |
|
$drop_tables = ($flags & RG_DROP_TABLES) ? TRUE : FALSE; |
|
137 |
|
|
|
138 |
|
rg_log("sql_struct_run: flags=$flags" |
117 |
139 |
. " ignore_errors=" . ($ignore_errors ? "Yes" : "No") |
. " ignore_errors=" . ($ignore_errors ? "Yes" : "No") |
118 |
140 |
. " drop_tables=" . ($drop_tables ? "Yes" : "No") |
. " drop_tables=" . ($drop_tables ? "Yes" : "No") |
119 |
141 |
. " old_schema_ver=$old_schema_ver..."); |
. " old_schema_ver=$old_schema_ver..."); |
|
... |
... |
function rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver) |
155 |
177 |
return TRUE; |
return TRUE; |
156 |
178 |
} |
} |
157 |
179 |
|
|
|
180 |
|
/* |
|
181 |
|
* Update schema if needed |
|
182 |
|
* Returns FALSE in case of error |
|
183 |
|
*/ |
|
184 |
|
function rg_sql_struct_update_if_needed($db, $flags) |
|
185 |
|
{ |
|
186 |
|
global $rg_sql_schema_ver; |
|
187 |
|
|
|
188 |
|
rg_log("sql_struct_update: flags=$flags"); |
|
189 |
|
|
|
190 |
|
$old = rg_state_get($db, "schema_version"); |
|
191 |
|
if (empty($old)) |
|
192 |
|
$old = 0; |
|
193 |
|
|
|
194 |
|
rg_log("DEBUG: old=$old new=$rg_sql_schema_ver"); |
|
195 |
|
if ($old == $rg_sql_schema_ver) { |
|
196 |
|
rg_log("DEBUG: schema is up to date!"); |
|
197 |
|
return TRUE; |
|
198 |
|
} |
|
199 |
|
|
|
200 |
|
// If we cannot lock, return error |
|
201 |
|
if (rg_lock("schema_upgrade.lock") === FALSE) |
|
202 |
|
return FALSE; |
|
203 |
|
|
|
204 |
|
if (rg_sql_begin($db) !== TRUE) |
|
205 |
|
return FALSE; |
|
206 |
|
|
|
207 |
|
$r = rg_sql_struct_run($db, $flags, $old); |
|
208 |
|
if ($r !== TRUE) { |
|
209 |
|
rg_log("Cannot update schema (" . rg_sql_error() . ")"); |
|
210 |
|
return FALSE; |
|
211 |
|
} |
|
212 |
|
|
|
213 |
|
$r = rg_state_set($db, "schema_version", $rg_sql_schema_ver); |
|
214 |
|
if ($r !== TRUE) { |
|
215 |
|
rg_log("Cannot update schema ver (" . rg_state_error() . ")"); |
|
216 |
|
return FALSE; |
|
217 |
|
} |
|
218 |
|
|
|
219 |
|
if (rg_sql_commit($db) !== TRUE) |
|
220 |
|
return FALSE; |
|
221 |
|
|
|
222 |
|
rg_unlock("schema_upgrade.lock"); |
|
223 |
|
|
|
224 |
|
return TRUE; |
|
225 |
|
} |
158 |
226 |
?> |
?> |
File inc/util.inc.php changed (mode: 100644) (index 6ed8a25..c733018) |
... |
... |
function rg_id($len) |
57 |
57 |
return substr($id, 0, $len); |
return substr($id, 0, $len); |
58 |
58 |
} |
} |
59 |
59 |
|
|
60 |
|
$_lock = FALSE; |
|
61 |
|
function rg_lock_or_exit($file) |
|
|
60 |
|
$_lock = array(); |
|
61 |
|
function rg_lock($file) |
62 |
62 |
{ |
{ |
63 |
63 |
global $_lock; |
global $_lock; |
64 |
64 |
global $rg_lock_dir; |
global $rg_lock_dir; |
|
... |
... |
function rg_lock_or_exit($file) |
67 |
67 |
$rg_lock_dir = "/var/lib/rocketgit"; |
$rg_lock_dir = "/var/lib/rocketgit"; |
68 |
68 |
|
|
69 |
69 |
// Double locking? |
// Double locking? |
70 |
|
if ($_lock !== FALSE) |
|
|
70 |
|
if (isset($_lock[$file])) |
71 |
71 |
return FALSE; |
return FALSE; |
72 |
72 |
|
|
73 |
|
$_lock = @fopen($rg_lock_dir . "/" . $file, "w"); |
|
74 |
|
if ($_lock === FALSE) |
|
|
73 |
|
$f = @fopen($rg_lock_dir . "/" . $file, "w"); |
|
74 |
|
if ($f === FALSE) |
75 |
75 |
return FALSE; |
return FALSE; |
76 |
76 |
|
|
77 |
|
if (!flock($_lock, LOCK_EX | LOCK_NB)) { |
|
78 |
|
fclose($_lock); |
|
79 |
|
exit(0); |
|
|
77 |
|
if (!flock($f, LOCK_EX | LOCK_NB)) { |
|
78 |
|
fclose($f); |
|
79 |
|
return FALSE; |
80 |
80 |
} |
} |
81 |
81 |
|
|
82 |
|
fwrite($_lock, getmypid() . "\n"); |
|
|
82 |
|
fwrite($f, getmypid() . "\n"); |
|
83 |
|
|
|
84 |
|
$_lock[$file] = $f; |
|
85 |
|
|
|
86 |
|
return TRUE; |
|
87 |
|
} |
|
88 |
|
|
|
89 |
|
function rg_lock_or_exit($file) |
|
90 |
|
{ |
|
91 |
|
global $_lock; |
|
92 |
|
|
|
93 |
|
if (rg_lock($file) === FALSE) |
|
94 |
|
exit(0); |
|
95 |
|
} |
|
96 |
|
|
|
97 |
|
function rg_unlock($file) |
|
98 |
|
{ |
|
99 |
|
global $_lock; |
|
100 |
|
|
|
101 |
|
fclose($_lock[$file]); |
83 |
102 |
} |
} |
84 |
103 |
|
|
85 |
104 |
function rg_load() |
function rg_load() |
File scripts/remote.php changed (mode: 100644) (index 4978f5f..20d22bb) |
... |
... |
$db = rg_sql_open($rg_sql); |
133 |
133 |
if ($db === FALSE) |
if ($db === FALSE) |
134 |
134 |
fatal("Internal error (db)!"); |
fatal("Internal error (db)!"); |
135 |
135 |
|
|
|
136 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
137 |
|
if ($r !== TRUE) |
|
138 |
|
fatal("We are in a short maintenance. Try again later."); |
|
139 |
|
|
136 |
140 |
// Loading info about the repository |
// Loading info about the repository |
137 |
141 |
$rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo); |
$rr = array("prefix" => $prefix, "user" => $user, "repo" => $repo); |
138 |
142 |
$ri = rg_repo_info($db, $rr); |
$ri = rg_repo_info($db, $rr); |
File tests/keys.php changed (mode: 100644) (index 4c87573..0407357) |
... |
... |
ini_set("track_errors", "On"); |
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/util.inc.php"); |
require_once($INC . "/util.inc.php"); |
7 |
7 |
require_once($INC . "/keys.inc.php"); |
require_once($INC . "/keys.inc.php"); |
8 |
|
require_once($INC . "/db/struct.inc.php"); |
|
|
8 |
|
require_once($INC . "/struct.inc.php"); |
9 |
9 |
|
|
10 |
10 |
rg_log_set_file("keys.log"); |
rg_log_set_file("keys.log"); |
11 |
11 |
|
|
|
... |
... |
if ($db === FALSE) { |
17 |
17 |
exit(1); |
exit(1); |
18 |
18 |
} |
} |
19 |
19 |
|
|
20 |
|
// needed for state table |
|
21 |
|
$ignore_errors = FALSE; |
|
22 |
|
$drop_tables = TRUE; |
|
23 |
|
$old_schema_ver = 0; |
|
24 |
|
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); |
|
25 |
|
if ($r === FALSE) { |
|
|
20 |
|
$r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES); |
|
21 |
|
if ($r !== TRUE) { |
26 |
22 |
echo "Cannot create structure (" . rg_sql_error() . ")!\n"; |
echo "Cannot create structure (" . rg_sql_error() . ")!\n"; |
27 |
23 |
exit(1); |
exit(1); |
28 |
24 |
} |
} |
File tests/repo.php changed (mode: 100644) (index 87fd5fd..38547df) |
... |
... |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
7 |
|
require_once($INC . "/db/struct.inc.php"); |
|
|
7 |
|
require_once($INC . "/struct.inc.php"); |
8 |
8 |
|
|
9 |
9 |
rg_log_set_file("repo.log"); |
rg_log_set_file("repo.log"); |
10 |
10 |
|
|
|
... |
... |
if ($db === FALSE) { |
85 |
85 |
exit(1); |
exit(1); |
86 |
86 |
} |
} |
87 |
87 |
|
|
88 |
|
$ignore_errors = TRUE; |
|
89 |
|
$drop_tables = TRUE; |
|
90 |
|
$old_schema_ver = 0; |
|
91 |
|
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); |
|
92 |
|
if ($r === FALSE) { |
|
|
88 |
|
$r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES|RG_IGNORE_ERRORS); |
|
89 |
|
if ($r !== TRUE) { |
93 |
90 |
rg_log("Cannot create struct (" . rg_sql_error() . ")!"); |
rg_log("Cannot create struct (" . rg_sql_error() . ")!"); |
94 |
91 |
exit(1); |
exit(1); |
95 |
92 |
} |
} |
File tests/state.php changed (mode: 100644) (index 86fb85e..7df990f) |
... |
... |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
7 |
7 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
8 |
8 |
require_once($INC . "/state.inc.php"); |
require_once($INC . "/state.inc.php"); |
9 |
|
require_once($INC . "/db/struct.inc.php"); |
|
|
9 |
|
require_once($INC . "/struct.inc.php"); |
10 |
10 |
|
|
11 |
11 |
rg_log_set_file("state.log"); |
rg_log_set_file("state.log"); |
12 |
12 |
|
|
13 |
13 |
$rg_sql_debug = 1; |
$rg_sql_debug = 1; |
|
14 |
|
$rg_lock_dir = "."; |
14 |
15 |
|
|
15 |
16 |
$db = rg_sql_open("dbname=trg"); |
$db = rg_sql_open("dbname=trg"); |
16 |
17 |
if ($db === FALSE) { |
if ($db === FALSE) { |
|
... |
... |
if ($db === FALSE) { |
18 |
19 |
exit(1); |
exit(1); |
19 |
20 |
} |
} |
20 |
21 |
|
|
21 |
|
// needed for state table |
|
22 |
|
$ignore_errors = FALSE; |
|
23 |
|
$drop_tables = TRUE; |
|
24 |
|
$old_schema_ver = 0; |
|
25 |
|
$r = rg_sql_struct_run($db, $ignore_errors, $drop_tables, $old_schema_ver); |
|
26 |
|
if ($r === FALSE) { |
|
|
22 |
|
$r = rg_state_set($db, "schema_version", "0"); |
|
23 |
|
if ($r !== TRUE) { |
|
24 |
|
echo "Cannot reset schema (" . rg_state_error() . ")!\n"; |
|
25 |
|
exit(1); |
|
26 |
|
} |
|
27 |
|
|
|
28 |
|
$r = rg_sql_struct_update_if_needed($db, RG_DROP_TABLES); |
|
29 |
|
if ($r !== TRUE) { |
27 |
30 |
echo "Cannot create structure (" . rg_sql_error() . ")!\n"; |
echo "Cannot create structure (" . rg_sql_error() . ")!\n"; |
28 |
31 |
exit(1); |
exit(1); |
29 |
32 |
} |
} |