· 6 years ago · Aug 13, 2019, 01:44 PM
1CREATE TABLE IF NOT EXISTS `clients` (
2 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
3 `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
4 `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
5 `email_verified_at` timestamp NULL DEFAULT NULL,
6 `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
7 `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
8 `created_at` timestamp NULL DEFAULT NULL,
9 `updated_at` timestamp NULL DEFAULT NULL,
10 PRIMARY KEY (`id`),
11 UNIQUE KEY `clients_email_unique` (`email`)
12) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
13
14CREATE TABLE IF NOT EXISTS `orders` (
15 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
16 `client_id` bigint(20) unsigned NOT NULL,
17 `status` enum('reserved','paid','canceled') COLLATE utf8mb4_unicode_ci NOT NULL,
18 `payment` enum('creditcard','money','boleto') COLLATE utf8mb4_unicode_ci NOT NULL,
19 `payment_token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
20 `payment_status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
21 `created_at` timestamp NULL DEFAULT NULL,
22 `updated_at` timestamp NULL DEFAULT NULL,
23 `deleted_at` timestamp NULL DEFAULT NULL,
24 PRIMARY KEY (`id`),
25 KEY `orders_client_id_foreign` (`client_id`),
26 CONSTRAINT `orders_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`)
27) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
28
29CREATE TABLE IF NOT EXISTS `reservations` (
30 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
31 `order_id` bigint(20) unsigned NOT NULL,
32 `room_id` bigint(20) unsigned NOT NULL,
33 `data` date NOT NULL,
34 `period` enum('morning','afternoon','fulltime') COLLATE utf8mb4_unicode_ci NOT NULL,
35 `price` decimal(6,2) NOT NULL DEFAULT '0.00',
36 `created_at` timestamp NULL DEFAULT NULL,
37 `updated_at` timestamp NULL DEFAULT NULL,
38 PRIMARY KEY (`id`),
39 KEY `reservations_order_id_foreign` (`order_id`),
40 KEY `reservations_room_id_foreign` (`room_id`),
41 CONSTRAINT `reservations_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
42 CONSTRAINT `reservations_room_id_foreign` FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`)
43) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
44
45CREATE TABLE IF NOT EXISTS `rooms` (
46 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
47 `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
48 `room` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
49 `price` double(6,2) NOT NULL DEFAULT '0.00',
50 `description` text COLLATE utf8mb4_unicode_ci NOT NULL,
51 `active` enum('Y','N') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Y',
52 `deleted_at` timestamp NULL DEFAULT NULL,
53 `created_at` timestamp NULL DEFAULT NULL,
54 `updated_at` timestamp NULL DEFAULT NULL,
55 PRIMARY KEY (`id`),
56 UNIQUE KEY `rooms_slug_unique` (`slug`)
57) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;