-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
28 lines (26 loc) · 868 Bytes
/
setup.php
File metadata and controls
28 lines (26 loc) · 868 Bytes
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
<?php
require_once 'db_connect.php';
try {
$pdo->exec("ALTER TABLE members ADD COLUMN IF NOT EXISTS is_new_member TINYINT(1) DEFAULT 0");
echo "Added is_new_member column.\n";
} catch(PDOException $e) {
if(strpos($e->getMessage(), 'Duplicate column name') !== false) {
echo "Column already exists.\n";
} else {
echo "Error: " . $e->getMessage() . "\n";
}
}
try {
$pdo->exec("CREATE TABLE IF NOT EXISTS destiny_chapel.attendance (
id INT AUTO_INCREMENT PRIMARY KEY,
member_id INT,
attendance_date DATE,
check_in_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (member_id) REFERENCES destiny_chapel.members(id) ON DELETE CASCADE
)");
echo "Created attendance table.\n";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
echo "Setup complete.\n";
?>