-- https://www.phpmyadmin.net/
--

START TRANSACTION;



-- --------------------------------------------------------

--
-- Table structure for table `admin_role`
--

CREATE TABLE `admin_role` (
  `admin_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `admin_role`
--

INSERT INTO `admin_role` (`admin_id`, `role_id`) VALUES
(2, 1),
(6, 1),
(9, 1);

-- --------------------------------------------------------

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `name`, `slug`, `created_at`, `updated_at`) VALUES
(1, 'Category1', 'Category1', '2018-04-02 14:13:50', '2018-04-02 14:13:50'),
(2, 'Category2', 'Category2', '2018-04-02 14:14:02', '2018-04-02 14:14:02'),
(3, 'Category3', 'Category3', '2018-04-02 14:14:12', '2018-04-02 14:14:12'),
(4, 'Category4', 'Category4', '2018-04-02 14:14:25', '2018-04-02 14:14:25'),
(5, 'Category5', 'Category5', '2018-04-02 14:14:35', '2018-04-02 14:14:35');

-- --------------------------------------------------------

--
-- Table structure for table `category_posts`
--

CREATE TABLE `category_posts` (
  `post_id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `category_posts`
--

INSERT INTO `category_posts` (`post_id`, `category_id`, `created_at`, `updated_at`) VALUES
(1, 1, '2018-04-02 14:15:27', '2018-04-02 14:15:27'),
(2, 3, '2018-04-02 14:16:04', '2018-04-02 14:16:04'),
(2, 4, '2018-04-02 14:16:04', '2018-04-02 14:16:04'),
(3, 1, '2018-04-02 14:16:36', '2018-04-02 14:16:36'),
(3, 2, '2018-04-02 14:16:36', '2018-04-02 14:16:36');

-- --------------------------------------------------------

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(12, '2014_10_12_000000_create_users_table', 1),
(13, '2014_10_12_100000_create_password_resets_table', 1),
(14, '2018_03_11_193700_create_posts_table', 1),
(15, '2018_03_11_193723_create_categories_table', 1),
(16, '2018_03_11_193745_create_tags_table', 1),
(17, '2018_03_11_193808_create_category_posts_table', 1),
(18, '2018_03_11_193830_create_post_tags_table', 1),
(19, '2018_03_11_194016_create_admins_table', 1),
(20, '2018_04_02_083627_create_roles_table', 1),
(21, '2018_04_02_083648_create_permissions_table', 1),
(22, '2018_04_02_083705_create_admin_roles_table', 1);

-- --------------------------------------------------------

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `for` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `permissions`
--

INSERT INTO `permissions` (`id`, `name`, `for`, `created_at`, `updated_at`) VALUES
(1, 'POST-CREATE', 'post', '2018-04-02 12:00:42', '2018-04-02 12:00:42'),
(2, 'POST-UPDATE', 'post', '2018-04-02 12:01:16', '2018-04-02 12:01:16'),
(3, 'POST-DELETE', 'post', '2018-04-02 13:37:56', '2018-04-02 13:37:56'),
(4, 'POST-PUBLISH', 'post', '2018-04-02 13:38:16', '2018-04-02 13:38:16'),
(5, 'USER-CREATE', 'user', '2018-04-02 13:38:26', '2018-04-02 13:38:26'),
(6, 'USER-UPDATE', 'user', '2018-04-02 13:38:36', '2018-04-02 13:38:36'),
(7, 'USER-DELETE', 'user', '2018-04-02 13:38:51', '2018-04-02 13:38:51'),
(8, 'CATEGORY-CRUD', 'other', '2018-04-02 13:39:00', '2018-04-02 13:39:00'),
(9, 'TAG-CRUD', 'other', '2018-04-02 13:39:08', '2018-04-02 13:39:08');

-- --------------------------------------------------------

--
-- Table structure for table `permission_role`
--

CREATE TABLE `permission_role` (
  `role_id` int(11) NOT NULL,
  `permission_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `permission_role`
--

INSERT INTO `permission_role` (`role_id`, `permission_id`) VALUES
(1, 1),
(1, 2),
(2, 1),
(1, 3),
(1, 8),
(1, 9),
(2, 2),
(3, 3),
(3, 4),
(2, 8),
(2, 9);

-- --------------------------------------------------------

--
-- Table structure for table `posts`
--

CREATE TABLE `posts` (
  `id` int(10) UNSIGNED NOT NULL,
  `title` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subtitle` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `body` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` tinyint(1) DEFAULT NULL,
  `posted_by` int(11) DEFAULT NULL,
  `image` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `like` int(11) DEFAULT NULL,
  `dislike` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `posts`
--

INSERT INTO `posts` (`id`, `title`, `subtitle`, `slug`, `body`, `status`, `posted_by`, `image`, `like`, `dislike`, `created_at`, `updated_at`) VALUES
(1, 'Post1', 'Post1 Subtitle', 'Post1', 'dasgsgf', 1, NULL, 'noimage.jpg', NULL, NULL, '2018-04-02 14:15:27', '2018-04-02 14:15:27'),
(2, 'Post2', 'post2 Subtitle', 'post2', 'fghgdfgh', 1, NULL, 'Untitled_1522685763.png', NULL, NULL, '2018-04-02 14:16:04', '2018-04-02 14:16:04'),
(3, 'Post3', 'post3 subtitle', 'post3', 'sagfsrdg', NULL, NULL, 'noimage.jpg', NULL, NULL, '2018-04-02 14:16:36', '2018-04-02 14:16:36');

-- --------------------------------------------------------

--
-- Table structure for table `post_tags`
--

CREATE TABLE `post_tags` (
  `post_id` int(10) UNSIGNED NOT NULL,
  `tag_id` int(10) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `post_tags`
--

INSERT INTO `post_tags` (`post_id`, `tag_id`, `created_at`, `updated_at`) VALUES
(1, 1, '2018-04-02 14:15:27', '2018-04-02 14:15:27'),
(2, 3, '2018-04-02 14:16:04', '2018-04-02 14:16:04'),
(2, 4, '2018-04-02 14:16:04', '2018-04-02 14:16:04'),
(3, 1, '2018-04-02 14:16:36', '2018-04-02 14:16:36'),
(3, 2, '2018-04-02 14:16:36', '2018-04-02 14:16:36'),
(3, 3, '2018-04-02 14:16:36', '2018-04-02 14:16:36'),
(3, 4, '2018-04-02 14:16:36', '2018-04-02 14:16:36'),
(3, 5, '2018-04-02 14:16:36', '2018-04-02 14:16:36');

-- --------------------------------------------------------

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, 'Editor', '2018-04-02 12:02:38', '2018-04-02 12:02:38'),
(2, 'Writer', '2018-04-02 12:06:00', '2018-04-02 12:06:00'),
(3, 'Publisher', '2018-04-02 13:44:07', '2018-04-02 13:44:07');

-- --------------------------------------------------------

--
-- Table structure for table `tags`
--

CREATE TABLE `tags` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tags`
--

INSERT INTO `tags` (`id`, `name`, `slug`, `created_at`, `updated_at`) VALUES
(1, 'Tag1', 'Tag1', '2018-04-02 14:13:05', '2018-04-02 14:13:05'),
(2, 'Tag2', 'Tag2', '2018-04-02 14:13:18', '2018-04-02 14:13:18'),
(3, 'Tag3', 'Tag3', '2018-04-02 14:13:32', '2018-04-02 14:13:32'),
(4, 'Tag4', 'Tag4', '2018-04-02 14:14:48', '2018-04-02 14:14:48'),
(5, 'Tag5', 'Tag5', '2018-04-02 14:14:57', '2018-04-02 14:14:57');

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `category_posts`
--
ALTER TABLE `category_posts`
  ADD KEY `category_posts_post_id_index` (`post_id`),
  ADD KEY `category_posts_category_id_index` (`category_id`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `posts`
--
ALTER TABLE `posts`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `post_tags`
--
ALTER TABLE `post_tags`
  ADD KEY `post_tags_post_id_index` (`post_id`),
  ADD KEY `post_tags_tag_id_index` (`tag_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `tags`
--
ALTER TABLE `tags`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `posts`
--
ALTER TABLE `posts`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `tags`
--
ALTER TABLE `tags`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `category_posts`
--
ALTER TABLE `category_posts`
  ADD CONSTRAINT `category_posts_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `post_tags`
--
ALTER TABLE `post_tags`
  ADD CONSTRAINT `post_tags_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE;
COMMIT;

