· 4 years ago · Mar 15, 2021, 09:48 PM
1-- phpMyAdmin SQL Dump
2-- version 4.9.2
3-- https://www.phpmyadmin.net/
4--
5-- Host: 127.0.0.1:3306
6-- Generation Time: Mar 15, 2021 at 09:41 PM
7-- Server version: 10.4.10-MariaDB
8-- PHP Version: 7.3.12
9
10SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11SET AUTOCOMMIT = 0;
12START TRANSACTION;
13SET time_zone = "+00:00";
14
15
16/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19/*!40101 SET NAMES utf8mb4 */;
20
21--
22-- Database: `flarumclean`
23--
24
25-- --------------------------------------------------------
26
27--
28-- Table structure for table `access_tokens`
29--
30
31DROP TABLE IF EXISTS `access_tokens`;
32CREATE TABLE IF NOT EXISTS `access_tokens` (
33 `token` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
34 `user_id` int(10) UNSIGNED NOT NULL,
35 `last_activity_at` datetime NOT NULL,
36 `lifetime_seconds` int(11) NOT NULL,
37 `created_at` datetime NOT NULL,
38 PRIMARY KEY (`token`),
39 KEY `access_tokens_user_id_foreign` (`user_id`)
40) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
41
42-- --------------------------------------------------------
43
44--
45-- Table structure for table `api_keys`
46--
47
48DROP TABLE IF EXISTS `api_keys`;
49CREATE TABLE IF NOT EXISTS `api_keys` (
50 `key` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
51 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
52 `allowed_ips` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
53 `scopes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
54 `user_id` int(10) UNSIGNED DEFAULT NULL,
55 `created_at` datetime NOT NULL,
56 `last_activity_at` datetime DEFAULT NULL,
57 PRIMARY KEY (`id`),
58 UNIQUE KEY `api_keys_key_unique` (`key`),
59 KEY `api_keys_user_id_foreign` (`user_id`)
60) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
61
62-- --------------------------------------------------------
63
64--
65-- Table structure for table `discussions`
66--
67
68DROP TABLE IF EXISTS `discussions`;
69CREATE TABLE IF NOT EXISTS `discussions` (
70 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
71 `title` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
72 `comment_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
73 `participant_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
74 `post_number_index` int(10) UNSIGNED NOT NULL DEFAULT 0,
75 `created_at` datetime NOT NULL,
76 `user_id` int(10) UNSIGNED DEFAULT NULL,
77 `first_post_id` int(10) UNSIGNED DEFAULT NULL,
78 `last_posted_at` datetime DEFAULT NULL,
79 `last_posted_user_id` int(10) UNSIGNED DEFAULT NULL,
80 `last_post_id` int(10) UNSIGNED DEFAULT NULL,
81 `last_post_number` int(10) UNSIGNED DEFAULT NULL,
82 `hidden_at` datetime DEFAULT NULL,
83 `hidden_user_id` int(10) UNSIGNED DEFAULT NULL,
84 `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
85 `is_private` tinyint(1) NOT NULL DEFAULT 0,
86 PRIMARY KEY (`id`),
87 KEY `discussions_hidden_user_id_foreign` (`hidden_user_id`),
88 KEY `discussions_first_post_id_foreign` (`first_post_id`),
89 KEY `discussions_last_post_id_foreign` (`last_post_id`),
90 KEY `discussions_last_posted_at_index` (`last_posted_at`),
91 KEY `discussions_last_posted_user_id_index` (`last_posted_user_id`),
92 KEY `discussions_created_at_index` (`created_at`),
93 KEY `discussions_user_id_index` (`user_id`),
94 KEY `discussions_comment_count_index` (`comment_count`),
95 KEY `discussions_participant_count_index` (`participant_count`),
96 KEY `discussions_hidden_at_index` (`hidden_at`)
97) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
98
99-- --------------------------------------------------------
100
101--
102-- Table structure for table `discussion_user`
103--
104
105DROP TABLE IF EXISTS `discussion_user`;
106CREATE TABLE IF NOT EXISTS `discussion_user` (
107 `user_id` int(10) UNSIGNED NOT NULL,
108 `discussion_id` int(10) UNSIGNED NOT NULL,
109 `last_read_at` datetime DEFAULT NULL,
110 `last_read_post_number` int(10) UNSIGNED DEFAULT NULL,
111 PRIMARY KEY (`user_id`,`discussion_id`),
112 KEY `discussion_user_discussion_id_foreign` (`discussion_id`)
113) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
114
115-- --------------------------------------------------------
116
117--
118-- Table structure for table `email_tokens`
119--
120
121DROP TABLE IF EXISTS `email_tokens`;
122CREATE TABLE IF NOT EXISTS `email_tokens` (
123 `token` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
124 `email` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
125 `user_id` int(10) UNSIGNED NOT NULL,
126 `created_at` datetime DEFAULT NULL,
127 PRIMARY KEY (`token`),
128 KEY `email_tokens_user_id_foreign` (`user_id`)
129) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
130
131-- --------------------------------------------------------
132
133--
134-- Table structure for table `groups`
135--
136
137DROP TABLE IF EXISTS `groups`;
138CREATE TABLE IF NOT EXISTS `groups` (
139 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
140 `name_singular` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
141 `name_plural` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
142 `color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
143 `icon` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
144 PRIMARY KEY (`id`)
145) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
146
147--
148-- Dumping data for table `groups`
149--
150
151INSERT INTO `groups` (`id`, `name_singular`, `name_plural`, `color`, `icon`) VALUES
152(1, 'Admin', 'Admins', '#B72A2A', 'fas fa-wrench'),
153(2, 'Guest', 'Guests', NULL, NULL),
154(3, 'Member', 'Members', NULL, NULL),
155(4, 'Mod', 'Mods', '#80349E', 'fas fa-bolt');
156
157-- --------------------------------------------------------
158
159--
160-- Table structure for table `group_permission`
161--
162
163DROP TABLE IF EXISTS `group_permission`;
164CREATE TABLE IF NOT EXISTS `group_permission` (
165 `group_id` int(10) UNSIGNED NOT NULL,
166 `permission` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
167 PRIMARY KEY (`group_id`,`permission`)
168) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
169
170--
171-- Dumping data for table `group_permission`
172--
173
174INSERT INTO `group_permission` (`group_id`, `permission`) VALUES
175(2, 'viewDiscussions'),
176(3, 'discussion.reply'),
177(3, 'startDiscussion'),
178(3, 'viewUserList'),
179(4, 'discussion.editPosts'),
180(4, 'discussion.hide'),
181(4, 'discussion.hidePosts'),
182(4, 'discussion.rename'),
183(4, 'discussion.viewIpsPosts'),
184(4, 'user.viewLastSeenAt');
185
186-- --------------------------------------------------------
187
188--
189-- Table structure for table `group_user`
190--
191
192DROP TABLE IF EXISTS `group_user`;
193CREATE TABLE IF NOT EXISTS `group_user` (
194 `user_id` int(10) UNSIGNED NOT NULL,
195 `group_id` int(10) UNSIGNED NOT NULL,
196 PRIMARY KEY (`user_id`,`group_id`),
197 KEY `group_user_group_id_foreign` (`group_id`)
198) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
199
200-- --------------------------------------------------------
201
202--
203-- Table structure for table `login_providers`
204--
205
206DROP TABLE IF EXISTS `login_providers`;
207CREATE TABLE IF NOT EXISTS `login_providers` (
208 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
209 `user_id` int(10) UNSIGNED NOT NULL,
210 `provider` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
211 `identifier` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
212 `created_at` datetime DEFAULT NULL,
213 `last_login_at` datetime DEFAULT NULL,
214 PRIMARY KEY (`id`),
215 UNIQUE KEY `login_providers_provider_identifier_unique` (`provider`,`identifier`),
216 KEY `login_providers_user_id_foreign` (`user_id`)
217) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
218
219-- --------------------------------------------------------
220
221--
222-- Table structure for table `migrations`
223--
224
225DROP TABLE IF EXISTS `migrations`;
226CREATE TABLE IF NOT EXISTS `migrations` (
227 `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
228 `extension` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
229) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
230
231--
232-- Dumping data for table `migrations`
233--
234
235INSERT INTO `migrations` (`migration`, `extension`) VALUES
236('2015_02_24_000000_create_access_tokens_table', NULL),
237('2015_02_24_000000_create_api_keys_table', NULL),
238('2015_02_24_000000_create_config_table', NULL),
239('2015_02_24_000000_create_discussions_table', NULL),
240('2015_02_24_000000_create_email_tokens_table', NULL),
241('2015_02_24_000000_create_groups_table', NULL),
242('2015_02_24_000000_create_notifications_table', NULL),
243('2015_02_24_000000_create_password_tokens_table', NULL),
244('2015_02_24_000000_create_permissions_table', NULL),
245('2015_02_24_000000_create_posts_table', NULL),
246('2015_02_24_000000_create_users_discussions_table', NULL),
247('2015_02_24_000000_create_users_groups_table', NULL),
248('2015_02_24_000000_create_users_table', NULL),
249('2015_09_15_000000_create_auth_tokens_table', NULL),
250('2015_09_20_224327_add_hide_to_discussions', NULL),
251('2015_09_22_030432_rename_notification_read_time', NULL),
252('2015_10_07_130531_rename_config_to_settings', NULL),
253('2015_10_24_194000_add_ip_address_to_posts', NULL),
254('2015_12_05_042721_change_access_tokens_columns', NULL),
255('2015_12_17_194247_change_settings_value_column_to_text', NULL),
256('2016_02_04_095452_add_slug_to_discussions', NULL),
257('2017_04_07_114138_add_is_private_to_discussions', NULL),
258('2017_04_07_114138_add_is_private_to_posts', NULL),
259('2018_01_11_093900_change_access_tokens_columns', NULL),
260('2018_01_11_094000_change_access_tokens_add_foreign_keys', NULL),
261('2018_01_11_095000_change_api_keys_columns', NULL),
262('2018_01_11_101800_rename_auth_tokens_to_registration_tokens', NULL),
263('2018_01_11_102000_change_registration_tokens_rename_id_to_token', NULL),
264('2018_01_11_102100_change_registration_tokens_created_at_to_datetime', NULL),
265('2018_01_11_120604_change_posts_table_to_innodb', NULL),
266('2018_01_11_155200_change_discussions_rename_columns', NULL),
267('2018_01_11_155300_change_discussions_add_foreign_keys', NULL),
268('2018_01_15_071700_rename_users_discussions_to_discussion_user', NULL),
269('2018_01_15_071800_change_discussion_user_rename_columns', NULL),
270('2018_01_15_071900_change_discussion_user_add_foreign_keys', NULL),
271('2018_01_15_072600_change_email_tokens_rename_id_to_token', NULL),
272('2018_01_15_072700_change_email_tokens_add_foreign_keys', NULL),
273('2018_01_15_072800_change_email_tokens_created_at_to_datetime', NULL),
274('2018_01_18_130400_rename_permissions_to_group_permission', NULL),
275('2018_01_18_130500_change_group_permission_add_foreign_keys', NULL),
276('2018_01_18_130600_rename_users_groups_to_group_user', NULL),
277('2018_01_18_130700_change_group_user_add_foreign_keys', NULL),
278('2018_01_18_133000_change_notifications_columns', NULL),
279('2018_01_18_133100_change_notifications_add_foreign_keys', NULL),
280('2018_01_18_134400_change_password_tokens_rename_id_to_token', NULL),
281('2018_01_18_134500_change_password_tokens_add_foreign_keys', NULL),
282('2018_01_18_134600_change_password_tokens_created_at_to_datetime', NULL),
283('2018_01_18_135000_change_posts_rename_columns', NULL),
284('2018_01_18_135100_change_posts_add_foreign_keys', NULL),
285('2018_01_30_112238_add_fulltext_index_to_discussions_title', NULL),
286('2018_01_30_220100_create_post_user_table', NULL),
287('2018_01_30_222900_change_users_rename_columns', NULL),
288('2018_07_21_000000_seed_default_groups', NULL),
289('2018_07_21_000100_seed_default_group_permissions', NULL),
290('2018_09_15_041340_add_users_indicies', NULL),
291('2018_09_15_041828_add_discussions_indicies', NULL),
292('2018_09_15_043337_add_notifications_indices', NULL),
293('2018_09_15_043621_add_posts_indices', NULL),
294('2018_09_22_004100_change_registration_tokens_columns', NULL),
295('2018_09_22_004200_create_login_providers_table', NULL),
296('2018_10_08_144700_add_shim_prefix_to_group_icons', NULL);
297
298-- --------------------------------------------------------
299
300--
301-- Table structure for table `notifications`
302--
303
304DROP TABLE IF EXISTS `notifications`;
305CREATE TABLE IF NOT EXISTS `notifications` (
306 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
307 `user_id` int(10) UNSIGNED NOT NULL,
308 `from_user_id` int(10) UNSIGNED DEFAULT NULL,
309 `type` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
310 `subject_id` int(10) UNSIGNED DEFAULT NULL,
311 `data` blob DEFAULT NULL,
312 `created_at` datetime NOT NULL,
313 `is_deleted` tinyint(1) NOT NULL DEFAULT 0,
314 `read_at` datetime DEFAULT NULL,
315 PRIMARY KEY (`id`),
316 KEY `notifications_from_user_id_foreign` (`from_user_id`),
317 KEY `notifications_user_id_index` (`user_id`)
318) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
319
320-- --------------------------------------------------------
321
322--
323-- Table structure for table `password_tokens`
324--
325
326DROP TABLE IF EXISTS `password_tokens`;
327CREATE TABLE IF NOT EXISTS `password_tokens` (
328 `token` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
329 `user_id` int(10) UNSIGNED NOT NULL,
330 `created_at` datetime DEFAULT NULL,
331 PRIMARY KEY (`token`),
332 KEY `password_tokens_user_id_foreign` (`user_id`)
333) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
334
335-- --------------------------------------------------------
336
337--
338-- Table structure for table `posts`
339--
340
341DROP TABLE IF EXISTS `posts`;
342CREATE TABLE IF NOT EXISTS `posts` (
343 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
344 `discussion_id` int(10) UNSIGNED NOT NULL,
345 `number` int(10) UNSIGNED DEFAULT NULL,
346 `created_at` datetime NOT NULL,
347 `user_id` int(10) UNSIGNED DEFAULT NULL,
348 `type` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
349 `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT ' ',
350 `edited_at` datetime DEFAULT NULL,
351 `edited_user_id` int(10) UNSIGNED DEFAULT NULL,
352 `hidden_at` datetime DEFAULT NULL,
353 `hidden_user_id` int(10) UNSIGNED DEFAULT NULL,
354 `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
355 `is_private` tinyint(1) NOT NULL DEFAULT 0,
356 PRIMARY KEY (`id`),
357 UNIQUE KEY `posts_discussion_id_number_unique` (`discussion_id`,`number`),
358 KEY `posts_edited_user_id_foreign` (`edited_user_id`),
359 KEY `posts_hidden_user_id_foreign` (`hidden_user_id`),
360 KEY `posts_discussion_id_number_index` (`discussion_id`,`number`),
361 KEY `posts_discussion_id_created_at_index` (`discussion_id`,`created_at`),
362 KEY `posts_user_id_created_at_index` (`user_id`,`created_at`)
363) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
364
365-- --------------------------------------------------------
366
367--
368-- Table structure for table `post_user`
369--
370
371DROP TABLE IF EXISTS `post_user`;
372CREATE TABLE IF NOT EXISTS `post_user` (
373 `post_id` int(10) UNSIGNED NOT NULL,
374 `user_id` int(10) UNSIGNED NOT NULL,
375 PRIMARY KEY (`post_id`,`user_id`),
376 KEY `post_user_user_id_foreign` (`user_id`)
377) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
378
379-- --------------------------------------------------------
380
381--
382-- Table structure for table `registration_tokens`
383--
384
385DROP TABLE IF EXISTS `registration_tokens`;
386CREATE TABLE IF NOT EXISTS `registration_tokens` (
387 `token` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
388 `payload` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
389 `created_at` datetime DEFAULT NULL,
390 `provider` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
391 `identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
392 `user_attributes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
393 PRIMARY KEY (`token`)
394) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
395
396-- --------------------------------------------------------
397
398--
399-- Table structure for table `settings`
400--
401
402DROP TABLE IF EXISTS `settings`;
403CREATE TABLE IF NOT EXISTS `settings` (
404 `key` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
405 `value` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
406 PRIMARY KEY (`key`)
407) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
408
409-- --------------------------------------------------------
410
411--
412-- Table structure for table `users`
413--
414
415DROP TABLE IF EXISTS `users`;
416CREATE TABLE IF NOT EXISTS `users` (
417 `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
418 `username` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
419 `email` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
420 `is_email_confirmed` tinyint(1) NOT NULL DEFAULT 0,
421 `password` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
422 `avatar_url` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
423 `preferences` blob DEFAULT NULL,
424 `joined_at` datetime DEFAULT NULL,
425 `last_seen_at` datetime DEFAULT NULL,
426 `marked_all_as_read_at` datetime DEFAULT NULL,
427 `read_notifications_at` datetime DEFAULT NULL,
428 `discussion_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
429 `comment_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
430 PRIMARY KEY (`id`),
431 UNIQUE KEY `users_username_unique` (`username`),
432 UNIQUE KEY `users_email_unique` (`email`),
433 KEY `users_joined_at_index` (`joined_at`),
434 KEY `users_last_seen_at_index` (`last_seen_at`),
435 KEY `users_discussion_count_index` (`discussion_count`),
436 KEY `users_comment_count_index` (`comment_count`)
437) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
438
439--
440-- Indexes for dumped tables
441--
442
443--
444-- Indexes for table `discussions`
445--
446ALTER TABLE `discussions` ADD FULLTEXT KEY `title` (`title`);
447
448--
449-- Indexes for table `posts`
450--
451ALTER TABLE `posts` ADD FULLTEXT KEY `content` (`content`);
452
453--
454-- Constraints for dumped tables
455--
456
457--
458-- Constraints for table `access_tokens`
459--
460ALTER TABLE `access_tokens`
461 ADD CONSTRAINT `access_tokens_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
462
463--
464-- Constraints for table `api_keys`
465--
466ALTER TABLE `api_keys`
467 ADD CONSTRAINT `api_keys_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
468
469--
470-- Constraints for table `discussions`
471--
472ALTER TABLE `discussions`
473 ADD CONSTRAINT `discussions_first_post_id_foreign` FOREIGN KEY (`first_post_id`) REFERENCES `posts` (`id`) ON DELETE SET NULL,
474 ADD CONSTRAINT `discussions_hidden_user_id_foreign` FOREIGN KEY (`hidden_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
475 ADD CONSTRAINT `discussions_last_post_id_foreign` FOREIGN KEY (`last_post_id`) REFERENCES `posts` (`id`) ON DELETE SET NULL,
476 ADD CONSTRAINT `discussions_last_posted_user_id_foreign` FOREIGN KEY (`last_posted_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
477 ADD CONSTRAINT `discussions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
478
479--
480-- Constraints for table `discussion_user`
481--
482ALTER TABLE `discussion_user`
483 ADD CONSTRAINT `discussion_user_discussion_id_foreign` FOREIGN KEY (`discussion_id`) REFERENCES `discussions` (`id`) ON DELETE CASCADE,
484 ADD CONSTRAINT `discussion_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
485
486--
487-- Constraints for table `email_tokens`
488--
489ALTER TABLE `email_tokens`
490 ADD CONSTRAINT `email_tokens_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
491
492--
493-- Constraints for table `group_permission`
494--
495ALTER TABLE `group_permission`
496 ADD CONSTRAINT `group_permission_group_id_foreign` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE;
497
498--
499-- Constraints for table `group_user`
500--
501ALTER TABLE `group_user`
502 ADD CONSTRAINT `group_user_group_id_foreign` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE,
503 ADD CONSTRAINT `group_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
504
505--
506-- Constraints for table `login_providers`
507--
508ALTER TABLE `login_providers`
509 ADD CONSTRAINT `login_providers_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
510
511--
512-- Constraints for table `notifications`
513--
514ALTER TABLE `notifications`
515 ADD CONSTRAINT `notifications_from_user_id_foreign` FOREIGN KEY (`from_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
516 ADD CONSTRAINT `notifications_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
517
518--
519-- Constraints for table `password_tokens`
520--
521ALTER TABLE `password_tokens`
522 ADD CONSTRAINT `password_tokens_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
523
524--
525-- Constraints for table `posts`
526--
527ALTER TABLE `posts`
528 ADD CONSTRAINT `posts_edited_user_id_foreign` FOREIGN KEY (`edited_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
529 ADD CONSTRAINT `posts_hidden_user_id_foreign` FOREIGN KEY (`hidden_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
530 ADD CONSTRAINT `posts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
531
532--
533-- Constraints for table `post_user`
534--
535ALTER TABLE `post_user`
536 ADD CONSTRAINT `post_user_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
537 ADD CONSTRAINT `post_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
538COMMIT;
539
540/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
541/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
542/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
543