Created
April 4, 2018 14:00
-
-
Save igoralves1/ab517de014a69ae3780979e8562a2889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/sql',function(){ | |
$sql=<<<EOF | |
-- ----------------------------------------------------- | |
-- Table `migrations` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `migrations` ( | |
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | |
`migration` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`batch` INT(11) NOT NULL, | |
PRIMARY KEY (`id`)) | |
ENGINE = InnoDB | |
AUTO_INCREMENT = 4; | |
-- ----------------------------------------------------- | |
-- Table `permissions` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `permissions` ( | |
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`guard_name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`created_at` TIMESTAMP NULL DEFAULT NULL, | |
`updated_at` TIMESTAMP NULL DEFAULT NULL, | |
PRIMARY KEY (`id`)) | |
ENGINE = InnoDB | |
AUTO_INCREMENT = 1; | |
-- ----------------------------------------------------- | |
-- Table `model_has_permissions` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `model_has_permissions` ( | |
`permission_id` INT(10) UNSIGNED NOT NULL, | |
`model_id` INT(10) UNSIGNED NOT NULL, | |
`model_type` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
PRIMARY KEY (`permission_id`, `model_id`, `model_type`), | |
INDEX `model_has_permissions_model_id_model_type_index` (`model_id` ASC, `model_type` ASC), | |
CONSTRAINT `model_has_permissions_permission_id_foreign` | |
FOREIGN KEY (`permission_id`) | |
REFERENCES `permissions` (`id`) | |
ON DELETE CASCADE) | |
ENGINE = InnoDB; | |
-- ----------------------------------------------------- | |
-- Table `roles` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `roles` ( | |
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`guard_name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`created_at` TIMESTAMP NULL DEFAULT NULL, | |
`updated_at` TIMESTAMP NULL DEFAULT NULL, | |
PRIMARY KEY (`id`)) | |
ENGINE = InnoDB | |
AUTO_INCREMENT = 1; | |
-- ----------------------------------------------------- | |
-- Table `model_has_roles` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `model_has_roles` ( | |
`role_id` INT(10) UNSIGNED NOT NULL, | |
`model_id` INT(10) UNSIGNED NOT NULL, | |
`model_type` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
PRIMARY KEY (`role_id`, `model_id`, `model_type`), | |
INDEX `model_has_roles_model_id_model_type_index` (`model_id` ASC, `model_type` ASC), | |
CONSTRAINT `model_has_roles_role_id_foreign` | |
FOREIGN KEY (`role_id`) | |
REFERENCES `roles` (`id`) | |
ON DELETE CASCADE) | |
ENGINE = InnoDB; | |
-- ----------------------------------------------------- | |
-- Table `password_resets` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `password_resets` ( | |
`email` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`token` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL, | |
`created_at` TIMESTAMP NULL DEFAULT NULL, | |
INDEX `password_resets_email_index` (`email` ASC)) | |
ENGINE = InnoDB; | |
-- ----------------------------------------------------- | |
-- Table `role_has_permissions` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `role_has_permissions` ( | |
`permission_id` INT(10) UNSIGNED NOT NULL, | |
`role_id` INT(10) UNSIGNED NOT NULL, | |
PRIMARY KEY (`permission_id`, `role_id`), | |
INDEX `role_has_permissions_role_id_foreign` (`role_id` ASC), | |
CONSTRAINT `role_has_permissions_permission_id_foreign` | |
FOREIGN KEY (`permission_id`) | |
REFERENCES `permissions` (`id`) | |
ON DELETE CASCADE, | |
CONSTRAINT `role_has_permissions_role_id_foreign` | |
FOREIGN KEY (`role_id`) | |
REFERENCES `roles` (`id`) | |
ON DELETE CASCADE) | |
ENGINE = InnoDB; | |
ALTER TABLE `users` ADD `name` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL; | |
ALTER TABLE `users` ADD `remember_token` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NULL DEFAULT NULL; | |
ALTER TABLE `users` ADD `password` VARCHAR(191) COLLATE 'utf8mb4_unicode_ci' NOT NULL; | |
ALTER TABLE `users` ADD `created_at` TIMESTAMP NULL DEFAULT NULL; | |
ALTER TABLE `users` ADD `updated_at` TIMESTAMP NULL DEFAULT NULL; | |
EOF; | |
return $sql; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment