-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-guests-table.sql
More file actions
26 lines (25 loc) · 1.16 KB
/
create-guests-table.sql
File metadata and controls
26 lines (25 loc) · 1.16 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
-- Create guests table
CREATE TABLE IF NOT EXISTS `guests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password_hash` varchar(255) NOT NULL,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`phone` varchar(20) DEFAULT NULL,
`date_of_birth` date DEFAULT NULL,
`nationality` varchar(100) DEFAULT NULL,
`passport_number` varchar(50) DEFAULT NULL,
`preferences` json DEFAULT NULL,
`is_active` tinyint(1) DEFAULT 1,
`last_login` datetime DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `idx_is_active` (`is_active`),
KEY `idx_last_login` (`last_login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Add foreign key constraint to concierge_requests table if it exists
-- This assumes the concierge_requests table already has a guest_id column
-- ALTER TABLE `concierge_requests` ADD CONSTRAINT `fk_concierge_requests_guest_id`
-- FOREIGN KEY (`guest_id`) REFERENCES `guests` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;