Initial version
This commit is contained in:
commit
348f4b4317
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules/
|
||||||
|
*/node_modules/
|
||||||
|
*/build/
|
||||||
18
.htaccess
Normal file
18
.htaccess
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
DirectoryIndex index.php index.html
|
||||||
|
Options -Indexes
|
||||||
|
Options -MultiViews
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# 0) Serve existing files/directories as-is
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -d
|
||||||
|
RewriteRule ^ - [L]
|
||||||
|
|
||||||
|
# 1) Internal map: /page or /page/ -> /page.php (if such PHP file exists)
|
||||||
|
RewriteCond %{REQUEST_FILENAME}.php -f
|
||||||
|
RewriteRule ^(.+?)/?$ $1.php [L]
|
||||||
|
|
||||||
|
# 2) Optional: strip trailing slash for non-directories (keeps .php links working)
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule ^(.+)/$ $1 [R=301,L]
|
||||||
0
.perm_test_apache
Normal file
0
.perm_test_apache
Normal file
0
.perm_test_exec
Normal file
0
.perm_test_exec
Normal file
17
db/config.php
Normal file
17
db/config.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||||
|
define('DB_HOST', '127.0.0.1');
|
||||||
|
define('DB_NAME', 'app_30797');
|
||||||
|
define('DB_USER', 'app_30797');
|
||||||
|
define('DB_PASS', '34e7ee58-3a07-450d-ab18-75eb7a20ae8b');
|
||||||
|
|
||||||
|
function db() {
|
||||||
|
static $pdo;
|
||||||
|
if (!$pdo) {
|
||||||
|
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $pdo;
|
||||||
|
}
|
||||||
51
db/migrate.php
Normal file
51
db/migrate.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
function run_migrations() {
|
||||||
|
$pdo = db_connect();
|
||||||
|
|
||||||
|
// 1. Create migrations table if it doesn't exist
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS `migrations` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`migration_file` VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
`applied_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
|
||||||
|
|
||||||
|
// 2. Get all migration files
|
||||||
|
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
||||||
|
|
||||||
|
// 3. Get already applied migrations
|
||||||
|
$stmt = $pdo->query("SELECT `migration_file` FROM `migrations`");
|
||||||
|
$applied_migrations = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
echo "Starting migrations...\n";
|
||||||
|
|
||||||
|
// 4. Apply pending migrations
|
||||||
|
foreach ($migration_files as $file) {
|
||||||
|
$filename = basename($file);
|
||||||
|
if (!in_array($filename, $applied_migrations)) {
|
||||||
|
echo "Applying migration: {$filename}...\n";
|
||||||
|
|
||||||
|
// Execute the SQL file
|
||||||
|
$sql = file_get_contents($file);
|
||||||
|
if (!empty(trim($sql))) {
|
||||||
|
$pdo->exec($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Record the migration
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO `migrations` (`migration_file`) VALUES (?)");
|
||||||
|
$stmt->execute([$filename]);
|
||||||
|
|
||||||
|
echo " ...applied successfully.\n";
|
||||||
|
} else {
|
||||||
|
echo "Migration already applied: {$filename}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Migrations finished.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run migrations if the script is executed directly
|
||||||
|
if (php_sapi_name() === 'cli' && basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {
|
||||||
|
run_migrations();
|
||||||
|
}
|
||||||
105
db/migrations/001_combined_schema.sql
Normal file
105
db/migrations/001_combined_schema.sql
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
-- Combined schema for the event management system
|
||||||
|
|
||||||
|
-- Drop existing tables to ensure a clean slate.
|
||||||
|
-- This is destructive and should not be used in production with existing data.
|
||||||
|
DROP TABLE IF EXISTS `event_vendors`, `event_budgets`, `event_guests`, `event_schedules`, `events`, `vendors`, `venues`, `users`, `roles`;
|
||||||
|
|
||||||
|
-- Table structure for table `roles`
|
||||||
|
CREATE TABLE `roles` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255) NOT NULL UNIQUE,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Seed default roles
|
||||||
|
INSERT INTO `roles` (`name`) VALUES ('Super-Admin'), ('Event Organizer'), ('Vendor'), ('Guest');
|
||||||
|
|
||||||
|
-- Table structure for table `users`
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255) NOT NULL,
|
||||||
|
`email` varchar(255) NOT NULL,
|
||||||
|
`password` varchar(255) NOT NULL,
|
||||||
|
`role_id` int(11) NOT NULL,
|
||||||
|
`created_at` datetime DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `email` (`email`),
|
||||||
|
FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `venues`
|
||||||
|
CREATE TABLE `venues` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`capacity` INT,
|
||||||
|
`amenities` TEXT,
|
||||||
|
`availability` BOOLEAN DEFAULT TRUE,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `vendors`
|
||||||
|
CREATE TABLE `vendors` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`service_type` VARCHAR(255),
|
||||||
|
`contact_info` VARCHAR(255),
|
||||||
|
`rating` DECIMAL(3, 2),
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `events`
|
||||||
|
CREATE TABLE `events` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`organizer_id` INT NOT NULL,
|
||||||
|
`venue_id` INT,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`description` TEXT,
|
||||||
|
`start_time` DATETIME,
|
||||||
|
`end_time` DATETIME,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (`organizer_id`) REFERENCES `users`(`id`),
|
||||||
|
FOREIGN KEY (`venue_id`) REFERENCES `venues`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_schedules`
|
||||||
|
CREATE TABLE `event_schedules` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`activity` VARCHAR(255) NOT NULL,
|
||||||
|
`start_time` DATETIME NOT NULL,
|
||||||
|
`end_time` DATETIME NOT NULL,
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_guests`
|
||||||
|
CREATE TABLE `event_guests` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`user_id` INT,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`email` VARCHAR(255),
|
||||||
|
`rsvp_status` ENUM('attending', 'not_attending', 'maybe') NOT NULL,
|
||||||
|
`meal_preference` VARCHAR(255),
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_budgets`
|
||||||
|
CREATE TABLE `event_budgets` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`item_name` VARCHAR(255) NOT NULL,
|
||||||
|
`estimated_cost` DECIMAL(10, 2) NOT NULL,
|
||||||
|
`actual_cost` DECIMAL(10, 2),
|
||||||
|
`paid_status` BOOLEAN DEFAULT FALSE,
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_vendors`
|
||||||
|
CREATE TABLE `event_vendors` (
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`vendor_id` INT NOT NULL,
|
||||||
|
PRIMARY KEY (`event_id`, `vendor_id`),
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`vendor_id`) REFERENCES `vendors`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
104
db/migrations/001_initial_schema.sql
Normal file
104
db/migrations/001_initial_schema.sql
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
-- Combined schema for the event management system
|
||||||
|
|
||||||
|
-- Drop existing tables to ensure a clean slate.
|
||||||
|
-- This is destructive and should not be used in production with existing data.
|
||||||
|
DROP TABLE IF EXISTS `event_vendors`, `event_budgets`, `event_guests`, `event_schedules`, `events`, `vendors`, `venues`, `users`, `roles`;
|
||||||
|
|
||||||
|
-- Table structure for table `roles`
|
||||||
|
CREATE TABLE `roles` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255) NOT NULL UNIQUE,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Seed default roles
|
||||||
|
INSERT INTO `roles` (`name`) VALUES ('Super-Admin'), ('Event Organizer'), ('Vendor'), ('Guest');
|
||||||
|
|
||||||
|
-- Table structure for table `users`
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`username` varchar(50) NOT NULL,
|
||||||
|
`password` varchar(255) NOT NULL,
|
||||||
|
`role_id` int(11) NOT NULL,
|
||||||
|
`created_at` datetime DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `username` (`username`),
|
||||||
|
FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `venues`
|
||||||
|
CREATE TABLE `venues` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`capacity` INT,
|
||||||
|
`amenities` TEXT,
|
||||||
|
`availability` BOOLEAN DEFAULT TRUE,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `vendors`
|
||||||
|
CREATE TABLE `vendors` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`service_type` VARCHAR(255),
|
||||||
|
`contact_info` VARCHAR(255),
|
||||||
|
`rating` DECIMAL(3, 2),
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `events`
|
||||||
|
CREATE TABLE `events` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`organizer_id` INT NOT NULL,
|
||||||
|
`venue_id` INT,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`description` TEXT,
|
||||||
|
`start_time` DATETIME,
|
||||||
|
`end_time` DATETIME,
|
||||||
|
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (`organizer_id`) REFERENCES `users`(`id`),
|
||||||
|
FOREIGN KEY (`venue_id`) REFERENCES `venues`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_schedules`
|
||||||
|
CREATE TABLE `event_schedules` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`activity` VARCHAR(255) NOT NULL,
|
||||||
|
`start_time` DATETIME NOT NULL,
|
||||||
|
`end_time` DATETIME NOT NULL,
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_guests`
|
||||||
|
CREATE TABLE `event_guests` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`user_id` INT,
|
||||||
|
`name` VARCHAR(255) NOT NULL,
|
||||||
|
`email` VARCHAR(255),
|
||||||
|
`rsvp_status` ENUM('attending', 'not_attending', 'maybe') NOT NULL,
|
||||||
|
`meal_preference` VARCHAR(255),
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_budgets`
|
||||||
|
CREATE TABLE `event_budgets` (
|
||||||
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`item_name` VARCHAR(255) NOT NULL,
|
||||||
|
`estimated_cost` DECIMAL(10, 2) NOT NULL,
|
||||||
|
`actual_cost` DECIMAL(10, 2),
|
||||||
|
`paid_status` BOOLEAN DEFAULT FALSE,
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
-- Table structure for table `event_vendors`
|
||||||
|
CREATE TABLE `event_vendors` (
|
||||||
|
`event_id` INT NOT NULL,
|
||||||
|
`vendor_id` INT NOT NULL,
|
||||||
|
PRIMARY KEY (`event_id`, `vendor_id`),
|
||||||
|
FOREIGN KEY (`event_id`) REFERENCES `events`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`vendor_id`) REFERENCES `vendors`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
0
db/migrations/002_add_event_management_tables.sql
Normal file
0
db/migrations/002_add_event_management_tables.sql
Normal file
Loading…
x
Reference in New Issue
Block a user