Skip to content

Instantly share code, notes, and snippets.

@icco
Created November 17, 2009 08:03
Show Gist options
  • Select an option

  • Save icco/236765 to your computer and use it in GitHub Desktop.

Select an option

Save icco/236765 to your computer and use it in GitHub Desktop.
Some sql examples for peter
DROP TABLE IF EXISTS `user_history`;
CREATE TABLE `user_history` (
`historyid` int(10) unsigned NOT NULL auto_increment,
`userid` int(10) unsigned NOT NULL,
`delta` int(11) NOT NULL,
`rewarded` int(11) NOT NULL,
`date` int(11) NOT NULL,
`doctype` enum('wiki_revisions','guide_translation_revisions','guide_step_revisions','user_success','comments','posts','user_badges','user_votes','users') default NULL,
`docid` int(10) unsigned default NULL,
`event` varchar(255) default 'default',
PRIMARY KEY (`historyid`),
KEY `user_history_fk1` (`userid`),
KEY `docid` (`docid`),
KEY `doctype` (`doctype`),
KEY `event` (`event`),
CONSTRAINT `user_history_fk1` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9325 DEFAULT CHARSET=utf8
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`userid` int(11) unsigned NOT NULL auto_increment,
`login` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`imageid` int(10) unsigned default NULL,
`langid` char(2) NOT NULL default 'en',
`active` tinyint(1) NOT NULL default '1',
`last_attempt` int(10) unsigned NOT NULL default '0',
`recent_attempts` tinyint(3) unsigned NOT NULL default '0',
`groupid` int(10) unsigned default NULL,
`join_date` int(10) unsigned default NULL,
`real_name` varchar(255) default NULL,
`about` text default '',
`reputation` int(10) default '0',
PRIMARY KEY (`userid`),
UNIQUE KEY `login` (`login`),
KEY `username` (`username`),
KEY `active` (`active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment