--  This file is a part of CodingTeam. Take a look at <http://codingteam.org>.
--  Copyright © 2007-2014 Erwan Briand <erwan@codingteam.net>
-- 
--  This program is free software: you can redistribute it and/or modify it
--  under the terms of the GNU Affero General Public License as published by
--  the Free Software Foundation, version 3 only.
-- 
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
--  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
--  License for more details.
-- 
--  You should have received a copy of the GNU Affero General Public License
--  along with this program. If not, see <http://www.gnu.org/licenses/>.

--
-- Table structure for table `config`
--

CREATE TABLE IF NOT EXISTS `config` (
  `group` varchar(42) COLLATE utf8_bin NOT NULL,
  `field` varchar(42) COLLATE utf8_bin NOT NULL,
  `value` tinytext COLLATE utf8_bin NOT NULL,
  `text` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `jabber_fortunes`
--

CREATE TABLE IF NOT EXISTS `jabber_fortunes` (
`id` int(11) NOT NULL,
  `vote` int(11) NOT NULL DEFAULT '0',
  `text` text COLLATE utf8_bin NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `messages`
--

CREATE TABLE IF NOT EXISTS `messages` (
`id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `recipient_id` int(11) NOT NULL,
  `datetime` datetime NOT NULL,
  `subject` tinytext COLLATE utf8_bin NOT NULL,
  `message` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `read_sender` tinyint(1) NOT NULL,
  `read_recipient` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `messages_answers`
--

CREATE TABLE IF NOT EXISTS `messages_answers` (
`id` int(11) NOT NULL,
  `pid` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `recipient_id` int(11) NOT NULL,
  `datetime` datetime NOT NULL,
  `message` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `read_sender` tinyint(1) NOT NULL,
  `read_recipient` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `notepad`
--

CREATE TABLE IF NOT EXISTS `notepad` (
`id` int(11) NOT NULL,
  `pid` int(11) NOT NULL,
  `title` tinytext COLLATE utf8_bin NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `language` tinytext COLLATE utf8_bin NOT NULL,
  `source` text COLLATE utf8_bin NOT NULL,
  `time` enum('d','m','f') COLLATE utf8_bin NOT NULL,
  `date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `notifications`
--

CREATE TABLE IF NOT EXISTS `notifications` (
`id` int(11) NOT NULL,
  `jabberid` tinytext COLLATE utf8_bin NOT NULL,
  `subject` tinytext COLLATE utf8_bin NOT NULL,
  `notification` text COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects`
--

CREATE TABLE IF NOT EXISTS `projects` (
`id` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `dbname` varchar(30) COLLATE utf8_bin NOT NULL,
  `website` tinytext COLLATE utf8_bin NOT NULL,
  `logo` tinytext COLLATE utf8_bin NOT NULL,
  `tags` tinytext COLLATE utf8_bin NOT NULL,
  `platforms` tinytext COLLATE utf8_bin NOT NULL,
  `languages` tinytext COLLATE utf8_bin NOT NULL,
  `translations` text COLLATE utf8_bin NOT NULL,
  `category` tinytext COLLATE utf8_bin NOT NULL,
  `license` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `oneline` tinytext COLLATE utf8_bin NOT NULL,
  `date` datetime NOT NULL,
  `userid` int(11) NOT NULL,
  `is_valid` tinyint(1) NOT NULL,
  `is_private` tinyint(1) NOT NULL,
  `mail_paypal` tinytext COLLATE utf8_bin NOT NULL,
  `cur_paypal` enum('USD','EUR') COLLATE utf8_bin NOT NULL,
  `downloads` int(11) NOT NULL DEFAULT '0',
  `popularity` int(11) NOT NULL DEFAULT '0',
  `scm` enum('git','mercurial','subversion') COLLATE utf8_bin NOT NULL,
  `features` tinytext COLLATE utf8_bin
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_admins`
--

CREATE TABLE IF NOT EXISTS `projects_admins` (
  `projectid` int(11) NOT NULL,
  `userid` int(11) NOT NULL,
  `role` enum('projectleader','graphicdesigner','developer','translater','packager','contributer') COLLATE utf8_bin NOT NULL,
  `powers` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_bugs`
--

CREATE TABLE IF NOT EXISTS `projects_bugs` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `version` varchar(15) COLLATE utf8_bin NOT NULL,
  `milestone` varchar(15) COLLATE utf8_bin NOT NULL,
  `priority` enum('blocker','critical','major','normal','minor','trivial') COLLATE utf8_bin NOT NULL,
  `type` enum('bugreport','featurerequest') COLLATE utf8_bin NOT NULL,
  `status` enum('unconfirmed','confirmed','working','needinformations','needcontributors','needtests','resolved','rejected') COLLATE utf8_bin NOT NULL,
  `assignedid` int(11) NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_bugs_answers`
--

CREATE TABLE IF NOT EXISTS `projects_bugs_answers` (
`id` int(11) NOT NULL,
  `bugid` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_bugs_attachements`
--

CREATE TABLE IF NOT EXISTS `projects_bugs_attachements` (
`id` int(11) NOT NULL,
  `bugid` int(11) NOT NULL,
  `type` enum('file','paste') COLLATE utf8_bin NOT NULL,
  `file` varchar(255) COLLATE utf8_bin NOT NULL,
  `paste` int(11) NOT NULL,
  `datetime` datetime NOT NULL,
  `authorid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_bugs_log`
--

CREATE TABLE IF NOT EXISTS `projects_bugs_log` (
  `bugid` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL,
  `version` varchar(15) COLLATE utf8_bin NOT NULL,
  `milestone` varchar(15) COLLATE utf8_bin NOT NULL,
  `priority` enum('!nochange!','blocker','critical','major','normal','minor','trivial') COLLATE utf8_bin NOT NULL,
  `type` enum('!nochange!','bugreport','featurerequest') COLLATE utf8_bin NOT NULL,
  `status` enum('!nochange!','unconfirmed','confirmed','working','needinformations','needcontributors','needtests','resolved','rejected') COLLATE utf8_bin NOT NULL,
  `assignedid` int(11) NOT NULL DEFAULT '0',
  `attachement` int(11) NOT NULL DEFAULT '0',
  `answer` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_commits`
--

CREATE TABLE IF NOT EXISTS `projects_commits` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `prev_rev` text COLLATE utf8_bin NOT NULL,
  `new_rev` text COLLATE utf8_bin NOT NULL,
  `log` text COLLATE utf8_bin NOT NULL,
  `author` tinytext COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_doc`
--

CREATE TABLE IF NOT EXISTS `projects_doc` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `link` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `log` tinytext COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `is_public` tinyint(1) NOT NULL,
  `datetime` datetime NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_downloads`
--

CREATE TABLE IF NOT EXISTS `projects_downloads` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `text` tinytext COLLATE utf8_bin NOT NULL,
  `version` varchar(15) COLLATE utf8_bin NOT NULL,
  `file` tinytext COLLATE utf8_bin NOT NULL,
  `downloads` int(11) NOT NULL DEFAULT '0',
  `date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_forum`
--

CREATE TABLE IF NOT EXISTS `projects_forum` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `category` enum('help','developement','userscomments','global') COLLATE utf8_bin NOT NULL,
  `title` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `answers` int(11) NOT NULL,
  `last_answer_id` int(11) NOT NULL,
  `datetime` datetime NOT NULL,
  `is_open` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_forum_answers`
--

CREATE TABLE IF NOT EXISTS `projects_forum_answers` (
`id` int(11) NOT NULL,
  `postid` int(11) NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `unregistered_nick` tinytext COLLATE utf8_bin NOT NULL,
  `registered_id` int(11) NOT NULL,
  `author_ip` varchar(15) COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_i18n`
--

CREATE TABLE IF NOT EXISTS `projects_i18n` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `baselang` varchar(5) COLLATE utf8_bin NOT NULL,
  `references` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `is_translated` tinytext COLLATE utf8_bin NOT NULL,
  `is_active` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_i18n_proposals`
--

CREATE TABLE IF NOT EXISTS `projects_i18n_proposals` (
`id` int(11) NOT NULL,
  `text_id` int(11) NOT NULL,
  `authorid` int(11) NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `type` enum('translation','reformulation','correction') COLLATE utf8_bin NOT NULL,
  `lang` varchar(5) COLLATE utf8_bin NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_jabber`
--

CREATE TABLE IF NOT EXISTS `projects_jabber` (
  `projectid` int(11) NOT NULL,
  `jid` varchar(255) COLLATE utf8_bin NOT NULL,
  `desc` tinytext COLLATE utf8_bin NOT NULL,
  `nbuser` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_news`
--

CREATE TABLE IF NOT EXISTS `projects_news` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `link` tinytext COLLATE utf8_bin NOT NULL,
  `title` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `authorid` int(11) NOT NULL,
  `datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_screenshots`
--

CREATE TABLE IF NOT EXISTS `projects_screenshots` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `version` varchar(15) COLLATE utf8_bin NOT NULL,
  `image` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `projects_versions`
--

CREATE TABLE IF NOT EXISTS `projects_versions` (
`id` int(11) NOT NULL,
  `projectid` int(11) NOT NULL,
  `version` varchar(15) COLLATE utf8_bin NOT NULL,
  `status` enum('planned','development','testing','alpha','beta','stable','abandonned') COLLATE utf8_bin NOT NULL,
  `posid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `teams`
--

CREATE TABLE IF NOT EXISTS `teams` (
`id` int(11) NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `dbname` varchar(50) COLLATE utf8_bin NOT NULL,
  `rule` enum('public','restricted','private') COLLATE utf8_bin NOT NULL,
  `logo` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `date` datetime NOT NULL,
  `leader_id` int(11) NOT NULL,
  `related_projects` tinytext COLLATE utf8_bin NOT NULL,
  `mailinglist` tinytext COLLATE utf8_bin NOT NULL,
  `xmppchatroom` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `teams_members`
--

CREATE TABLE IF NOT EXISTS `teams_members` (
  `team_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `texts`
--

CREATE TABLE IF NOT EXISTS `texts` (
  `page` varchar(42) COLLATE utf8_bin NOT NULL,
  `title` tinytext COLLATE utf8_bin NOT NULL,
  `text` text COLLATE utf8_bin NOT NULL,
  `allow_nl2br` tinyint(1) NOT NULL,
  `date` datetime NOT NULL,
  `author` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Table structure for table `users`
--

CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL,
  `nickname` varchar(30) COLLATE utf8_bin NOT NULL,
  `password` varchar(32) COLLATE utf8_bin NOT NULL,
  `apache_password` varchar(37) COLLATE utf8_bin NOT NULL,
  `surname` tinytext COLLATE utf8_bin NOT NULL,
  `name` tinytext COLLATE utf8_bin NOT NULL,
  `date` datetime NOT NULL,
  `email` varchar(255) COLLATE utf8_bin NOT NULL,
  `jid` tinytext COLLATE utf8_bin NOT NULL,
  `url` tinytext COLLATE utf8_bin NOT NULL,
  `avatar` tinytext COLLATE utf8_bin NOT NULL,
  `level` enum('administrator','member','banned','deleted') COLLATE utf8_bin NOT NULL,
  `keyid` varchar(42) COLLATE utf8_bin NOT NULL,
  `lang` varchar(2) COLLATE utf8_bin NOT NULL,
  `unread_messages` int(11) NOT NULL,
  `notifs` enum('mail','xmpp','no') COLLATE utf8_bin NOT NULL,
  `dashboard_lastelement` tinytext COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

ALTER TABLE `config`
 ADD UNIQUE KEY `key` (`group`,`field`,`value`(255),`text`(255));

ALTER TABLE `messages`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `messages_answers`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `notepad`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `notifications`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `projects`
 ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `dbname` (`dbname`);

ALTER TABLE `projects_admins`
 ADD UNIQUE KEY `admin` (`projectid`,`userid`), ADD KEY `constr_users_userid` (`userid`);

ALTER TABLE `projects_bugs`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `projects_bugs_answers`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_bugs_bugid1` (`bugid`);

ALTER TABLE `projects_bugs_attachements`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_bugs_bugid2` (`bugid`);

ALTER TABLE `projects_bugs_log`
 ADD KEY `constr_projects_bugs_bugid` (`bugid`);

ALTER TABLE `projects_commits`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_projectid10` (`projectid`);

ALTER TABLE `projects_doc`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_projectid7` (`projectid`);

ALTER TABLE `projects_downloads`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `projects_forum`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_projectid8` (`projectid`);

ALTER TABLE `projects_forum_answers`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_forum_postid` (`postid`);

ALTER TABLE `projects_i18n`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_projectid11` (`projectid`);

ALTER TABLE `projects_i18n_proposals`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_i18n_textid` (`text_id`);

ALTER TABLE `projects_jabber`
 ADD UNIQUE KEY `projectid` (`projectid`,`jid`);

ALTER TABLE `projects_news`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `projects_screenshots`
 ADD PRIMARY KEY (`id`), ADD KEY `constr_projects_projectid3` (`projectid`);

ALTER TABLE `projects_versions`
 ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `version` (`projectid`,`version`);

ALTER TABLE `teams`
 ADD PRIMARY KEY (`id`);

ALTER TABLE `teams_members`
 ADD UNIQUE KEY `team_id` (`team_id`,`user_id`);

ALTER TABLE `texts`
 ADD UNIQUE KEY `page` (`page`);

ALTER TABLE `users`
 ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `uninc0` (`nickname`), ADD UNIQUE KEY `uninc1` (`keyid`);

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

ALTER TABLE `messages`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `messages_answers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `notepad`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `notifications`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_bugs`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_bugs_answers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_bugs_attachements`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_commits`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_doc`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_downloads`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_forum`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_forum_answers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_i18n`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_i18n_proposals`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_news`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_screenshots`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `projects_versions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `teams`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

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

ALTER TABLE `projects_admins`
ADD CONSTRAINT `constr_projects_projectid` FOREIGN KEY (`projectid`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `constr_users_userid` FOREIGN KEY (`userid`) REFERENCES `users` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_bugs_answers`
ADD CONSTRAINT `constr_projects_bugs_bugid1` FOREIGN KEY (`bugid`) REFERENCES `projects_bugs` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_bugs_attachements`
ADD CONSTRAINT `constr_projects_bugs_bugid2` FOREIGN KEY (`bugid`) REFERENCES `projects_bugs` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_bugs_log`
ADD CONSTRAINT `constr_projects_bugs_bugid` FOREIGN KEY (`bugid`) REFERENCES `projects_bugs` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_doc`
ADD CONSTRAINT `constr_projects_projectid7` FOREIGN KEY (`projectid`) REFERENCES `projects` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_forum`
ADD CONSTRAINT `constr_projects_projectid8` FOREIGN KEY (`projectid`) REFERENCES `projects` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_forum_answers`
ADD CONSTRAINT `constr_projects_forum_postid` FOREIGN KEY (`postid`) REFERENCES `projects_forum` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_i18n`
ADD CONSTRAINT `constr_projects_projectid11` FOREIGN KEY (`projectid`) REFERENCES `projects` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_i18n_proposals`
ADD CONSTRAINT `constr_projects_i18n_textid` FOREIGN KEY (`text_id`) REFERENCES `projects_i18n` (`id`) ON DELETE CASCADE;

ALTER TABLE `projects_screenshots`
ADD CONSTRAINT `constr_projects_projectid3` FOREIGN KEY (`projectid`) REFERENCES `projects` (`id`) ON DELETE CASCADE;

ALTER TABLE `teams_members`
ADD CONSTRAINT `constr_teams_teamid` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `constr_teams_userid` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;