-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_missing_tables.php
More file actions
42 lines (38 loc) · 1.21 KB
/
Copy pathupdate_missing_tables.php
File metadata and controls
42 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
try {
// Connect to the SQLite database
$db = new SQLite3('admin_users.db');
// Add the volunteer_roles table if it doesn't exist
$db->exec("
CREATE TABLE IF NOT EXISTS volunteer_roles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
role_name TEXT NOT NULL,
visible INTEGER NOT NULL DEFAULT 1
);
");
// Add the ride_visibility table if it doesn't exist
$db->exec("
CREATE TABLE IF NOT EXISTS ride_visibility (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ride_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
visible INTEGER NOT NULL DEFAULT 1,
FOREIGN KEY (ride_id) REFERENCES rides (id),
FOREIGN KEY (role_id) REFERENCES volunteer_roles (id)
);
");
// Add the users table if it doesn't exist
$db->exec("
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
phone TEXT
);
");
echo "Missing tables added successfully!";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>