1
0
Fork 0

Update schema

This commit is contained in:
Gregory Eremin 2015-04-06 22:29:24 +07:00
parent 86d503d622
commit 7bcab0002a
1 changed files with 52 additions and 43 deletions

View File

@ -2,77 +2,84 @@ DROP TABLE IF EXISTS `contribs`;
CREATE TABLE `contribs` ( CREATE TABLE `contribs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`week` int(11) unsigned NOT NULL, `week` int(11) unsigned NOT NULL,
`author` varchar(255) NOT NULL DEFAULT '', `org_id` int(11) unsigned NOT NULL,
`owner` varchar(255) NOT NULL DEFAULT '', `repo_id` int(11) unsigned NOT NULL,
`repo` varchar(255) NOT NULL DEFAULT '', `user_id` int(11) unsigned NOT NULL,
`commits` int(11) unsigned NOT NULL, `commits` int(11) unsigned NOT NULL,
`additions` int(11) unsigned NOT NULL, `additions` int(11) unsigned NOT NULL,
`deletions` int(11) unsigned NOT NULL, `deletions` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `week_author_repo` (`week`,`author`,`owner`,`repo`) UNIQUE KEY `record` (`week`,`org_id`,`repo_id`,`user_id`),
KEY `search` (`org_id`,`week`,`repo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `hooks`; DROP TABLE IF EXISTS `org_members`;
CREATE TABLE `hooks` ( CREATE TABLE `org_members` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`owner` varchar(255) NOT NULL DEFAULT '', `org_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`) `user_id` int(11) unsigned NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `members`;
CREATE TABLE `members` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`org` varchar(255) NOT NULL DEFAULT '',
`team_id` int(11) unsigned DEFAULT NULL,
`user` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `team` (`team_id`), UNIQUE KEY `membership` (`org_id`,`user_id`)
KEY `login` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `orgs`; DROP TABLE IF EXISTS `orgs`;
CREATE TABLE `orgs` ( CREATE TABLE `orgs` (
`login` varchar(255) NOT NULL DEFAULT '',
`descr` varchar(255) NOT NULL DEFAULT '',
`id` int(11) unsigned NOT NULL, `id` int(11) unsigned NOT NULL,
`login` varchar(255) NOT NULL DEFAULT '',
`company` varchar(255) NOT NULL DEFAULT '',
`avatar_url` varchar(255) NOT NULL DEFAULT '', `avatar_url` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`login`) `updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `login` (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `repos`; DROP TABLE IF EXISTS `repos`;
CREATE TABLE `repos` ( CREATE TABLE `repos` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL,
`owner` varchar(255) NOT NULL DEFAULT '', `org_id` int(11) unsigned NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '',
`updated_at` datetime DEFAULT NULL, `description` varchar(255) NOT NULL,
`is_private` tinyint(1) NOT NULL, `is_private` tinyint(1) NOT NULL,
`is_fork` tinyint(1) NOT NULL, `is_fork` tinyint(1) NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `owner_repo` (`owner`,`name`) UNIQUE KEY `owner_repo` (`org_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `tasks`; DROP TABLE IF EXISTS `team_members`;
CREATE TABLE `tasks` ( CREATE TABLE `team_members` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`token` varchar(255) DEFAULT '', `org_id` int(11) unsigned NOT NULL,
`owner` varchar(255) DEFAULT '', `team_id` int(11) unsigned NOT NULL,
`job` varchar(255) NOT NULL DEFAULT '', `user_id` int(11) unsigned NOT NULL,
`worker` varchar(36) NOT NULL DEFAULT '', PRIMARY KEY (`id`),
`duration` int(11) unsigned NOT NULL, UNIQUE KEY `membership` (`team_id`,`user_id`),
`error` varchar(255) DEFAULT NULL, KEY `search` (`org_id`,`user_id`),
`created_at` datetime NOT NULL, KEY `team_id` (`team_id`)
`started_at` datetime NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `team_repos`;
CREATE TABLE `team_repos` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`org_id` int(11) unsigned NOT NULL,
`team_id` int(11) unsigned NOT NULL,
`repo_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `access` (`team_id`,`repo_id`),
KEY `search` (`org_id`,`team_id`),
KEY `team_id` (`team_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `teams`; DROP TABLE IF EXISTS `teams`;
CREATE TABLE `teams` ( CREATE TABLE `teams` (
`id` int(11) unsigned NOT NULL, `id` int(11) unsigned NOT NULL,
`org_id` int(11) NOT NULL,
`slug` varchar(255) NOT NULL, `slug` varchar(255) NOT NULL,
`owner` varchar(255) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '', `permission` varchar(20) NOT NULL DEFAULT '',
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `owner` (`owner`) KEY `owner` (`org_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `tokens`; DROP TABLE IF EXISTS `tokens`;
@ -85,15 +92,17 @@ CREATE TABLE `tokens` (
`reset_at` datetime DEFAULT NULL, `reset_at` datetime DEFAULT NULL,
`created_at` datetime NOT NULL, `created_at` datetime NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `owner` (`user`) UNIQUE KEY `owner` (`user`),
UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `users`; DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` ( CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL,
`login` varchar(255) NOT NULL DEFAULT '', `login` varchar(255) NOT NULL DEFAULT '',
`name` varchar(255) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '',
`id` int(11) unsigned NOT NULL,
`avatar_url` varchar(255) NOT NULL DEFAULT '', `avatar_url` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`login`), `updated_at` datetime NOT NULL,
UNIQUE KEY `id` (`id`) PRIMARY KEY (`id`),
UNIQUE KEY `login` (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;