@dbml/cli 7.0.0-alpha.1 → 7.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/__tests__/cli.test.ts +8 -4
  4. package/__tests__/db2dbml/mssql/expect-out-files/schema.dbml +0 -0
  5. package/__tests__/db2dbml/mssql/options.json +0 -0
  6. package/__tests__/db2dbml/mssql/schema.sql +0 -0
  7. package/__tests__/db2dbml/mssql/stdout.txt +0 -0
  8. package/__tests__/db2dbml/mysql/expect-out-files/schema.dbml +0 -0
  9. package/__tests__/db2dbml/mysql/options.json +0 -0
  10. package/__tests__/db2dbml/mysql/schema.sql +0 -0
  11. package/__tests__/db2dbml/mysql/stdout.txt +0 -0
  12. package/__tests__/db2dbml/oracle/expect-out-files/schema.dbml +0 -0
  13. package/__tests__/db2dbml/oracle/options.json +0 -0
  14. package/__tests__/db2dbml/oracle/schema.sql +0 -0
  15. package/__tests__/db2dbml/oracle/stdout.txt +0 -0
  16. package/__tests__/db2dbml/postgres/expect-out-files/schema.dbml +0 -0
  17. package/__tests__/db2dbml/postgres/options.json +0 -0
  18. package/__tests__/db2dbml/postgres/schema.sql +0 -0
  19. package/__tests__/db2dbml/postgres/stdout.txt +0 -0
  20. package/__tests__/db2dbml_bin.js +3 -1
  21. package/__tests__/dbml2sql/filename --mysql --out-file/expect-out-files/schema.sql +0 -0
  22. package/__tests__/dbml2sql/filename --mysql --out-file/in-files/schema.dbml +0 -0
  23. package/__tests__/dbml2sql/filename --mysql --out-file/options.json +0 -0
  24. package/__tests__/dbml2sql/filename --mysql --out-file/stdout.txt +0 -0
  25. package/__tests__/dbml2sql/filename --mysql stdout/in-files/schema.dbml +0 -0
  26. package/__tests__/dbml2sql/filename --mysql stdout/options.json +0 -0
  27. package/__tests__/dbml2sql/filename --mysql stdout/stdout.txt +0 -0
  28. package/__tests__/dbml2sql/filename --oracle --out-file/expect-out-files/schema.sql +0 -0
  29. package/__tests__/dbml2sql/filename --oracle --out-file/in-files/schema.dbml +0 -0
  30. package/__tests__/dbml2sql/filename --oracle --out-file/options.json +0 -0
  31. package/__tests__/dbml2sql/filename --oracle --out-file/stdout.txt +0 -0
  32. package/__tests__/dbml2sql/filename --oracle stdout/in-files/schema.dbml +0 -0
  33. package/__tests__/dbml2sql/filename --oracle stdout/options.json +0 -0
  34. package/__tests__/dbml2sql/filename --oracle stdout/stdout.txt +0 -0
  35. package/__tests__/dbml2sql/filename --out-file/expect-out-files/schema.sql +0 -0
  36. package/__tests__/dbml2sql/filename --out-file/in-files/schema.dbml +0 -0
  37. package/__tests__/dbml2sql/filename --out-file/options.json +0 -0
  38. package/__tests__/dbml2sql/filename --out-file/stdout.txt +0 -0
  39. package/__tests__/dbml2sql/filename --postgres --out-file/expect-out-files/schema.sql +0 -0
  40. package/__tests__/dbml2sql/filename --postgres --out-file/in-files/schema.dbml +0 -0
  41. package/__tests__/dbml2sql/filename --postgres --out-file/options.json +0 -0
  42. package/__tests__/dbml2sql/filename --postgres --out-file/stdout.txt +0 -0
  43. package/__tests__/dbml2sql/filename --postgres stdout/in-files/schema.dbml +0 -0
  44. package/__tests__/dbml2sql/filename --postgres stdout/options.json +0 -0
  45. package/__tests__/dbml2sql/filename --postgres stdout/stdout.txt +0 -0
  46. package/__tests__/dbml2sql/filename stdout/in-files/schema.dbml +0 -0
  47. package/__tests__/dbml2sql/filename stdout/options.json +0 -0
  48. package/__tests__/dbml2sql/filename stdout/stdout.txt +0 -0
  49. package/__tests__/dbml2sql/filenames --mysql --out-file/expect-out-files/schema.sql +0 -0
  50. package/__tests__/dbml2sql/filenames --mysql --out-file/in-files/business.dbml +0 -0
  51. package/__tests__/dbml2sql/filenames --mysql --out-file/in-files/customer.dbml +0 -0
  52. package/__tests__/dbml2sql/filenames --mysql --out-file/in-files/inventory.dbml +0 -0
  53. package/__tests__/dbml2sql/filenames --mysql --out-file/options.json +0 -0
  54. package/__tests__/dbml2sql/filenames --mysql --out-file/stdout.txt +0 -0
  55. package/__tests__/dbml2sql/filenames --mysql stdout/in-files/business.dbml +0 -0
  56. package/__tests__/dbml2sql/filenames --mysql stdout/in-files/customer.dbml +0 -0
  57. package/__tests__/dbml2sql/filenames --mysql stdout/in-files/inventory.dbml +0 -0
  58. package/__tests__/dbml2sql/filenames --mysql stdout/options.json +0 -0
  59. package/__tests__/dbml2sql/filenames --mysql stdout/stdout.txt +0 -0
  60. package/__tests__/dbml2sql/filenames --oracle --out-file/expect-out-files/schema.sql +0 -0
  61. package/__tests__/dbml2sql/filenames --oracle --out-file/in-files/business.dbml +0 -0
  62. package/__tests__/dbml2sql/filenames --oracle --out-file/in-files/customer.dbml +0 -0
  63. package/__tests__/dbml2sql/filenames --oracle --out-file/in-files/inventory.dbml +0 -0
  64. package/__tests__/dbml2sql/filenames --oracle --out-file/options.json +0 -0
  65. package/__tests__/dbml2sql/filenames --oracle --out-file/stdout.txt +0 -0
  66. package/__tests__/dbml2sql/filenames --oracle stdout/in-files/business.dbml +0 -0
  67. package/__tests__/dbml2sql/filenames --oracle stdout/in-files/customer.dbml +0 -0
  68. package/__tests__/dbml2sql/filenames --oracle stdout/in-files/inventory.dbml +0 -0
  69. package/__tests__/dbml2sql/filenames --oracle stdout/options.json +0 -0
  70. package/__tests__/dbml2sql/filenames --oracle stdout/stdout.txt +0 -0
  71. package/__tests__/dbml2sql/filenames --out-file/expect-out-files/schema.sql +0 -0
  72. package/__tests__/dbml2sql/filenames --out-file/in-files/business.dbml +0 -0
  73. package/__tests__/dbml2sql/filenames --out-file/in-files/customer.dbml +0 -0
  74. package/__tests__/dbml2sql/filenames --out-file/in-files/inventory.dbml +0 -0
  75. package/__tests__/dbml2sql/filenames --out-file/options.json +0 -0
  76. package/__tests__/dbml2sql/filenames --out-file/stdout.txt +0 -0
  77. package/__tests__/dbml2sql/filenames --postgres --out-file/expect-out-files/schema.sql +0 -0
  78. package/__tests__/dbml2sql/filenames --postgres --out-file/in-files/business.dbml +0 -0
  79. package/__tests__/dbml2sql/filenames --postgres --out-file/in-files/customer.dbml +0 -0
  80. package/__tests__/dbml2sql/filenames --postgres --out-file/in-files/inventory.dbml +0 -0
  81. package/__tests__/dbml2sql/filenames --postgres --out-file/options.json +0 -0
  82. package/__tests__/dbml2sql/filenames --postgres --out-file/stdout.txt +0 -0
  83. package/__tests__/dbml2sql/filenames --postgres stdout/in-files/business.dbml +0 -0
  84. package/__tests__/dbml2sql/filenames --postgres stdout/in-files/customer.dbml +0 -0
  85. package/__tests__/dbml2sql/filenames --postgres stdout/in-files/inventory.dbml +0 -0
  86. package/__tests__/dbml2sql/filenames --postgres stdout/options.json +0 -0
  87. package/__tests__/dbml2sql/filenames --postgres stdout/stdout.txt +0 -0
  88. package/__tests__/dbml2sql/filenames stdout/in-files/business.dbml +0 -0
  89. package/__tests__/dbml2sql/filenames stdout/in-files/customer.dbml +0 -0
  90. package/__tests__/dbml2sql/filenames stdout/in-files/inventory.dbml +0 -0
  91. package/__tests__/dbml2sql/filenames stdout/options.json +0 -0
  92. package/__tests__/dbml2sql/filenames stdout/stdout.txt +0 -0
  93. package/__tests__/dbml2sql/multiple_schema_mssql/expect-out-files/multiple_schema.out.sql +0 -0
  94. package/__tests__/dbml2sql/multiple_schema_mssql/in-files/multiple_schema.in.dbml +0 -0
  95. package/__tests__/dbml2sql/multiple_schema_mssql/options.json +0 -0
  96. package/__tests__/dbml2sql/multiple_schema_mssql/stdout.txt +0 -0
  97. package/__tests__/dbml2sql/multiple_schema_mysql/expect-out-files/multiple_schema.out.sql +0 -0
  98. package/__tests__/dbml2sql/multiple_schema_mysql/in-files/multiple_schema.in.dbml +0 -0
  99. package/__tests__/dbml2sql/multiple_schema_mysql/options.json +0 -0
  100. package/__tests__/dbml2sql/multiple_schema_mysql/stdout.txt +0 -0
  101. package/__tests__/dbml2sql/multiple_schema_oracle/expect-out-files/multiple_schema.out.sql +0 -0
  102. package/__tests__/dbml2sql/multiple_schema_oracle/in-files/multiple_schema.in.dbml +0 -0
  103. package/__tests__/dbml2sql/multiple_schema_oracle/options.json +0 -0
  104. package/__tests__/dbml2sql/multiple_schema_oracle/stdout.txt +0 -0
  105. package/__tests__/dbml2sql/multiple_schema_pg/expect-out-files/multiple_schema.out.sql +0 -0
  106. package/__tests__/dbml2sql/multiple_schema_pg/in-files/multiple_schema.in.dbml +0 -0
  107. package/__tests__/dbml2sql/multiple_schema_pg/options.json +0 -0
  108. package/__tests__/dbml2sql/multiple_schema_pg/stdout.txt +0 -0
  109. package/__tests__/dbml2sql/syntax-error/in-files/ecommerce.dbml +0 -0
  110. package/__tests__/dbml2sql/syntax-error/options.json +0 -0
  111. package/__tests__/dbml2sql/syntax-error/stdout.txt +0 -0
  112. package/__tests__/dbml2sql_bin.js +3 -1
  113. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/in-files/schema.sql +0 -0
  114. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/options.json +0 -0
  115. package/__tests__/sql2dbml/custom-error-alter-table-column-not-found --oracle/stdout.txt +0 -0
  116. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/in-files/schema.sql +0 -0
  117. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/options.json +0 -0
  118. package/__tests__/sql2dbml/custom-error-alter-table-table-not-found --oracle/stdout.txt +0 -0
  119. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/in-files/schema.sql +0 -0
  120. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/options.json +0 -0
  121. package/__tests__/sql2dbml/custom-error-column-comment-column-not-found --oracle/stdout.txt +0 -0
  122. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/in-files/schema.sql +0 -0
  123. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/options.json +0 -0
  124. package/__tests__/sql2dbml/custom-error-column-comment-table-not-found --oracle/stdout.txt +0 -0
  125. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/in-files/schema.sql +0 -0
  126. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/options.json +0 -0
  127. package/__tests__/sql2dbml/custom-error-create-index-table-not-found --oracle/stdout.txt +0 -0
  128. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/in-files/schema.sql +0 -0
  129. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/options.json +0 -0
  130. package/__tests__/sql2dbml/custom-error-table-comment-table-not-found --oracle/stdout.txt +0 -0
  131. package/__tests__/sql2dbml/filename --mssql --out-file/expect-out-files/schema.dbml +0 -0
  132. package/__tests__/sql2dbml/filename --mssql --out-file/in-files/schema.sql +0 -0
  133. package/__tests__/sql2dbml/filename --mssql --out-file/options.json +0 -0
  134. package/__tests__/sql2dbml/filename --mssql --out-file/stdout.txt +0 -0
  135. package/__tests__/sql2dbml/filename --mysql --out-file/expect-out-files/schema.dbml +0 -0
  136. package/__tests__/sql2dbml/filename --mysql --out-file/in-files/schema.sql +0 -0
  137. package/__tests__/sql2dbml/filename --mysql --out-file/options.json +0 -0
  138. package/__tests__/sql2dbml/filename --mysql --out-file/stdout.txt +0 -0
  139. package/__tests__/sql2dbml/filename --mysql stdout/in-files/schema.sql +0 -0
  140. package/__tests__/sql2dbml/filename --mysql stdout/options.json +0 -0
  141. package/__tests__/sql2dbml/filename --mysql stdout/stdout.txt +0 -0
  142. package/__tests__/sql2dbml/filename --oracle --out-file/expect-out-files/schema.dbml +0 -0
  143. package/__tests__/sql2dbml/filename --oracle --out-file/in-files/schema.sql +0 -0
  144. package/__tests__/sql2dbml/filename --oracle --out-file/options.json +0 -0
  145. package/__tests__/sql2dbml/filename --oracle --out-file/stdout.txt +0 -0
  146. package/__tests__/sql2dbml/filename --out-file/expect-out-files/schema.dbml +0 -0
  147. package/__tests__/sql2dbml/filename --out-file/in-files/schema.sql +0 -0
  148. package/__tests__/sql2dbml/filename --out-file/options.json +0 -0
  149. package/__tests__/sql2dbml/filename --out-file/stdout.txt +0 -0
  150. package/__tests__/sql2dbml/filename --postgres --out-file/expect-out-files/schema.dbml +0 -0
  151. package/__tests__/sql2dbml/filename --postgres --out-file/in-files/schema.sql +0 -0
  152. package/__tests__/sql2dbml/filename --postgres --out-file/options.json +0 -0
  153. package/__tests__/sql2dbml/filename --postgres --out-file/stdout.txt +0 -0
  154. package/__tests__/sql2dbml/filename --postgres stdout/in-files/schema.sql +0 -0
  155. package/__tests__/sql2dbml/filename --postgres stdout/options.json +0 -0
  156. package/__tests__/sql2dbml/filename --postgres stdout/stdout.txt +0 -0
  157. package/__tests__/sql2dbml/filename --snowflake stdout/in-files/schema.sql +0 -0
  158. package/__tests__/sql2dbml/filename --snowflake stdout/options.json +0 -0
  159. package/__tests__/sql2dbml/filename --snowflake stdout/stdout.txt +0 -0
  160. package/__tests__/sql2dbml/filename stdout/in-files/schema.sql +0 -0
  161. package/__tests__/sql2dbml/filename stdout/options.json +0 -0
  162. package/__tests__/sql2dbml/filename stdout/stdout.txt +0 -0
  163. package/__tests__/sql2dbml/filenames --mysql --out-file/expect-out-files/schema.dbml +0 -0
  164. package/__tests__/sql2dbml/filenames --mysql --out-file/in-files/business.sql +0 -0
  165. package/__tests__/sql2dbml/filenames --mysql --out-file/in-files/customer.sql +0 -0
  166. package/__tests__/sql2dbml/filenames --mysql --out-file/in-files/inventory.sql +0 -0
  167. package/__tests__/sql2dbml/filenames --mysql --out-file/options.json +0 -0
  168. package/__tests__/sql2dbml/filenames --mysql --out-file/stdout.txt +0 -0
  169. package/__tests__/sql2dbml/filenames --mysql stdout/in-files/business.sql +0 -0
  170. package/__tests__/sql2dbml/filenames --mysql stdout/in-files/customer.sql +0 -0
  171. package/__tests__/sql2dbml/filenames --mysql stdout/in-files/inventory.sql +0 -0
  172. package/__tests__/sql2dbml/filenames --mysql stdout/options.json +0 -0
  173. package/__tests__/sql2dbml/filenames --mysql stdout/stdout.txt +0 -0
  174. package/__tests__/sql2dbml/filenames --out-file/expect-out-files/schema.dbml +0 -0
  175. package/__tests__/sql2dbml/filenames --out-file/in-files/business.sql +0 -0
  176. package/__tests__/sql2dbml/filenames --out-file/in-files/customer.sql +0 -0
  177. package/__tests__/sql2dbml/filenames --out-file/in-files/inventory.sql +0 -0
  178. package/__tests__/sql2dbml/filenames --out-file/options.json +0 -0
  179. package/__tests__/sql2dbml/filenames --out-file/stdout.txt +0 -0
  180. package/__tests__/sql2dbml/filenames --postgres --out-file/expect-out-files/schema.dbml +0 -0
  181. package/__tests__/sql2dbml/filenames --postgres --out-file/in-files/business.sql +0 -0
  182. package/__tests__/sql2dbml/filenames --postgres --out-file/in-files/customer.sql +0 -0
  183. package/__tests__/sql2dbml/filenames --postgres --out-file/in-files/inventory.sql +0 -0
  184. package/__tests__/sql2dbml/filenames --postgres --out-file/options.json +0 -0
  185. package/__tests__/sql2dbml/filenames --postgres --out-file/stdout.txt +0 -0
  186. package/__tests__/sql2dbml/filenames --postgres stdout/in-files/business.sql +0 -0
  187. package/__tests__/sql2dbml/filenames --postgres stdout/in-files/customer.sql +0 -0
  188. package/__tests__/sql2dbml/filenames --postgres stdout/in-files/inventory.sql +0 -0
  189. package/__tests__/sql2dbml/filenames --postgres stdout/options.json +0 -0
  190. package/__tests__/sql2dbml/filenames --postgres stdout/stdout.txt +0 -0
  191. package/__tests__/sql2dbml/filenames stdout/in-files/business.sql +0 -0
  192. package/__tests__/sql2dbml/filenames stdout/in-files/customer.sql +0 -0
  193. package/__tests__/sql2dbml/filenames stdout/in-files/inventory.sql +0 -0
  194. package/__tests__/sql2dbml/filenames stdout/options.json +0 -0
  195. package/__tests__/sql2dbml/filenames stdout/stdout.txt +0 -0
  196. package/__tests__/sql2dbml/multiple_schema_mssql/expect-out-files/multiple_schema.out.dbml +0 -0
  197. package/__tests__/sql2dbml/multiple_schema_mssql/in-files/multiple_schema.in.sql +0 -0
  198. package/__tests__/sql2dbml/multiple_schema_mssql/options.json +0 -0
  199. package/__tests__/sql2dbml/multiple_schema_mssql/stdout.txt +0 -0
  200. package/__tests__/sql2dbml/multiple_schema_mysql/expect-out-files/multiple_schema.out.dbml +0 -0
  201. package/__tests__/sql2dbml/multiple_schema_mysql/in-files/multiple_schema.in.sql +0 -0
  202. package/__tests__/sql2dbml/multiple_schema_mysql/options.json +0 -0
  203. package/__tests__/sql2dbml/multiple_schema_mysql/stdout.txt +0 -0
  204. package/__tests__/sql2dbml/multiple_schema_pg/expect-out-files/multiple_schema.out.dbml +0 -0
  205. package/__tests__/sql2dbml/multiple_schema_pg/in-files/multiple_schema.in.sql +0 -0
  206. package/__tests__/sql2dbml/multiple_schema_pg/options.json +0 -0
  207. package/__tests__/sql2dbml/multiple_schema_pg/stdout.txt +0 -0
  208. package/__tests__/sql2dbml/syntax-error/in-files/business.sql +0 -0
  209. package/__tests__/sql2dbml/syntax-error/options.json +0 -0
  210. package/__tests__/sql2dbml/syntax-error/stdout.txt +0 -0
  211. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/in-files/schema.sql +0 -0
  212. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/options.json +0 -0
  213. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mssql/stdout.txt +0 -0
  214. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/in-files/schema.sql +0 -0
  215. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/options.json +0 -0
  216. package/__tests__/sql2dbml/syntax-error-duplicate-endpoints --mysql/stdout.txt +0 -0
  217. package/__tests__/sql2dbml_bin.js +3 -1
  218. package/__tests__/testHelpers.ts +0 -0
  219. package/eslint.config.ts +46 -9
  220. package/lib/index.js +178 -179
  221. package/package.json +5 -4
  222. package/src/cli/{config.js → config.ts} +3 -1
  223. package/src/cli/{connector.js → connector.ts} +19 -10
  224. package/src/cli/{export.js → export.ts} +30 -15
  225. package/src/cli/{import.js → import.ts} +29 -15
  226. package/src/cli/{index.js → index.ts} +7 -7
  227. package/src/cli/outputPlugins/{outputConsolePlugin.js → outputConsolePlugin.ts} +1 -1
  228. package/src/cli/outputPlugins/{outputFilePlugin.js → outputFilePlugin.ts} +10 -3
  229. package/src/cli/{utils.js → utils.ts} +36 -13
  230. package/src/cli/validatePlugins/{validatePlugins.js → validatePlugins.ts} +2 -2
  231. package/src/errors/{domainError.js → domainError.ts} +3 -1
  232. package/src/errors/{index.js → index.ts} +0 -0
  233. package/src/errors/{syntaxError.js → syntaxError.ts} +15 -2
  234. package/src/helpers/{logger.js → logger.ts} +29 -16
  235. package/src/index.ts +9 -0
  236. package/tsconfig.json +0 -0
  237. package/vite.config.ts +1 -1
  238. package/__test__/dbml2sql/filename --mysql --out-file/dbml-error.log +0 -36
  239. package/__test__/dbml2sql/filename --mysql --out-file/out-files/schema.sql +0 -65
  240. package/__test__/dbml2sql/filename --mysql stdout/dbml-error.log +0 -0
  241. package/__test__/dbml2sql/filename --oracle --out-file/dbml-error.log +0 -0
  242. package/__test__/dbml2sql/filename --oracle --out-file/out-files/schema.sql +0 -61
  243. package/__test__/dbml2sql/filename --oracle stdout/dbml-error.log +0 -0
  244. package/__test__/dbml2sql/filename --out-file/dbml-error.log +0 -36
  245. package/__test__/dbml2sql/filename --out-file/out-files/schema.sql +0 -77
  246. package/__test__/dbml2sql/filename --postgres --out-file/dbml-error.log +0 -24
  247. package/__test__/dbml2sql/filename --postgres --out-file/out-files/schema.sql +0 -77
  248. package/__test__/dbml2sql/filename --postgres stdout/dbml-error.log +0 -0
  249. package/__test__/dbml2sql/filename stdout/dbml-error.log +0 -0
  250. package/__test__/dbml2sql/filenames --mysql --out-file/dbml-error.log +0 -24
  251. package/__test__/dbml2sql/filenames --mysql --out-file/out-files/schema.sql +0 -172
  252. package/__test__/dbml2sql/filenames --mysql stdout/dbml-error.log +0 -0
  253. package/__test__/dbml2sql/filenames --oracle --out-file/dbml-error.log +0 -0
  254. package/__test__/dbml2sql/filenames --oracle --out-file/out-files/schema.sql +0 -172
  255. package/__test__/dbml2sql/filenames --oracle stdout/dbml-error.log +0 -0
  256. package/__test__/dbml2sql/filenames --out-file/dbml-error.log +0 -24
  257. package/__test__/dbml2sql/filenames --out-file/out-files/schema.sql +0 -172
  258. package/__test__/dbml2sql/filenames --postgres --out-file/dbml-error.log +0 -24
  259. package/__test__/dbml2sql/filenames --postgres --out-file/out-files/schema.sql +0 -172
  260. package/__test__/dbml2sql/filenames --postgres stdout/dbml-error.log +0 -0
  261. package/__test__/dbml2sql/filenames stdout/dbml-error.log +0 -0
  262. package/__test__/dbml2sql/multiple_schema_mssql/dbml-error.log +0 -24
  263. package/__test__/dbml2sql/multiple_schema_mssql/out-files/multiple_schema.out.sql +0 -62
  264. package/__test__/dbml2sql/multiple_schema_mysql/dbml-error.log +0 -24
  265. package/__test__/dbml2sql/multiple_schema_mysql/out-files/multiple_schema.out.sql +0 -50
  266. package/__test__/dbml2sql/multiple_schema_oracle/dbml-error.log +0 -0
  267. package/__test__/dbml2sql/multiple_schema_oracle/out-files/multiple_schema.out.sql +0 -88
  268. package/__test__/dbml2sql/multiple_schema_pg/dbml-error.log +0 -24
  269. package/__test__/dbml2sql/multiple_schema_pg/out-files/multiple_schema.out.sql +0 -67
  270. package/__test__/dbml2sql/syntax-error/dbml-error.log +0 -2112
  271. package/__test__/sql2dbml/filename --mssql --out-file/dbml-error.log +0 -51
  272. package/__test__/sql2dbml/filename --mssql --out-file/out-files/schema.dbml +0 -25
  273. package/__test__/sql2dbml/filename --mysql --out-file/dbml-error.log +0 -24
  274. package/__test__/sql2dbml/filename --mysql --out-file/out-files/schema.dbml +0 -74
  275. package/__test__/sql2dbml/filename --mysql stdout/dbml-error.log +0 -0
  276. package/__test__/sql2dbml/filename --out-file/dbml-error.log +0 -24
  277. package/__test__/sql2dbml/filename --out-file/out-files/schema.dbml +0 -74
  278. package/__test__/sql2dbml/filename --postgres --out-file/dbml-error.log +0 -24
  279. package/__test__/sql2dbml/filename --postgres --out-file/out-files/schema.dbml +0 -74
  280. package/__test__/sql2dbml/filename --postgres stdout/dbml-error.log +0 -0
  281. package/__test__/sql2dbml/filename --snowflake stdout/dbml-error.log +0 -54
  282. package/__test__/sql2dbml/filename stdout/dbml-error.log +0 -0
  283. package/__test__/sql2dbml/filenames --mysql --out-file/dbml-error.log +0 -24
  284. package/__test__/sql2dbml/filenames --mysql --out-file/out-files/schema.dbml +0 -170
  285. package/__test__/sql2dbml/filenames --mysql stdout/dbml-error.log +0 -0
  286. package/__test__/sql2dbml/filenames --out-file/dbml-error.log +0 -24
  287. package/__test__/sql2dbml/filenames --out-file/out-files/schema.dbml +0 -170
  288. package/__test__/sql2dbml/filenames --postgres --out-file/dbml-error.log +0 -24
  289. package/__test__/sql2dbml/filenames --postgres --out-file/out-files/schema.dbml +0 -170
  290. package/__test__/sql2dbml/filenames --postgres stdout/dbml-error.log +0 -3
  291. package/__test__/sql2dbml/filenames stdout/dbml-error.log +0 -0
  292. package/__test__/sql2dbml/multiple_schema_mssql/dbml-error.log +0 -121
  293. package/__test__/sql2dbml/multiple_schema_mssql/out-files/multiple_schema.out.dbml +0 -106
  294. package/__test__/sql2dbml/multiple_schema_mysql/dbml-error.log +0 -104
  295. package/__test__/sql2dbml/multiple_schema_mysql/out-files/multiple_schema.out.dbml +0 -136
  296. package/__test__/sql2dbml/multiple_schema_pg/dbml-error.log +0 -131
  297. package/__test__/sql2dbml/multiple_schema_pg/out-files/multiple_schema.out.dbml +0 -101
  298. package/__test__/sql2dbml/syntax-error/dbml-error.log +0 -2088
  299. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mssql/dbml-error.log +0 -36
  300. package/__test__/sql2dbml/syntax-error-duplicate-endpoints --mysql/dbml-error.log +0 -39
  301. package/dbml-error.log +0 -330
  302. package/src/index.js +0 -7
@@ -1,27 +1,39 @@
1
- import { importer } from '@dbml/core';
2
- import figures from 'figures';
3
- import chalk from 'chalk';
4
1
  import path from 'path';
2
+ import {
3
+ CompilerError, importer,
4
+ } from '@dbml/core';
5
+ import type {
6
+ ImportFormat,
7
+ } from '@dbml/core';
8
+ import chalk from 'chalk';
9
+ import {
10
+ Command,
11
+ } from 'commander';
12
+ import figures from 'figures';
13
+ import {
14
+ SyntaxError,
15
+ } from '../errors';
16
+ import logger from '../helpers/logger';
5
17
  import config from './config';
18
+ import OutputConsolePlugin from './outputPlugins/outputConsolePlugin';
19
+ import OutputFilePlugin from './outputPlugins/outputFilePlugin';
6
20
  import {
7
- validateInputFilePaths,
8
- resolvePaths,
9
- getFormatOpt,
10
21
  generate,
22
+ getFormatOpt,
23
+ resolvePaths,
24
+ validateInputFilePaths,
11
25
  } from './utils';
12
- import { validateFilePlugin } from './validatePlugins/validatePlugins';
13
- import OutputConsolePlugin from './outputPlugins/outputConsolePlugin';
14
- import OutputFilePlugin from './outputPlugins/outputFilePlugin';
15
- import logger from '../helpers/logger';
16
- import { SyntaxError } from '../errors';
26
+ import {
27
+ validateFilePlugin,
28
+ } from './validatePlugins/validatePlugins';
17
29
 
18
- export default async function importHandler (program) {
30
+ export default async function importHandler (program: Command) {
19
31
  try {
20
32
  const inputPaths = resolvePaths(program.args);
21
33
  validateInputFilePaths(inputPaths, validateFilePlugin);
22
34
  const opts = program.opts();
23
35
 
24
- const format = getFormatOpt(opts);
36
+ const format = getFormatOpt(opts) as ImportFormat;
25
37
 
26
38
  if (!opts.outFile && !opts.outDir) {
27
39
  generate(inputPaths, (sql) => importer.import(sql, format), OutputConsolePlugin);
@@ -31,8 +43,10 @@ export default async function importHandler (program) {
31
43
  console.log(` ${chalk.green(figures.main.tick)} Generated DBML file from SQL file (${config[format].name}): ${path.basename(opts.outFile)}`);
32
44
  }
33
45
  } catch (error) {
34
- if ('diags' in error) {
35
- logger.error(`\n ${error.diags.map((diag) => new SyntaxError(diag.filepath, diag)).map(({ message }) => message).join('\n ')}`);
46
+ if (error instanceof CompilerError) {
47
+ logger.error(`\n ${error.diags.map((diag) => new SyntaxError(diag.filepath ?? '', diag)).map(({
48
+ message,
49
+ }) => message).join('\n ')}`);
36
50
  return;
37
51
  }
38
52
  throw error;
@@ -1,14 +1,14 @@
1
1
  import program from 'commander';
2
- import importHandler from './import';
3
- import exportHandler from './export';
4
- import connectionHandler from './connector';
5
2
  import projectInfo from '../../package.json';
3
+ import connectionHandler from './connector';
4
+ import exportHandler from './export';
5
+ import importHandler from './import';
6
6
 
7
- function showHelp (args) {
7
+ function showHelp (args: string[]) {
8
8
  if (args.length < 3) program.help();
9
9
  }
10
10
 
11
- function dbml2sql (args) {
11
+ function dbml2sql (args: string[]) {
12
12
  program.version(projectInfo.version);
13
13
 
14
14
  program
@@ -26,7 +26,7 @@ function dbml2sql (args) {
26
26
  exportHandler(program);
27
27
  }
28
28
 
29
- function sql2dbml (args) {
29
+ function sql2dbml (args: string[]) {
30
30
  program.version(projectInfo.version);
31
31
 
32
32
  program
@@ -48,7 +48,7 @@ function sql2dbml (args) {
48
48
  importHandler(program);
49
49
  }
50
50
 
51
- function db2dbml (args) {
51
+ function db2dbml (args: string[]) {
52
52
  program.version(projectInfo.version);
53
53
 
54
54
  const description = `Generate DBML directly from a database
@@ -1,5 +1,5 @@
1
1
  class OutputConsolePlugin {
2
- static write (content) {
2
+ static write (content: string) {
3
3
  console.log(content);
4
4
  }
5
5
  }
@@ -1,7 +1,12 @@
1
1
  import fs from 'fs';
2
2
 
3
3
  class OutputFilePlugin {
4
- constructor (filePath, header) {
4
+ filePath: string;
5
+ header: string | undefined;
6
+ isWrite: boolean;
7
+ stream!: fs.WriteStream;
8
+
9
+ constructor (filePath: string, header?: string) {
5
10
  this.filePath = filePath;
6
11
  this.header = header;
7
12
  this.isWrite = false;
@@ -9,12 +14,14 @@ class OutputFilePlugin {
9
14
 
10
15
  start () {
11
16
  fs.writeFileSync(this.filePath, '');
12
- this.stream = fs.createWriteStream(this.filePath, { flags: 'a' });
17
+ this.stream = fs.createWriteStream(this.filePath, {
18
+ flags: 'a',
19
+ });
13
20
  if (this.header) this.stream.write(this.header);
14
21
  this.isWrite = true;
15
22
  }
16
23
 
17
- write (content) {
24
+ write (content: string) {
18
25
  if (!this.isWrite) this.start();
19
26
  this.stream.write(content);
20
27
  }
@@ -1,41 +1,57 @@
1
- import path from 'path';
2
1
  import fs from 'fs';
3
- import { CompilerError } from '@dbml/core';
4
- import { reduce } from 'lodash-es';
2
+ import path from 'path';
3
+ import {
4
+ CompilerError,
5
+ type ExportFormat,
6
+ } from '@dbml/core';
7
+ import {
8
+ reduce,
9
+ } from 'lodash-es';
10
+
11
+ interface OutputPlugin {
12
+ write(content: string): void;
13
+ }
14
+
15
+ interface ConnectionOpt {
16
+ connection: string;
17
+ databaseType: string;
18
+ }
5
19
 
6
- function resolvePaths (paths) {
20
+ function resolvePaths (paths: string): string;
21
+ function resolvePaths (paths: string[]): string[];
22
+ function resolvePaths (paths: string | string[]): string | string[] {
7
23
  if (!Array.isArray(paths)) {
8
24
  return path.resolve(process.cwd(), paths);
9
25
  }
10
26
  return paths.map((_path) => path.resolve(process.cwd(), _path));
11
27
  }
12
28
 
13
- function validateInputFilePaths (paths, validatePlugin) {
29
+ function validateInputFilePaths (paths: string[], validatePlugin: (_path: string) => void) {
14
30
  return paths.every((_path) => validatePlugin(_path));
15
31
  }
16
32
 
17
- function getFormatOpt (opts) {
33
+ function getFormatOpt (opts: Record<string, unknown>): ExportFormat {
18
34
  const formatOpts = Object.keys(opts).filter((opt) => {
19
35
  return ['postgres', 'mysql', 'mssql', 'postgresLegacy', 'mysqlLegacy', 'mssqlLegacy', 'oracle', 'snowflake'].includes(opt);
20
36
  });
21
37
 
22
- let format = 'postgres';
38
+ let format: ExportFormat = 'postgres';
23
39
  let cnt = 0;
24
40
 
25
41
  formatOpts.forEach((opt) => {
26
42
  if (opts[opt]) {
27
43
  cnt += 1;
28
44
  if (cnt > 1) throw new Error('Too many format options');
29
- format = opt;
45
+ format = opt as ExportFormat;
30
46
  }
31
47
  });
32
48
 
33
- return format;
49
+ return format as ExportFormat;
34
50
  }
35
51
 
36
- function getConnectionOpt (args) {
52
+ function getConnectionOpt (args: string[]): ConnectionOpt {
37
53
  const supportedDatabases = ['postgres', 'mysql', 'mssql', 'snowflake', 'bigquery', 'oracle'];
38
- const defaultConnectionOpt = {
54
+ const defaultConnectionOpt: ConnectionOpt = {
39
55
  connection: args[0],
40
56
  databaseType: 'unknown',
41
57
  };
@@ -61,7 +77,11 @@ function getConnectionOpt (args) {
61
77
  }, defaultConnectionOpt);
62
78
  }
63
79
 
64
- function generate (inputPaths, transform, outputPlugin) {
80
+ function generate (
81
+ inputPaths: string[],
82
+ transform: (source: string) => string,
83
+ outputPlugin: OutputPlugin,
84
+ ): void {
65
85
  inputPaths.forEach((_path) => {
66
86
  const source = fs.readFileSync(_path, 'utf-8');
67
87
  try {
@@ -70,7 +90,10 @@ function generate (inputPaths, transform, outputPlugin) {
70
90
  } catch (e) {
71
91
  if (e instanceof CompilerError) {
72
92
  throw e.map((diag) => ({
73
- ...diag, message: diag.message, filepath: path.basename(_path), stack: diag.stack,
93
+ ...diag,
94
+ message: diag.message,
95
+ filepath: path.basename(_path),
96
+ stack: diag.stack,
74
97
  }));
75
98
  }
76
99
  throw e;
@@ -1,8 +1,8 @@
1
1
  import fs from 'fs';
2
2
 
3
- function validateFilePlugin (_path) {
3
+ function validateFilePlugin (_path: string) {
4
4
  const stat = fs.statSync(_path);
5
- if (stat.isDirectory(_path)) {
5
+ if (stat.isDirectory()) {
6
6
  throw new Error('Expect input to be files');
7
7
  }
8
8
  }
@@ -1,5 +1,7 @@
1
1
  class DomainError extends Error {
2
- constructor (message, rootError = {}) {
2
+ rootError: unknown;
3
+
4
+ constructor (message: string, rootError: unknown = {}) {
3
5
  super(message);
4
6
  this.name = this.constructor.name;
5
7
  this.rootError = rootError;
File without changes
@@ -1,8 +1,21 @@
1
- import { isEmpty } from 'lodash-es';
1
+ import {
2
+ isEmpty,
3
+ } from 'lodash-es';
2
4
  import DomainError from './domainError';
3
5
 
6
+ interface RootError {
7
+ location?: {
8
+ start: {
9
+ line: number;
10
+ column: number;
11
+ };
12
+ };
13
+ message?: string;
14
+ stack?: unknown;
15
+ }
16
+
4
17
  class SyntaxError extends DomainError {
5
- constructor (fileName, rootError = {}) {
18
+ constructor (fileName: string, rootError: RootError = {}) {
6
19
  let message = `You have a syntax error at "${fileName}"`;
7
20
 
8
21
  if (rootError.location) {
@@ -1,19 +1,30 @@
1
- import { createLogger, format, transports } from 'winston';
2
- import chalk from 'chalk';
3
1
  import path from 'path';
2
+ import chalk from 'chalk';
3
+ import {
4
+ createLogger, format, transports,
5
+ } from 'winston';
4
6
 
5
- const { combine, timestamp, printf } = format;
7
+ const {
8
+ combine, timestamp, printf,
9
+ } = format;
6
10
 
7
11
  const consoleFormat = printf((info) => {
8
- const { level, message } = info;
12
+ const {
13
+ level, message,
14
+ } = info;
9
15
  return ` ${chalk.red(level.toUpperCase())}: ${message}\n
10
16
  A complete log can be found in:
11
17
  ${path.resolve(process.cwd(), 'dbml-error.log')}`;
12
18
  });
13
19
 
14
20
  const fileFormat = printf((info) => {
15
- const { timestamp, stack, rootError } = info;
16
- let logContent = `${timestamp}\n${stack}\n`;
21
+ const {
22
+ timestamp: ts, stack, rootError,
23
+ } = info as unknown as { timestamp: string;
24
+ stack?: string;
25
+ rootError?: { stack?: string;
26
+ location?: unknown; }; };
27
+ let logContent = `${ts}\n${stack}\n`;
17
28
  if (rootError) {
18
29
  logContent += '\nROOT_ERROR:';
19
30
  logContent += `\n${rootError.stack}`;
@@ -30,7 +41,9 @@ const consoleLogger = createLogger({
30
41
  consoleFormat,
31
42
  ),
32
43
  transports: [
33
- new transports.Console({ level: 'error' }),
44
+ new transports.Console({
45
+ level: 'error',
46
+ }),
34
47
  ],
35
48
  });
36
49
 
@@ -40,28 +53,28 @@ const fileLogger = createLogger({
40
53
  fileFormat,
41
54
  ),
42
55
  transports: [
43
- new transports.File({ filename: 'dbml-error.log', level: 'error' }),
56
+ new transports.File({
57
+ filename: 'dbml-error.log',
58
+ level: 'error',
59
+ }),
44
60
  ],
45
61
  });
46
62
 
47
63
  const logger = {
48
- debug (msg) {
64
+ debug (msg: string) {
49
65
  consoleLogger.debug(msg);
50
66
  },
51
- info (msg) {
67
+ info (msg: string) {
52
68
  consoleLogger.info(msg);
53
69
  },
54
- warn (msg) {
70
+ warn (msg: string) {
55
71
  consoleLogger.warn(msg);
56
72
  },
57
- error (msg) {
73
+
74
+ error (msg: any) {
58
75
  consoleLogger.error(msg);
59
76
  fileLogger.error(msg);
60
77
  },
61
- log (level, msg) {
62
- const lvl = exports[level];
63
- lvl(msg);
64
- },
65
78
  };
66
79
 
67
80
  export default logger;
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ db2dbml, dbml2sql, sql2dbml,
3
+ } from './cli';
4
+
5
+ export {
6
+ dbml2sql,
7
+ sql2dbml,
8
+ db2dbml,
9
+ };
package/tsconfig.json CHANGED
File without changes
package/vite.config.ts CHANGED
@@ -14,7 +14,7 @@ export default defineConfig({
14
14
  outDir: 'lib',
15
15
  minify: false,
16
16
  lib: {
17
- entry: path.resolve(__dirname, 'src/index.js'),
17
+ entry: path.resolve(__dirname, 'src/index.ts'),
18
18
  fileName: 'index',
19
19
  formats: ['cjs'],
20
20
  },
@@ -1,36 +0,0 @@
1
- 2021-07-13T12:37:40.734Z
2
- TypeError: Cannot read property 'tick' of undefined
3
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:56)
4
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
5
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
6
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
7
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
8
- at Module.load (internal/modules/cjs/loader.js:950:32)
9
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
10
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
11
- at internal/main/run_main_module.js:17:47
12
-
13
- 2021-07-13T12:47:15.905Z
14
- TypeError: Cannot read property 'tick' of undefined
15
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:56)
16
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
17
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
18
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
19
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
20
- at Module.load (internal/modules/cjs/loader.js:950:32)
21
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
22
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
23
- at internal/main/run_main_module.js:17:47
24
-
25
- 2021-07-13T12:58:20.418Z
26
- TypeError: Cannot read property 'tick' of undefined
27
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:49)
28
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
29
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
30
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
31
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
32
- at Module.load (internal/modules/cjs/loader.js:950:32)
33
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
34
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
35
- at internal/main/run_main_module.js:17:47
36
-
@@ -1,65 +0,0 @@
1
- -- SQL dump generated using DBML (dbml.dbdiagram.io)
2
- -- Database: MySQL
3
- -- Generated at: 2024-08-12T11:56:40.986Z
4
-
5
- CREATE TABLE `orders` (
6
- `id` int PRIMARY KEY AUTO_INCREMENT,
7
- `user_id` int UNIQUE NOT NULL,
8
- `status` ENUM ('created', 'running', 'done', 'failure'),
9
- `created_at` varchar(255)
10
- );
11
-
12
- CREATE TABLE `order_items` (
13
- `order_id` int,
14
- `product_id` int,
15
- `quantity` int DEFAULT 1
16
- );
17
-
18
- CREATE TABLE `products` (
19
- `id` int PRIMARY KEY,
20
- `name` varchar(255),
21
- `merchant_id` int NOT NULL,
22
- `price` int,
23
- `status` ENUM ('Out of Stock', 'In Stock'),
24
- `created_at` datetime DEFAULT (now())
25
- );
26
-
27
- CREATE TABLE `users` (
28
- `id` int PRIMARY KEY,
29
- `full_name` varchar(255),
30
- `email` varchar(255) UNIQUE,
31
- `gender` varchar(255),
32
- `date_of_birth` varchar(255),
33
- `created_at` varchar(255),
34
- `country_code` int
35
- );
36
-
37
- CREATE TABLE `merchants` (
38
- `id` int PRIMARY KEY,
39
- `merchant_name` varchar(255),
40
- `country_code` int,
41
- `created_at` varchar(255),
42
- `admin_id` int
43
- );
44
-
45
- CREATE TABLE `countries` (
46
- `code` int PRIMARY KEY,
47
- `name` varchar(255),
48
- `continent_name` varchar(255)
49
- );
50
-
51
- CREATE INDEX `product_status` ON `products` (`merchant_id`, `status`);
52
-
53
- CREATE UNIQUE INDEX `products_index_1` ON `products` (`id`) USING HASH;
54
-
55
- ALTER TABLE `order_items` ADD FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`);
56
-
57
- ALTER TABLE `order_items` ADD FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);
58
-
59
- ALTER TABLE `users` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
60
-
61
- ALTER TABLE `merchants` ADD FOREIGN KEY (`country_code`) REFERENCES `countries` (`code`);
62
-
63
- ALTER TABLE `products` ADD FOREIGN KEY (`merchant_id`) REFERENCES `merchants` (`id`);
64
-
65
- ALTER TABLE `merchants` ADD FOREIGN KEY (`admin_id`) REFERENCES `users` (`id`);
@@ -1,61 +0,0 @@
1
- -- SQL dump generated using DBML (dbml.dbdiagram.io)
2
- -- Database: Oracle
3
- -- Generated at: 2024-08-12T11:56:41.926Z
4
-
5
- CREATE TABLE "orders" (
6
- "id" int GENERATED AS IDENTITY PRIMARY KEY,
7
- "user_id" int UNIQUE NOT NULL,
8
- "status" nvarchar2(255) NOT NULL CHECK ("status" IN ('created', 'running', 'done', 'failure'))
9
- );
10
-
11
- CREATE TABLE "order_items" (
12
- "order_id" int,
13
- "product_id" int,
14
- "quantity" int DEFAULT 1
15
- );
16
-
17
- CREATE TABLE "products" (
18
- "id" int PRIMARY KEY,
19
- "name" nvarchar2(255),
20
- "merchant_id" int NOT NULL,
21
- "price" int,
22
- "status" nvarchar2(255) NOT NULL CHECK ("status" IN ('Out of Stock', 'In Stock')),
23
- "created_at" timestamp DEFAULT current_timestamp
24
- );
25
-
26
- CREATE TABLE "users" (
27
- "id" int PRIMARY KEY,
28
- "full_name" nvarchar2(255),
29
- "email" nvarchar2(255) UNIQUE,
30
- "gender" nvarchar2(255),
31
- "date_of_birth" date,
32
- "created_at" timestamp,
33
- "country_code" int
34
- );
35
-
36
- CREATE TABLE "merchants" (
37
- "id" int PRIMARY KEY,
38
- "merchant_name" nvarchar2(255),
39
- "country_code" int,
40
- "created_at" timestamp,
41
- "admin_id" int
42
- );
43
-
44
- CREATE TABLE "countries" (
45
- "code" int PRIMARY KEY,
46
- "name" nvarchar2(255)
47
- );
48
-
49
- CREATE INDEX "product_status" ON "products" ("merchant_id", "status");
50
-
51
- ALTER TABLE "order_items" ADD FOREIGN KEY ("order_id") REFERENCES "orders" ("id");
52
-
53
- ALTER TABLE "order_items" ADD FOREIGN KEY ("product_id") REFERENCES "products" ("id");
54
-
55
- ALTER TABLE "users" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
56
-
57
- ALTER TABLE "merchants" ADD FOREIGN KEY ("country_code") REFERENCES "countries" ("code");
58
-
59
- ALTER TABLE "products" ADD FOREIGN KEY ("merchant_id") REFERENCES "merchants" ("id");
60
-
61
- ALTER TABLE "merchants" ADD FOREIGN KEY ("admin_id") REFERENCES "users" ("id");
@@ -1,36 +0,0 @@
1
- 2021-07-13T12:37:43.283Z
2
- TypeError: Cannot read property 'tick' of undefined
3
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:56)
4
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
5
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
6
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
7
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
8
- at Module.load (internal/modules/cjs/loader.js:950:32)
9
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
10
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
11
- at internal/main/run_main_module.js:17:47
12
-
13
- 2021-07-13T12:47:19.039Z
14
- TypeError: Cannot read property 'tick' of undefined
15
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:56)
16
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
17
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
18
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
19
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
20
- at Module.load (internal/modules/cjs/loader.js:950:32)
21
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
22
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
23
- at internal/main/run_main_module.js:17:47
24
-
25
- 2021-07-13T12:58:22.994Z
26
- TypeError: Cannot read property 'tick' of undefined
27
- at exportHandler (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\export.js:37:49)
28
- at dbml2sql (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\src\cli\index.js:19:3)
29
- at Object.<anonymous> (C:\Users\Inspiron101\Desktop\Holistics\dbml\packages\dbml-cli\__test__\dbml2sql_bin.js:5:1)
30
- at Module._compile (internal/modules/cjs/loader.js:1085:14)
31
- at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
32
- at Module.load (internal/modules/cjs/loader.js:950:32)
33
- at Function.Module._load (internal/modules/cjs/loader.js:790:14)
34
- at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
35
- at internal/main/run_main_module.js:17:47
36
-