freepost_freepost.sql 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  2. SET time_zone = "+00:00";
  3. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  4. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  5. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  6. /*!40101 SET NAMES utf8 */;
  7. CREATE DATABASE IF NOT EXISTS `freepost_freepost` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  8. USE `freepost_freepost`;
  9. DROP TABLE IF EXISTS `comment`;
  10. CREATE TABLE IF NOT EXISTS `comment` (
  11. `id` int(11) NOT NULL,
  12. `hashId` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  13. `created` datetime NOT NULL,
  14. `dateCreated` date NOT NULL,
  15. `read` tinyint(1) NOT NULL,
  16. `text` longtext COLLATE utf8_unicode_ci NOT NULL,
  17. `vote` int(11) NOT NULL,
  18. `parentId` int(11) DEFAULT NULL,
  19. `parentUserId` int(11) DEFAULT NULL,
  20. `postId` int(11) DEFAULT NULL,
  21. `userId` int(11) DEFAULT NULL
  22. ) ENGINE=InnoDB AUTO_INCREMENT=8027 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  23. DROP TABLE IF EXISTS `post`;
  24. CREATE TABLE IF NOT EXISTS `post` (
  25. `id` int(11) NOT NULL,
  26. `hashId` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  27. `created` datetime NOT NULL,
  28. `dateCreated` date NOT NULL,
  29. `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  30. `link` text COLLATE utf8_unicode_ci,
  31. `text` longtext COLLATE utf8_unicode_ci NOT NULL,
  32. `vote` int(11) NOT NULL,
  33. `commentsCount` int(11) NOT NULL,
  34. `userId` int(11) DEFAULT NULL
  35. ) ENGINE=InnoDB AUTO_INCREMENT=6566 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  36. DROP TABLE IF EXISTS `remember_me`;
  37. CREATE TABLE IF NOT EXISTS `remember_me` (
  38. `token` char(128) COLLATE utf8_unicode_ci NOT NULL,
  39. `userId` int(10) NOT NULL,
  40. `expires` datetime NOT NULL
  41. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Used for user authentication (keep session alive for returning user)';
  42. DROP TABLE IF EXISTS `user`;
  43. CREATE TABLE IF NOT EXISTS `user` (
  44. `id` int(11) NOT NULL,
  45. `hashId` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  46. `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  47. `email_notifications` tinyint(1) unsigned NOT NULL DEFAULT '1',
  48. `isActive` tinyint(1) NOT NULL,
  49. `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  50. `passwordResetToken` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  51. `passwordResetTokenExpire` datetime DEFAULT NULL,
  52. `registered` datetime NOT NULL,
  53. `salt` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  54. `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  55. `about` varchar(10000) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''
  56. ) ENGINE=InnoDB AUTO_INCREMENT=264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  57. DROP TABLE IF EXISTS `vote_comment`;
  58. CREATE TABLE IF NOT EXISTS `vote_comment` (
  59. `vote` smallint(6) NOT NULL,
  60. `datetime` datetime NOT NULL,
  61. `commentId` int(11) NOT NULL,
  62. `userId` int(11) NOT NULL
  63. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  64. DROP TABLE IF EXISTS `vote_post`;
  65. CREATE TABLE IF NOT EXISTS `vote_post` (
  66. `vote` smallint(6) NOT NULL,
  67. `datetime` datetime NOT NULL,
  68. `postId` int(11) NOT NULL,
  69. `userId` int(11) NOT NULL
  70. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  71. ALTER TABLE `comment`
  72. ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `hashId` (`hashId`), ADD KEY `IDX_9474526C10EE4CEE` (`parentId`), ADD KEY `IDX_9474526C251330C5` (`parentUserId`), ADD KEY `IDX_9474526CE094D20D` (`postId`), ADD KEY `IDX_9474526C64B64DCC` (`userId`), ADD KEY `created` (`created`), ADD KEY `dateCreated` (`dateCreated`), ADD KEY `isRead` (`read`), ADD KEY `vote` (`vote`);
  73. ALTER TABLE `post`
  74. ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `hashId` (`hashId`), ADD KEY `IDX_5A8A6C8D64B64DCC` (`userId`), ADD KEY `created` (`created`), ADD KEY `dateCreated` (`dateCreated`), ADD KEY `vote` (`vote`);
  75. ALTER TABLE `remember_me`
  76. ADD PRIMARY KEY (`token`), ADD KEY `userId` (`userId`);
  77. ALTER TABLE `user`
  78. ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `hashId` (`hashId`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `email` (`email`), ADD UNIQUE KEY `passwordResetCode` (`passwordResetToken`);
  79. ALTER TABLE `vote_comment`
  80. ADD PRIMARY KEY (`commentId`,`userId`), ADD KEY `IDX_1FC60DF46690C3F5` (`commentId`), ADD KEY `IDX_1FC60DF464B64DCC` (`userId`);
  81. ALTER TABLE `vote_post`
  82. ADD PRIMARY KEY (`postId`,`userId`), ADD KEY `IDX_EDE89DBCE094D20D` (`postId`), ADD KEY `IDX_EDE89DBC64B64DCC` (`userId`);
  83. ALTER TABLE `comment`
  84. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8027;
  85. ALTER TABLE `post`
  86. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6566;
  87. ALTER TABLE `user`
  88. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=264;
  89. ALTER TABLE `comment`
  90. ADD CONSTRAINT `FK_9474526C10EE4CEE` FOREIGN KEY (`parentId`) REFERENCES `comment` (`id`),
  91. ADD CONSTRAINT `FK_9474526C251330C5` FOREIGN KEY (`parentUserId`) REFERENCES `user` (`id`),
  92. ADD CONSTRAINT `FK_9474526C64B64DCC` FOREIGN KEY (`userId`) REFERENCES `user` (`id`),
  93. ADD CONSTRAINT `FK_9474526CE094D20D` FOREIGN KEY (`postId`) REFERENCES `post` (`id`);
  94. ALTER TABLE `post`
  95. ADD CONSTRAINT `FK_5A8A6C8D64B64DCC` FOREIGN KEY (`userId`) REFERENCES `user` (`id`);
  96. ALTER TABLE `remember_me`
  97. ADD CONSTRAINT `FK_userId` FOREIGN KEY (`userId`) REFERENCES `user` (`id`);
  98. ALTER TABLE `vote_comment`
  99. ADD CONSTRAINT `FK_1FC60DF464B64DCC` FOREIGN KEY (`userId`) REFERENCES `user` (`id`),
  100. ADD CONSTRAINT `FK_1FC60DF46690C3F5` FOREIGN KEY (`commentId`) REFERENCES `comment` (`id`);
  101. ALTER TABLE `vote_post`
  102. ADD CONSTRAINT `FK_EDE89DBC64B64DCC` FOREIGN KEY (`userId`) REFERENCES `user` (`id`),
  103. ADD CONSTRAINT `FK_EDE89DBCE094D20D` FOREIGN KEY (`postId`) REFERENCES `post` (`id`);
  104. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  105. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  106. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;