You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
6.8 KiB

  1. // FIXME: Refactor to our database ERM already combined
  2. const init_queries = [
  3. `CREATE TABLE IF NOT EXISTS PluviometerData (
  4. Id integer PRIMARY KEY autoincrement,
  5. Date text NOT NULL,
  6. Images text,
  7. Precipitation real NOT NULL,
  8. Description text
  9. )`,
  10. `CREATE TABLE IF NOT EXISTS FloodZones (
  11. Id integer PRIMARY KEY autoincrement,
  12. Description text,
  13. Images text,
  14. Latitude real NOT NULL,
  15. Longitude real NOT NULL,
  16. Passable INTERGER NOT NULL,
  17. Date text,
  18. Time text,
  19. Address text
  20. );`,
  21. // `CREATE TABLE IF NOT EXISTS Pluviometer (
  22. // Id integer PRIMARY KEY autoincrement,
  23. // Date text NOT NULL,
  24. // Latitude real NOT NULL,
  25. // Longitude real NOT NULL,
  26. // Address text,
  27. // School text,
  28. // );`,
  29. // `INSERT INTO Pluviometer(Latitude, Longitude, Precipitation, Address, Description) VALUES(?, ?, ?, ?, ?, ?, ?);`,
  30. `CREATE TABLE IF NOT EXISTS RainLevel (
  31. Id integer PRIMARY KEY autoincrement,
  32. Description text,
  33. RainIdx INTEGER NOT NULL,
  34. Images text,
  35. Latitude real NOT NULL,
  36. Longitude real NOT NULL,
  37. Date text,
  38. Time text,
  39. Address text
  40. );`,
  41. `CREATE TABLE IF NOT EXISTS RiverLevel (
  42. Id integer PRIMARY KEY autoincrement,
  43. Description text,
  44. RiverIdx INTEGER NOT NULL,
  45. Images text,
  46. Latitude real NOT NULL,
  47. Longitude real NOT NULL,
  48. Date text,
  49. Time text,
  50. Address text
  51. );`,
  52. ];
  53. // `CREATE TABLE IF NOT EXISTS Users (
  54. // Id integer PRIMARY KEY autoincrement,
  55. // Email text NOT NULL,
  56. // FirstName text NOT NULL,
  57. // SurName text NOT NULL,
  58. // Avatar text NOT NULL,
  59. // Active integer NOT NULL
  60. // );`,
  61. // `CREATE TABLE IF NOT EXISTS Profiles (
  62. // Id integer PRIMARY KEY autoincrement,
  63. // Name text NOT NULL,
  64. // Active integer NOT NULL
  65. // );`,
  66. // `CREATE TABLE IF NOT EXISTS UsersProfiles (
  67. // Id integer PRIMARY KEY autoincrement,
  68. // IdUsers integer NOT NULL,
  69. // IdProfiles integer NOT NULL,
  70. // Active integer NOT NULL,
  71. // FOREIGN KEY (IdUsers) REFERENCES Users (Id),
  72. // FOREIGN KEY (IdProfiles) REFERENCES Profiles (Id)
  73. // );`,
  74. // `CREATE TABLE IF NOT EXISTS Permissions (
  75. // Id integer PRIMARY KEY autoincrement,
  76. // Name text NOT NULL,
  77. // Active integer NOT NULL
  78. // );`,
  79. // `CREATE TABLE IF NOT EXISTS ProfilesPermissions (
  80. // Id integer PRIMARY KEY autoincrement,
  81. // IdProfiles integer NOT NULL,
  82. // IdPermissions integer NOT NULL,
  83. // Active integer NOT NULL,
  84. // FOREIGN KEY (IdProfiles) REFERENCES Profiles (Id),
  85. // FOREIGN KEY (IdPermissions) REFERENCES Permissions (Id)
  86. // );`,
  87. // `CREATE TABLE IF NOT EXISTS FormsOrigins (
  88. // Id integer PRIMARY KEY autoincrement,
  89. // Name text NOT NULL,
  90. // Active integer NOT NULL
  91. // );`,
  92. // `CREATE TABLE IF NOT EXISTS Forms (
  93. // Id integer PRIMARY KEY autoincrement,
  94. // IdFormsOrigins integer NOT NULL,
  95. // Name text NOT NULL,
  96. // Description text NOT NULL,
  97. // DtCreation TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
  98. // Active integer NOT NULL,
  99. // FOREIGN KEY (IdFormsOrigins) REFERENCES FormsOrigins (Id)
  100. // );`,
  101. // `CREATE TABLE IF NOT EXISTS FieldsDataTypes (
  102. // Id integer PRIMARY KEY autoincrement,
  103. // Name text NOT NULL,
  104. // Description text NOT NULL,
  105. // Active integer NOT NULL
  106. // );`,
  107. // `CREATE TABLE IF NOT EXISTS Fields (
  108. // Id integer PRIMARY KEY autoincrement,
  109. // IdFieldsDataTypes integer NOT NULL,
  110. // Name text NOT NULL,
  111. // Description text NOT NULL,
  112. // FillingClue text NOT NULL,
  113. // Active integer NOT NULL,
  114. // FOREIGN KEY (IdFieldsDataTypes) REFERENCES FieldsDataTypes (Id)
  115. // );`,
  116. // `CREATE TABLE IF NOT EXISTS FormsFields (
  117. // Id integer PRIMARY KEY autoincrement,
  118. // IdForms integer NOT NULL,
  119. // IdFields integer NOT NULL,
  120. // Active integer NOT NULL,
  121. // FOREIGN KEY (IdForms) REFERENCES Forms (Id),
  122. // FOREIGN KEY (IdFields) REFERENCES Fields (Id)
  123. // );`,
  124. // `CREATE TABLE IF NOT EXISTS Alternatives (
  125. // Id integer PRIMARY KEY autoincrement,
  126. // Response text NOT NULL,
  127. // ShortResponse text NOT NULL,
  128. // Description text NOT NULL,
  129. // Active integer NOT NULL
  130. // );`,
  131. // `CREATE TABLE IF NOT EXISTS FieldsAlternatives (
  132. // Id integer PRIMARY KEY autoincrement,
  133. // IdFields integer NOT NULL,
  134. // IdAlternatives integer NOT NULL,
  135. // Active integer NOT NULL,
  136. // FOREIGN KEY (IdFields) REFERENCES Fields (Id),
  137. // FOREIGN KEY (IdAlternatives) REFERENCES Alternatives (Id)
  138. // );`,
  139. // `CREATE TABLE IF NOT EXISTS FieldsAnswers (
  140. // Id integer PRIMARY KEY autoincrement,
  141. // IdFields integer NOT NULL,
  142. // Value text NOT NULL,
  143. // DtFilling TIMESTAMP NOT NULL,
  144. // Active integer NOT NULL,
  145. // FOREIGN KEY (IdFields) REFERENCES Fields (Id)
  146. // );`,
  147. // `CREATE TABLE IF NOT EXISTS UsersInformerFieldsAnswers (
  148. // Id integer PRIMARY KEY autoincrement,
  149. // IdUsersInformer integer NOT NULL,
  150. // IdFieldsAnswers integer NOT NULL,
  151. // Latitude real NULL,
  152. // Longitude real NULL,
  153. // Active integer NOT NULL,
  154. // FOREIGN KEY (IdUsersInformer) REFERENCES Users (Id),
  155. // FOREIGN KEY (IdFieldsAnswers) REFERENCES FieldsAnswers (Id)
  156. // );`,
  157. // `CREATE TABLE IF NOT EXISTS UsersEndorsementFieldsAnswers (
  158. // Id integer PRIMARY KEY autoincrement,
  159. // IdUsersEndorsement integer NOT NULL,
  160. // IdFieldsAnswers integer NOT NULL,
  161. // Latitude real NULL,
  162. // Longitude real NULL,
  163. // IsTrustable integer NOT NULL,
  164. // Active integer NOT NULL,
  165. // FOREIGN KEY (IdUsersEndorsement) REFERENCES Users (Id),
  166. // FOREIGN KEY (IdFieldsAnswers) REFERENCES FieldsAnswers (Id)
  167. // );`,
  168. // `CREATE TABLE IF NOT EXISTS PreliminaryData (
  169. // Id integer PRIMARY KEY autoincrement,
  170. // IdFieldsAnswers integer NOT NULL,
  171. // DtInsert TIMESTAMP NOT NULL,
  172. // Active integer NOT NULL,
  173. // FOREIGN KEY (IdFieldsAnswers) REFERENCES FieldsAnswers (Id)
  174. // );`,
  175. // `CREATE TABLE IF NOT EXISTS TrustedData (
  176. // Id integer PRIMARY KEY autoincrement,
  177. // IdFieldsAnswers integer NOT NULL,
  178. // DtInsert TIMESTAMP NOT NULL,
  179. // Active integer NOT NULL,
  180. // FOREIGN KEY (IdFieldsAnswers) REFERENCES FieldsAnswers (Id)
  181. // );`,
  182. // ];
  183. export default init_queries;