schema.sql 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. CREATE TABLE IF NOT EXISTS `components_double` (
  3. `eid` INT,
  4. `typeID` INT,
  5. `data` double,
  6. `rev` int,
  7. PRIMARY KEY (`eid`, `typeID`)
  8. );
  9. CREATE TABLE IF NOT EXISTS `components_int` (
  10. `eid` INT,
  11. `typeID` INT,
  12. `data` BIGINT,
  13. `rev` int,
  14. PRIMARY KEY (`eid`, `typeID`)
  15. );
  16. CREATE TABLE IF NOT EXISTS `components_string` (
  17. `eid` INT,
  18. `typeID` INT,
  19. `data` VARCHAR(31000),
  20. `rev` int,
  21. PRIMARY KEY (`eid`, `typeID`)
  22. );
  23. CREATE TABLE IF NOT EXISTS `components_date` (
  24. `eid` INT,
  25. `typeID` INT,
  26. `data` timestamp,
  27. `rev` int,
  28. PRIMARY KEY (`eid`, `typeID`)
  29. );
  30. */
  31. CREATE TABLE IF NOT EXISTS `components` (
  32. `eid` INT,
  33. `typeID` INT,
  34. `data_double` double,
  35. `data_int` BIGINT,
  36. `data_string` VARCHAR(31000),
  37. `data_date` timestamp,
  38. `rev` int default 1,
  39. PRIMARY KEY (`eid`, `typeID`)
  40. );
  41. CREATE TABLE IF NOT EXISTS `entities` (
  42. `eid` INT AUTO_INCREMENT PRIMARY KEY,
  43. `deleted` bool not null default false
  44. );
  45. CREATE TABLE IF NOT EXISTS `types` (
  46. `typeID` INT AUTO_INCREMENT PRIMARY KEY,
  47. `name` VARCHAR(64),
  48. `is_double` bool default false,
  49. `is_int` bool default false,
  50. `is_string` bool default false,
  51. `is_date` bool default false,
  52. `externalType` VARCHAR(64) default '',
  53. unique(`name`)
  54. );
  55. INSERT INTO `types` (`name`, `is_string`) VALUES ('name', true);
  56. INSERT INTO `types` (`name`, `is_date`) VALUES ('created_at', true);
  57. INSERT INTO `types` (`name`, `is_date`) VALUES ('updated_at', true);
  58. INSERT INTO `types` (`name`, `is_date`) VALUES ('deleted_at', true);
  59. CREATE TABLE IF NOT EXISTS `users` (
  60. `uid` INT AUTO_INCREMENT PRIMARY KEY,
  61. `status` VARCHAR(32),
  62. `joinedAt` timestamp not null,
  63. `lastLoginAt` timestamp
  64. );
  65. CREATE TABLE IF NOT EXISTS `user_claims` (
  66. `uid` INT,
  67. `type` VARCHAR(32),
  68. `status` VARCHAR(32),
  69. `providerID` VARCHAR(1024),
  70. `authData` VARCHAR(1024),
  71. `activatedAt` timestamp,
  72. `lastLoginAt` timestamp,
  73. PRIMARY KEY (`uid`, `type`)
  74. );