-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetternet4.1.sql
174 lines (161 loc) · 8.04 KB
/
betternet4.1.sql
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
-- Disable foreign key checks to avoid issues during table creation
SET FOREIGN_KEY_CHECKS = 0;
-- Create `users` table
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`role` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user',
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`stripe_id` varchar(125) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`pm_type` varchar(125) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`pm_last_four` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`trial_ends_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`),
KEY `users_stripe_id_index` (`stripe_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `tickets` table
CREATE TABLE IF NOT EXISTS `tickets` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`number` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`subject` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`message` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`priority` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` bigint unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tickets_number_unique` (`number`),
KEY `tickets_user_id_foreign` (`user_id`),
CONSTRAINT `tickets_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `comments` table
CREATE TABLE IF NOT EXISTS `comments` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`comment` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` bigint unsigned NOT NULL,
`ticket_id` bigint unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `comments_user_id_foreign` (`user_id`),
KEY `comments_ticket_id_foreign` (`ticket_id`),
CONSTRAINT `comments_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`),
CONSTRAINT `comments_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `billings` table
CREATE TABLE IF NOT EXISTS `billings` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`invoice` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`package_name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`package_price` int unsigned NOT NULL,
`package_start` date NOT NULL,
`user_id` bigint unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `billings_user_id_foreign` (`user_id`),
CONSTRAINT `billings_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `payments` table
CREATE TABLE IF NOT EXISTS `payments` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`invoice` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`payment_method` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`package_price` int unsigned NOT NULL,
`user_id` bigint unsigned NOT NULL,
`billing_id` bigint unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `payments_user_id_foreign` (`user_id`),
KEY `payments_billing_id_foreign` (`billing_id`),
CONSTRAINT `payments_billing_id_foreign` FOREIGN KEY (`billing_id`) REFERENCES `billings` (`id`),
CONSTRAINT `payments_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `companies` table
CREATE TABLE IF NOT EXISTS `companies` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`address` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `details` table
CREATE TABLE IF NOT EXISTS `details` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`dob` date NOT NULL,
`pin` varchar(125) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`router_password` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`package_name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`package_price` int unsigned NOT NULL,
`package_start` date NOT NULL,
`due` int unsigned NOT NULL,
`status` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
`user_id` bigint unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`router_name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `details_user_id_foreign` (`user_id`),
CONSTRAINT `details_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `failed_jobs` table
CREATE TABLE IF NOT EXISTS `failed_jobs` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`uuid` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `subscriptions` table
CREATE TABLE IF NOT EXISTS `subscriptions` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint unsigned NOT NULL,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`stripe_id` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`stripe_status` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`stripe_price` varchar(125) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`quantity` int DEFAULT NULL,
`trial_ends_at` timestamp NULL DEFAULT NULL,
`ends_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `subscriptions_stripe_id_unique` (`stripe_id`),
KEY `subscriptions_user_id_stripe_status_index` (`user_id`,`stripe_status`),
CONSTRAINT `subscriptions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create `personal_access_tokens` table
CREATE TABLE IF NOT EXISTS `personal_access_tokens` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tokenable_type` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`tokenable_id` bigint unsigned NOT NULL,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`abilities` text COLLATE utf8mb4_unicode_ci,
`last_used_at` timestamp NULL DEFAULT NULL,
`expires_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Enable foreign key checks after creating all tables
SET FOREIGN_KEY_CHECKS = 1;