Skip to content

Instantly share code, notes, and snippets.

@ArtOfCode-
Created November 20, 2019 22:04
Show Gist options
  • Save ArtOfCode-/cb8f14e7727f3543589f0377528e5ba8 to your computer and use it in GitHub Desktop.
Save ArtOfCode-/cb8f14e7727f3543589f0377528e5ba8 to your computer and use it in GitHub Desktop.
CREATE TABLE `ar_internal_metadata` (
`key` varchar(255) NOT NULL,
`value` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`post_id` int(11) DEFAULT NULL,
`content` varchar(255) DEFAULT NULL,
`deleted` tinyint(1) DEFAULT '0',
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_comments_on_post_type_and_post_id` (`post_id`) USING BTREE,
KEY `index_comments_on_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `flag_statuses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`result` varchar(255) DEFAULT NULL,
`message` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`flag_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_flag_statuses_on_flag_id` (`flag_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `flags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`reason` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` int(11) DEFAULT NULL,
`post_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_flags_on_post_type_and_post_id` (`post_id`) USING BTREE,
KEY `index_flags_on_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `notifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` varchar(255) DEFAULT NULL,
`link` varchar(255) DEFAULT NULL,
`is_read` tinyint(1) DEFAULT '0',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_notifications_on_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
CREATE TABLE `post_histories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_history_type_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`post_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_post_histories_on_post_history_type_id` (`post_history_type_id`) USING BTREE,
KEY `index_post_histories_on_post_type_and_post_id` (`post_id`) USING BTREE,
KEY `index_post_histories_on_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
CREATE TABLE `post_history_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;
CREATE TABLE `post_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
CREATE TABLE `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`body` text NOT NULL,
`tags` varchar(255) DEFAULT NULL,
`score` int(11) NOT NULL DEFAULT '0',
`parent_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`closed` tinyint(1) NOT NULL DEFAULT '0',
`closed_by_id` int(11) DEFAULT NULL,
`closed_at` datetime DEFAULT NULL,
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`deleted_by_id` int(11) DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`post_type_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
CREATE TABLE `privileges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`name` varchar(255) DEFAULT NULL,
`threshold` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
CREATE TABLE `privileges_users` (
`privilege_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
KEY `index_privileges_users_on_privilege_id_and_user_id` (`privilege_id`,`user_id`) USING BTREE,
KEY `index_privileges_users_on_user_id_and_privilege_id` (`user_id`,`privilege_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `schema_migrations` (
`version` varchar(255) NOT NULL,
PRIMARY KEY (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `site_settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`value` text,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
CREATE TABLE `suspicious_votes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from_user_id` int(11) DEFAULT NULL,
`to_user_id` int(11) DEFAULT NULL,
`was_investigated` tinyint(1) DEFAULT '0',
`investigated_by` int(11) DEFAULT NULL,
`investigated_at` datetime DEFAULT NULL,
`suspicious_count` int(11) DEFAULT NULL,
`total_count` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL DEFAULT '',
`encrypted_password` varchar(255) NOT NULL DEFAULT '',
`reset_password_token` varchar(255) DEFAULT NULL,
`reset_password_sent_at` datetime DEFAULT NULL,
`remember_created_at` datetime DEFAULT NULL,
`sign_in_count` int(11) NOT NULL DEFAULT '0',
`current_sign_in_at` datetime DEFAULT NULL,
`last_sign_in_at` datetime DEFAULT NULL,
`current_sign_in_ip` varchar(255) DEFAULT NULL,
`last_sign_in_ip` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`is_moderator` tinyint(1) DEFAULT NULL,
`is_admin` tinyint(1) DEFAULT NULL,
`reputation` int(11) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_users_on_email` (`email`) USING BTREE,
UNIQUE KEY `index_users_on_reset_password_token` (`reset_password_token`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
CREATE TABLE `votes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vote_type` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` int(11) DEFAULT NULL,
`post_id` int(11) DEFAULT NULL,
`recv_user` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_votes_on_post_type_and_post_id` (`post_id`) USING BTREE,
KEY `index_votes_on_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment