· 8 years ago · Apr 12, 2018, 02:28 PM
1Route::get('/sql',function(){
2$sql=<<<EOF
3
4
5-- -----------------------------------------------------
6-- Table `migrations`
7-- -----------------------------------------------------
8CREATE TABLE IF NOT EXISTS `migrations` (
9 `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
10 `migration` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
11 `batch` INT(11) NOT NULL,
12 PRIMARY KEY (`id`))
13ENGINE = InnoDB
14AUTO_INCREMENT = 4;
15
16
17-- -----------------------------------------------------
18-- Table `permissions`
19-- -----------------------------------------------------
20CREATE TABLE IF NOT EXISTS `permissions` (
21 `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
22 `name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
23 `guard_name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
24 `created_at` TIMESTAMP NULL DEFAULT NULL,
25 `updated_at` TIMESTAMP NULL DEFAULT NULL,
26 PRIMARY KEY (`id`))
27ENGINE = InnoDB
28AUTO_INCREMENT = 1;
29
30
31-- -----------------------------------------------------
32-- Table `model_has_permissions`
33-- -----------------------------------------------------
34CREATE TABLE IF NOT EXISTS `model_has_permissions` (
35 `permission_id` INT(10) UNSIGNED NOT NULL,
36 `model_id` INT(10) UNSIGNED NOT NULL,
37 `model_type` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
38 PRIMARY KEY (`permission_id`, `model_id`, `model_type`),
39 INDEX `model_has_permissions_model_id_model_type_index` (`model_id` ASC, `model_type` ASC),
40 CONSTRAINT `model_has_permissions_permission_id_foreign`
41 FOREIGN KEY (`permission_id`)
42 REFERENCES `permissions` (`id`)
43 ON DELETE CASCADE)
44ENGINE = InnoDB;
45
46
47-- -----------------------------------------------------
48-- Table `roles`
49-- -----------------------------------------------------
50CREATE TABLE IF NOT EXISTS `roles` (
51 `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
52 `name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
53 `guard_name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
54 `created_at` TIMESTAMP NULL DEFAULT NULL,
55 `updated_at` TIMESTAMP NULL DEFAULT NULL,
56 PRIMARY KEY (`id`))
57ENGINE = InnoDB
58AUTO_INCREMENT = 1;
59
60
61-- -----------------------------------------------------
62-- Table `model_has_roles`
63-- -----------------------------------------------------
64CREATE TABLE IF NOT EXISTS `model_has_roles` (
65 `role_id` INT(10) UNSIGNED NOT NULL,
66 `model_id` INT(10) UNSIGNED NOT NULL,
67 `model_type` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
68 PRIMARY KEY (`role_id`, `model_id`, `model_type`),
69 INDEX `model_has_roles_model_id_model_type_index` (`model_id` ASC, `model_type` ASC),
70 CONSTRAINT `model_has_roles_role_id_foreign`
71 FOREIGN KEY (`role_id`)
72 REFERENCES `roles` (`id`)
73 ON DELETE CASCADE)
74ENGINE = InnoDB;
75
76
77-- -----------------------------------------------------
78-- Table `password_resets`
79-- -----------------------------------------------------
80CREATE TABLE IF NOT EXISTS `password_resets` (
81 `email` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
82 `token` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL,
83 `created_at` TIMESTAMP NULL DEFAULT NULL,
84 INDEX `password_resets_email_index` (`email` ASC))
85ENGINE = InnoDB;
86
87
88-- -----------------------------------------------------
89-- Table `role_has_permissions`
90-- -----------------------------------------------------
91CREATE TABLE IF NOT EXISTS `role_has_permissions` (
92 `permission_id` INT(10) UNSIGNED NOT NULL,
93 `role_id` INT(10) UNSIGNED NOT NULL,
94 PRIMARY KEY (`permission_id`, `role_id`),
95 INDEX `role_has_permissions_role_id_foreign` (`role_id` ASC),
96 CONSTRAINT `role_has_permissions_permission_id_foreign`
97 FOREIGN KEY (`permission_id`)
98 REFERENCES `permissions` (`id`)
99 ON DELETE CASCADE,
100 CONSTRAINT `role_has_permissions_role_id_foreign`
101 FOREIGN KEY (`role_id`)
102 REFERENCES `roles` (`id`)
103 ON DELETE CASCADE)
104ENGINE = InnoDB;
105
106ALTER TABLE `users` ADD `name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL;
107ALTER TABLE `users` ADD `remember_token` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NULL DEFAULT NULL;
108ALTER TABLE `users` ADD `password` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL;
109ALTER TABLE `users` ADD `created_at` TIMESTAMP NULL DEFAULT NULL;
110ALTER TABLE `users` ADD `updated_at` TIMESTAMP NULL DEFAULT NULL;
111
112
113EOF;
114
115
116
117
118 return $sql;
119});