@warlock.js/cascade 4.1.15 → 4.2.1

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 (336) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +21 -0
  3. package/cjs/index.cjs +21388 -0
  4. package/cjs/index.cjs.map +1 -0
  5. package/esm/context/database-data-source-context.d.mts +1 -1
  6. package/esm/context/database-data-source-context.d.mts.map +1 -1
  7. package/esm/context/database-data-source-context.mjs +1 -1
  8. package/esm/context/database-data-source-context.mjs.map +1 -1
  9. package/esm/context/database-transaction-context.d.mts +1 -1
  10. package/esm/context/database-transaction-context.d.mts.map +1 -1
  11. package/esm/context/database-transaction-context.mjs +1 -1
  12. package/esm/context/database-transaction-context.mjs.map +1 -1
  13. package/esm/contracts/database-driver.contract.d.mts +1 -1
  14. package/esm/contracts/database-driver.contract.d.mts.map +1 -1
  15. package/esm/contracts/database-id-generator.contract.d.mts +1 -1
  16. package/esm/contracts/database-id-generator.contract.d.mts.map +1 -1
  17. package/esm/contracts/database-remover.contract.d.mts +1 -1
  18. package/esm/contracts/database-remover.contract.d.mts.map +1 -1
  19. package/esm/contracts/database-restorer.contract.d.mts +1 -1
  20. package/esm/contracts/database-restorer.contract.d.mts.map +1 -1
  21. package/esm/contracts/database-writer.contract.d.mts +1 -1
  22. package/esm/contracts/database-writer.contract.d.mts.map +1 -1
  23. package/esm/contracts/driver-blueprint.contract.d.mts +1 -1
  24. package/esm/contracts/driver-blueprint.contract.d.mts.map +1 -1
  25. package/esm/contracts/migration-driver.contract.d.mts +1 -1
  26. package/esm/contracts/migration-driver.contract.d.mts.map +1 -1
  27. package/esm/contracts/query-builder.contract.d.mts +1 -1
  28. package/esm/contracts/query-builder.contract.d.mts.map +1 -1
  29. package/esm/contracts/sync-adapter.contract.d.mts +1 -1
  30. package/esm/contracts/sync-adapter.contract.d.mts.map +1 -1
  31. package/esm/data-source/data-source-registry.d.mts +1 -1
  32. package/esm/data-source/data-source-registry.d.mts.map +1 -1
  33. package/esm/data-source/data-source-registry.mjs +1 -1
  34. package/esm/data-source/data-source-registry.mjs.map +1 -1
  35. package/esm/data-source/data-source.d.mts +1 -1
  36. package/esm/data-source/data-source.d.mts.map +1 -1
  37. package/esm/data-source/data-source.mjs +1 -1
  38. package/esm/data-source/data-source.mjs.map +1 -1
  39. package/esm/database-dirty-tracker.d.mts +1 -1
  40. package/esm/database-dirty-tracker.d.mts.map +1 -1
  41. package/esm/database-dirty-tracker.mjs +1 -1
  42. package/esm/database-dirty-tracker.mjs.map +1 -1
  43. package/esm/drivers/mongodb/mongodb-blueprint.mjs +1 -1
  44. package/esm/drivers/mongodb/mongodb-blueprint.mjs.map +1 -1
  45. package/esm/drivers/mongodb/mongodb-driver.d.mts +1 -1
  46. package/esm/drivers/mongodb/mongodb-driver.d.mts.map +1 -1
  47. package/esm/drivers/mongodb/mongodb-driver.mjs +2 -2
  48. package/esm/drivers/mongodb/mongodb-driver.mjs.map +1 -1
  49. package/esm/drivers/mongodb/mongodb-id-generator.d.mts +1 -1
  50. package/esm/drivers/mongodb/mongodb-id-generator.d.mts.map +1 -1
  51. package/esm/drivers/mongodb/mongodb-id-generator.mjs +1 -1
  52. package/esm/drivers/mongodb/mongodb-id-generator.mjs.map +1 -1
  53. package/esm/drivers/mongodb/mongodb-migration-driver.d.mts +1 -1
  54. package/esm/drivers/mongodb/mongodb-migration-driver.d.mts.map +1 -1
  55. package/esm/drivers/mongodb/mongodb-migration-driver.mjs +1 -1
  56. package/esm/drivers/mongodb/mongodb-migration-driver.mjs.map +1 -1
  57. package/esm/drivers/mongodb/mongodb-query-builder.d.mts +1 -1
  58. package/esm/drivers/mongodb/mongodb-query-builder.d.mts.map +1 -1
  59. package/esm/drivers/mongodb/mongodb-query-builder.mjs +1 -1
  60. package/esm/drivers/mongodb/mongodb-query-builder.mjs.map +1 -1
  61. package/esm/drivers/mongodb/mongodb-query-operations.d.mts +1 -1
  62. package/esm/drivers/mongodb/mongodb-query-operations.d.mts.map +1 -1
  63. package/esm/drivers/mongodb/mongodb-query-operations.mjs +1 -1
  64. package/esm/drivers/mongodb/mongodb-query-operations.mjs.map +1 -1
  65. package/esm/drivers/mongodb/mongodb-query-parser.d.mts +1 -1
  66. package/esm/drivers/mongodb/mongodb-query-parser.d.mts.map +1 -1
  67. package/esm/drivers/mongodb/mongodb-query-parser.mjs +1 -1
  68. package/esm/drivers/mongodb/mongodb-query-parser.mjs.map +1 -1
  69. package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts +1 -1
  70. package/esm/drivers/mongodb/mongodb-sync-adapter.d.mts.map +1 -1
  71. package/esm/drivers/mongodb/mongodb-sync-adapter.mjs +1 -1
  72. package/esm/drivers/mongodb/mongodb-sync-adapter.mjs.map +1 -1
  73. package/esm/drivers/mongodb/types.d.mts +1 -1
  74. package/esm/drivers/mongodb/types.d.mts.map +1 -1
  75. package/esm/drivers/postgres/postgres-blueprint.d.mts +1 -1
  76. package/esm/drivers/postgres/postgres-blueprint.d.mts.map +1 -1
  77. package/esm/drivers/postgres/postgres-blueprint.mjs +1 -1
  78. package/esm/drivers/postgres/postgres-blueprint.mjs.map +1 -1
  79. package/esm/drivers/postgres/postgres-dialect.d.mts +1 -1
  80. package/esm/drivers/postgres/postgres-dialect.d.mts.map +1 -1
  81. package/esm/drivers/postgres/postgres-dialect.mjs +1 -1
  82. package/esm/drivers/postgres/postgres-dialect.mjs.map +1 -1
  83. package/esm/drivers/postgres/postgres-driver.d.mts +1 -1
  84. package/esm/drivers/postgres/postgres-driver.d.mts.map +1 -1
  85. package/esm/drivers/postgres/postgres-driver.mjs +2 -2
  86. package/esm/drivers/postgres/postgres-driver.mjs.map +1 -1
  87. package/esm/drivers/postgres/postgres-migration-driver.d.mts +1 -1
  88. package/esm/drivers/postgres/postgres-migration-driver.d.mts.map +1 -1
  89. package/esm/drivers/postgres/postgres-migration-driver.mjs +1 -1
  90. package/esm/drivers/postgres/postgres-migration-driver.mjs.map +1 -1
  91. package/esm/drivers/postgres/postgres-query-builder.d.mts +1 -1
  92. package/esm/drivers/postgres/postgres-query-builder.d.mts.map +1 -1
  93. package/esm/drivers/postgres/postgres-query-builder.mjs +7 -5
  94. package/esm/drivers/postgres/postgres-query-builder.mjs.map +1 -1
  95. package/esm/drivers/postgres/postgres-query-parser.d.mts +1 -1
  96. package/esm/drivers/postgres/postgres-query-parser.d.mts.map +1 -1
  97. package/esm/drivers/postgres/postgres-query-parser.mjs +1 -1
  98. package/esm/drivers/postgres/postgres-query-parser.mjs.map +1 -1
  99. package/esm/drivers/postgres/postgres-sql-serializer.mjs +1 -1
  100. package/esm/drivers/postgres/postgres-sql-serializer.mjs.map +1 -1
  101. package/esm/drivers/postgres/postgres-sync-adapter.d.mts +1 -1
  102. package/esm/drivers/postgres/postgres-sync-adapter.d.mts.map +1 -1
  103. package/esm/drivers/postgres/postgres-sync-adapter.mjs +1 -1
  104. package/esm/drivers/postgres/postgres-sync-adapter.mjs.map +1 -1
  105. package/esm/drivers/postgres/types.d.mts +1 -1
  106. package/esm/drivers/postgres/types.d.mts.map +1 -1
  107. package/esm/drivers/sql/sql-dialect.contract.d.mts +1 -1
  108. package/esm/drivers/sql/sql-dialect.contract.d.mts.map +1 -1
  109. package/esm/drivers/sql/sql-types.d.mts +1 -1
  110. package/esm/drivers/sql/sql-types.d.mts.map +1 -1
  111. package/esm/errors/missing-data-source.error.d.mts +1 -1
  112. package/esm/errors/missing-data-source.error.d.mts.map +1 -1
  113. package/esm/errors/missing-data-source.error.mjs +1 -1
  114. package/esm/errors/missing-data-source.error.mjs.map +1 -1
  115. package/esm/errors/transaction-rollback.error.d.mts +1 -1
  116. package/esm/errors/transaction-rollback.error.d.mts.map +1 -1
  117. package/esm/errors/transaction-rollback.error.mjs +1 -1
  118. package/esm/errors/transaction-rollback.error.mjs.map +1 -1
  119. package/esm/events/model-events.d.mts +1 -1
  120. package/esm/events/model-events.d.mts.map +1 -1
  121. package/esm/events/model-events.mjs +1 -1
  122. package/esm/events/model-events.mjs.map +1 -1
  123. package/esm/expressions/aggregate-expressions.d.mts +1 -1
  124. package/esm/expressions/aggregate-expressions.d.mts.map +1 -1
  125. package/esm/expressions/aggregate-expressions.mjs +1 -1
  126. package/esm/expressions/aggregate-expressions.mjs.map +1 -1
  127. package/esm/migration/column-builder.d.mts +1 -1
  128. package/esm/migration/column-builder.d.mts.map +1 -1
  129. package/esm/migration/column-builder.mjs +1 -1
  130. package/esm/migration/column-builder.mjs.map +1 -1
  131. package/esm/migration/column-helpers.d.mts +1 -1
  132. package/esm/migration/column-helpers.d.mts.map +1 -1
  133. package/esm/migration/column-helpers.mjs +1 -1
  134. package/esm/migration/column-helpers.mjs.map +1 -1
  135. package/esm/migration/foreign-key-builder.d.mts +1 -1
  136. package/esm/migration/foreign-key-builder.d.mts.map +1 -1
  137. package/esm/migration/foreign-key-builder.mjs +1 -1
  138. package/esm/migration/foreign-key-builder.mjs.map +1 -1
  139. package/esm/migration/migration-runner.d.mts +1 -1
  140. package/esm/migration/migration-runner.d.mts.map +1 -1
  141. package/esm/migration/migration-runner.mjs +1 -1
  142. package/esm/migration/migration-runner.mjs.map +1 -1
  143. package/esm/migration/migration.d.mts +1 -1
  144. package/esm/migration/migration.d.mts.map +1 -1
  145. package/esm/migration/migration.mjs +1 -1
  146. package/esm/migration/migration.mjs.map +1 -1
  147. package/esm/migration/sql-grammar.mjs +1 -1
  148. package/esm/migration/sql-grammar.mjs.map +1 -1
  149. package/esm/migration/sql-serializer.d.mts +1 -1
  150. package/esm/migration/sql-serializer.d.mts.map +1 -1
  151. package/esm/migration/sql-serializer.mjs +1 -1
  152. package/esm/migration/sql-serializer.mjs.map +1 -1
  153. package/esm/migration/types.d.mts +1 -1
  154. package/esm/migration/types.d.mts.map +1 -1
  155. package/esm/model/methods/accessor-methods.mjs +1 -1
  156. package/esm/model/methods/accessor-methods.mjs.map +1 -1
  157. package/esm/model/methods/delete-methods.mjs +1 -1
  158. package/esm/model/methods/delete-methods.mjs.map +1 -1
  159. package/esm/model/methods/dirty-methods.mjs +1 -1
  160. package/esm/model/methods/dirty-methods.mjs.map +1 -1
  161. package/esm/model/methods/hydration-methods.mjs +1 -1
  162. package/esm/model/methods/hydration-methods.mjs.map +1 -1
  163. package/esm/model/methods/instance-event-methods.mjs +1 -1
  164. package/esm/model/methods/instance-event-methods.mjs.map +1 -1
  165. package/esm/model/methods/meta-methods.mjs +1 -1
  166. package/esm/model/methods/meta-methods.mjs.map +1 -1
  167. package/esm/model/methods/pivot-methods.mjs +1 -1
  168. package/esm/model/methods/pivot-methods.mjs.map +1 -1
  169. package/esm/model/methods/query-methods.mjs +1 -1
  170. package/esm/model/methods/query-methods.mjs.map +1 -1
  171. package/esm/model/methods/restore-methods.mjs +1 -1
  172. package/esm/model/methods/restore-methods.mjs.map +1 -1
  173. package/esm/model/methods/scope-methods.mjs +1 -1
  174. package/esm/model/methods/scope-methods.mjs.map +1 -1
  175. package/esm/model/methods/serialization-methods.mjs +1 -1
  176. package/esm/model/methods/serialization-methods.mjs.map +1 -1
  177. package/esm/model/methods/static-event-methods.mjs +1 -1
  178. package/esm/model/methods/static-event-methods.mjs.map +1 -1
  179. package/esm/model/methods/write-methods.mjs +1 -1
  180. package/esm/model/methods/write-methods.mjs.map +1 -1
  181. package/esm/model/model.d.mts +1 -1
  182. package/esm/model/model.d.mts.map +1 -1
  183. package/esm/model/model.mjs +1 -1
  184. package/esm/model/model.mjs.map +1 -1
  185. package/esm/model/model.types.d.mts +1 -1
  186. package/esm/model/model.types.d.mts.map +1 -1
  187. package/esm/model/register-model.d.mts +1 -1
  188. package/esm/model/register-model.d.mts.map +1 -1
  189. package/esm/model/register-model.mjs +1 -1
  190. package/esm/model/register-model.mjs.map +1 -1
  191. package/esm/model/relation-decorators.d.mts +1 -1
  192. package/esm/model/relation-decorators.d.mts.map +1 -1
  193. package/esm/model/relation-decorators.mjs +2 -2
  194. package/esm/model/relation-decorators.mjs.map +1 -1
  195. package/esm/operations/database.d.mts +1 -1
  196. package/esm/operations/database.d.mts.map +1 -1
  197. package/esm/operations/database.mjs +1 -1
  198. package/esm/operations/database.mjs.map +1 -1
  199. package/esm/operations/migrations.d.mts +1 -1
  200. package/esm/operations/migrations.d.mts.map +1 -1
  201. package/esm/operations/migrations.mjs +1 -1
  202. package/esm/operations/migrations.mjs.map +1 -1
  203. package/esm/query-builder/query-builder.d.mts +1 -1
  204. package/esm/query-builder/query-builder.d.mts.map +1 -1
  205. package/esm/query-builder/query-builder.mjs +1 -1
  206. package/esm/query-builder/query-builder.mjs.map +1 -1
  207. package/esm/relations/key-conventions.mjs +1 -1
  208. package/esm/relations/key-conventions.mjs.map +1 -1
  209. package/esm/relations/pivot-operations.d.mts +1 -1
  210. package/esm/relations/pivot-operations.d.mts.map +1 -1
  211. package/esm/relations/pivot-operations.mjs +1 -1
  212. package/esm/relations/pivot-operations.mjs.map +1 -1
  213. package/esm/relations/relation-hydrator.d.mts +1 -1
  214. package/esm/relations/relation-hydrator.d.mts.map +1 -1
  215. package/esm/relations/relation-hydrator.mjs +1 -1
  216. package/esm/relations/relation-hydrator.mjs.map +1 -1
  217. package/esm/relations/relation-loader.d.mts +1 -1
  218. package/esm/relations/relation-loader.d.mts.map +1 -1
  219. package/esm/relations/relation-loader.mjs +1 -1
  220. package/esm/relations/relation-loader.mjs.map +1 -1
  221. package/esm/relations/types.d.mts +1 -1
  222. package/esm/relations/types.d.mts.map +1 -1
  223. package/esm/remover/database-remover.d.mts +1 -1
  224. package/esm/remover/database-remover.d.mts.map +1 -1
  225. package/esm/remover/database-remover.mjs +1 -1
  226. package/esm/remover/database-remover.mjs.map +1 -1
  227. package/esm/restorer/database-restorer.d.mts +1 -1
  228. package/esm/restorer/database-restorer.d.mts.map +1 -1
  229. package/esm/restorer/database-restorer.mjs +1 -1
  230. package/esm/restorer/database-restorer.mjs.map +1 -1
  231. package/esm/sql-database-dirty-tracker.d.mts +1 -1
  232. package/esm/sql-database-dirty-tracker.d.mts.map +1 -1
  233. package/esm/sql-database-dirty-tracker.mjs +1 -1
  234. package/esm/sql-database-dirty-tracker.mjs.map +1 -1
  235. package/esm/sync/model-events.mjs +1 -1
  236. package/esm/sync/model-events.mjs.map +1 -1
  237. package/esm/sync/model-sync-operation.d.mts +1 -1
  238. package/esm/sync/model-sync-operation.d.mts.map +1 -1
  239. package/esm/sync/model-sync-operation.mjs +1 -1
  240. package/esm/sync/model-sync-operation.mjs.map +1 -1
  241. package/esm/sync/model-sync.d.mts +1 -1
  242. package/esm/sync/model-sync.d.mts.map +1 -1
  243. package/esm/sync/model-sync.mjs +1 -1
  244. package/esm/sync/model-sync.mjs.map +1 -1
  245. package/esm/sync/sync-context.d.mts +1 -1
  246. package/esm/sync/sync-context.d.mts.map +1 -1
  247. package/esm/sync/sync-context.mjs +1 -1
  248. package/esm/sync/sync-context.mjs.map +1 -1
  249. package/esm/sync/sync-manager.d.mts +1 -1
  250. package/esm/sync/sync-manager.d.mts.map +1 -1
  251. package/esm/sync/sync-manager.mjs +1 -1
  252. package/esm/sync/sync-manager.mjs.map +1 -1
  253. package/esm/sync/types.d.mts +1 -1
  254. package/esm/sync/types.d.mts.map +1 -1
  255. package/esm/types.d.mts +1 -1
  256. package/esm/types.d.mts.map +1 -1
  257. package/esm/utils/connect-to-database.d.mts +1 -1
  258. package/esm/utils/connect-to-database.d.mts.map +1 -1
  259. package/esm/utils/connect-to-database.mjs +1 -1
  260. package/esm/utils/connect-to-database.mjs.map +1 -1
  261. package/esm/utils/database-writer.utils.d.mts +1 -1
  262. package/esm/utils/database-writer.utils.d.mts.map +1 -1
  263. package/esm/utils/database-writer.utils.mjs +1 -1
  264. package/esm/utils/database-writer.utils.mjs.map +1 -1
  265. package/esm/utils/define-model.d.mts +1 -1
  266. package/esm/utils/define-model.d.mts.map +1 -1
  267. package/esm/utils/define-model.mjs +1 -1
  268. package/esm/utils/define-model.mjs.map +1 -1
  269. package/esm/utils/is-valid-date-value.mjs +1 -1
  270. package/esm/utils/is-valid-date-value.mjs.map +1 -1
  271. package/esm/utils/once-connected.d.mts +1 -1
  272. package/esm/utils/once-connected.d.mts.map +1 -1
  273. package/esm/utils/once-connected.mjs +1 -1
  274. package/esm/utils/once-connected.mjs.map +1 -1
  275. package/esm/validation/database-seal-plugins.mjs +1 -1
  276. package/esm/validation/database-seal-plugins.mjs.map +1 -1
  277. package/esm/validation/database-writer-validation-error.d.mts +1 -1
  278. package/esm/validation/database-writer-validation-error.d.mts.map +1 -1
  279. package/esm/validation/database-writer-validation-error.mjs +1 -1
  280. package/esm/validation/database-writer-validation-error.mjs.map +1 -1
  281. package/esm/validation/mutators/embed-mutator.mjs +1 -1
  282. package/esm/validation/mutators/embed-mutator.mjs.map +1 -1
  283. package/esm/validation/plugins/database-rules-plugin.d.mts +1 -1
  284. package/esm/validation/plugins/database-rules-plugin.d.mts.map +1 -1
  285. package/esm/validation/plugins/database-rules-plugin.mjs +1 -1
  286. package/esm/validation/plugins/database-rules-plugin.mjs.map +1 -1
  287. package/esm/validation/plugins/embed-validator-plugin.d.mts +1 -1
  288. package/esm/validation/plugins/embed-validator-plugin.d.mts.map +1 -1
  289. package/esm/validation/plugins/embed-validator-plugin.mjs +1 -1
  290. package/esm/validation/plugins/embed-validator-plugin.mjs.map +1 -1
  291. package/esm/validation/rules/database-model-rule.mjs +1 -1
  292. package/esm/validation/rules/database-model-rule.mjs.map +1 -1
  293. package/esm/validation/rules/exists-rule.mjs +1 -1
  294. package/esm/validation/rules/exists-rule.mjs.map +1 -1
  295. package/esm/validation/rules/unique-rule.mjs +1 -1
  296. package/esm/validation/rules/unique-rule.mjs.map +1 -1
  297. package/esm/validation/transformers/embed-model-transformer.mjs +1 -1
  298. package/esm/validation/transformers/embed-model-transformer.mjs.map +1 -1
  299. package/esm/validation/types.d.mts +1 -1
  300. package/esm/validation/types.d.mts.map +1 -1
  301. package/esm/validation/validators/embed-validator.d.mts +1 -1
  302. package/esm/validation/validators/embed-validator.d.mts.map +1 -1
  303. package/esm/validation/validators/embed-validator.mjs +1 -1
  304. package/esm/validation/validators/embed-validator.mjs.map +1 -1
  305. package/esm/writer/database-writer.d.mts +1 -1
  306. package/esm/writer/database-writer.d.mts.map +1 -1
  307. package/esm/writer/database-writer.mjs +1 -1
  308. package/esm/writer/database-writer.mjs.map +1 -1
  309. package/llms-full.txt +535 -0
  310. package/llms.txt +1 -0
  311. package/package.json +9 -12
  312. package/skills/README.md +4 -0
  313. package/skills/alter-migration/SKILL.md +531 -0
  314. package/esm/cli/commands/migrate-export-sql.mjs +0 -48
  315. package/esm/cli/commands/migrate-export-sql.mjs.map +0 -1
  316. package/esm/cli/commands/migrate-list.mjs +0 -26
  317. package/esm/cli/commands/migrate-list.mjs.map +0 -1
  318. package/esm/cli/commands/migrate-rollback.mjs +0 -50
  319. package/esm/cli/commands/migrate-rollback.mjs.map +0 -1
  320. package/esm/cli/commands/migrate.mjs +0 -65
  321. package/esm/cli/commands/migrate.mjs.map +0 -1
  322. package/esm/cli/connection-from-env.mjs +0 -181
  323. package/esm/cli/connection-from-env.mjs.map +0 -1
  324. package/esm/cli/index.mjs +0 -31
  325. package/esm/cli/index.mjs.map +0 -1
  326. package/esm/cli/load-migrations.mjs +0 -78
  327. package/esm/cli/load-migrations.mjs.map +0 -1
  328. package/esm/cli/printers.mjs +0 -57
  329. package/esm/cli/printers.mjs.map +0 -1
  330. package/esm/cli/setup-logger.mjs +0 -30
  331. package/esm/cli/setup-logger.mjs.map +0 -1
  332. package/esm/cli/with-cli-connection.mjs +0 -39
  333. package/esm/cli/with-cli-connection.mjs.map +0 -1
  334. package/esm/cli.d.mts +0 -1
  335. package/esm/cli.mjs +0 -26
  336. package/esm/cli.mjs.map +0 -1
@@ -0,0 +1,531 @@
1
+ ---
2
+ name: alter-migration
3
+ description: 'Evolve an existing table with `Migration.alter(Model, schema, options?)` — add/drop/rename/modify columns; add/drop regular, unique, expression, full-text, geo, vector, and TTL indexes; add/drop foreign keys and CHECK constraints; write rollbacks with class-form methods in `down()`. Triggers: "alter a table", "add a column to existing table", "drop a column", "rename a column", "add an index", "drop a unique constraint", "change a column type", `Migration.alter`, `dropUnique`, `addIndex`, `addForeign`. Skip: creating a brand-new table — `@warlock.js/cascade/write-migration/SKILL.md`.'
4
+ ---
5
+
6
+ # Alter a migration
7
+
8
+ Use `Migration.alter` to evolve an existing table — adding or dropping columns, renaming them, changing their type, and managing every variety of index or constraint. It's the declarative counterpart to `Migration.create` and inherits the table name and data source straight from the model.
9
+
10
+ > **Key difference from `Migration.create`:** `alter` does **not** auto-infer rollbacks. You must supply a `down()` function in options whenever you need to be able to roll back.
11
+
12
+ ---
13
+
14
+ ## Minimal example
15
+
16
+ ```ts title="src/app/users/models/user/migrations/06-09-2026_00-00-00-add-phone-to-users.migration.ts"
17
+ import { Migration, text } from "@warlock.js/cascade";
18
+ import { User } from "../user.model";
19
+
20
+ export default Migration.alter(User, {
21
+ add: {
22
+ phone: text().nullable(),
23
+ },
24
+ }, {
25
+ down() {
26
+ this.dropColumn("phone");
27
+ },
28
+ });
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Signature
34
+
35
+ ```ts
36
+ Migration.alter(
37
+ model: ModelClass,
38
+ schema: AlterSchema,
39
+ options?: MigrationAlterOptions,
40
+ ): MigrationConstructor
41
+ ```
42
+
43
+ - **`model`** — the model class; provides `table` and `dataSource` automatically.
44
+ - **`schema`** — any combination of the keys below; omit everything you don't need.
45
+ - **`options`** — rollback logic + order/transaction overrides (see [Options](#options)).
46
+
47
+ ---
48
+
49
+ ## Column operations
50
+
51
+ ### `add` — new columns
52
+
53
+ ```ts
54
+ import { Migration, text, integer, bool, uuid } from "@warlock.js/cascade";
55
+ import { Organization } from "app/organizations/models/organization";
56
+ import { User } from "../user.model";
57
+
58
+ export default Migration.alter(User, {
59
+ add: {
60
+ phone: text().nullable(),
61
+ login_attempts: integer().notNullable().default(0),
62
+ is_verified: bool().notNullable().default(false),
63
+ organization_id: uuid().references(Organization.table).onDelete("cascade").notNullable(),
64
+ },
65
+ }, {
66
+ down() {
67
+ this.dropColumn("phone");
68
+ this.dropColumn("login_attempts");
69
+ this.dropColumn("is_verified");
70
+ this.dropColumn("organization_id");
71
+ },
72
+ });
73
+ ```
74
+
75
+ Column helpers (`text`, `integer`, `bool`, `uuid`, `double`, `json`, `timestamp`, `date`, …) are imported from `@warlock.js/cascade` and support the same modifier chain as in `Migration.create`.
76
+
77
+ ### `drop` — remove columns
78
+
79
+ ```ts
80
+ export default Migration.alter(User, {
81
+ drop: ["legacy_token", "old_avatar_url"],
82
+ }, {
83
+ down() {
84
+ // re-add with the original definition if rollback is meaningful
85
+ this.text("legacy_token").nullable();
86
+ this.text("old_avatar_url").nullable();
87
+ },
88
+ });
89
+ ```
90
+
91
+ ### `rename` — rename columns
92
+
93
+ ```ts
94
+ export default Migration.alter(Post, {
95
+ rename: {
96
+ body: "content",
97
+ thumb_url: "thumbnail_url",
98
+ },
99
+ }, {
100
+ down() {
101
+ this.renameColumn("content", "body");
102
+ this.renameColumn("thumbnail_url", "thumb_url");
103
+ },
104
+ });
105
+ ```
106
+
107
+ ### `modify` — change column type or nullability
108
+
109
+ ```ts
110
+ import { Migration, string } from "@warlock.js/cascade";
111
+ import { User } from "../user.model";
112
+
113
+ export default Migration.alter(User, {
114
+ modify: {
115
+ // widen email from text to varchar(320) and keep not-null
116
+ email: string(320).notNullable(),
117
+ },
118
+ }, {
119
+ down() {
120
+ // revert to unbounded text
121
+ this.text("email").notNullable();
122
+ },
123
+ });
124
+ ```
125
+
126
+ > `modify` re-declares the column. Include every modifier you want to keep (`.notNullable()`, `.default(…)`, etc.) — the declaration replaces the old one entirely.
127
+
128
+ ---
129
+
130
+ ## Index operations
131
+
132
+ ### Regular indexes — `addIndex` / `dropIndex`
133
+
134
+ ```ts
135
+ export default Migration.alter(Order, {
136
+ // single column
137
+ addIndex: [{ columns: "status" }],
138
+ }, {
139
+ down() {
140
+ this.dropIndex("status");
141
+ },
142
+ });
143
+ ```
144
+
145
+ ```ts
146
+ // composite index with an explicit name
147
+ export default Migration.alter(Order, {
148
+ addIndex: [
149
+ { columns: ["organization_id", "status"], name: "idx_org_status" },
150
+ { columns: "created_at" },
151
+ ],
152
+ }, {
153
+ down() {
154
+ this.dropIndex("idx_org_status");
155
+ this.dropIndex("created_at");
156
+ },
157
+ });
158
+ ```
159
+
160
+ `dropIndex` accepts a name string or a columns array:
161
+
162
+ ```ts
163
+ export default Migration.alter(Order, {
164
+ dropIndex: ["idx_org_status", ["created_at"]],
165
+ });
166
+ ```
167
+
168
+ `options.concurrently: true` builds the index without locking the table (Postgres):
169
+
170
+ ```ts
171
+ addIndex: [{ columns: "email", options: { concurrently: true } }]
172
+ ```
173
+
174
+ ### Unique constraints — `addUnique` / `dropUnique`
175
+
176
+ ```ts
177
+ // promote an indexed column to unique
178
+ export default Migration.alter(User, {
179
+ addUnique: [{ columns: "email" }],
180
+ }, {
181
+ down() {
182
+ this.dropUnique("email");
183
+ },
184
+ });
185
+ ```
186
+
187
+ Composite unique constraint:
188
+
189
+ ```ts
190
+ export default Migration.alter(Membership, {
191
+ addUnique: [{ columns: ["organization_id", "user_id"], name: "uq_org_member" }],
192
+ }, {
193
+ down() {
194
+ this.dropUnique(["organization_id", "user_id"]);
195
+ },
196
+ });
197
+ ```
198
+
199
+ Downgrade a unique to a plain index (the pattern used in this session):
200
+
201
+ ```ts
202
+ export default Migration.alter(User, {
203
+ dropUnique: [["email"]],
204
+ addIndex: [{ columns: "email", name: "users_email_index" }],
205
+ }, {
206
+ down() {
207
+ this.dropIndex("users_email_index");
208
+ this.unique("email");
209
+ },
210
+ });
211
+ ```
212
+
213
+ ### Expression indexes — `addExpressionIndex` (Postgres)
214
+
215
+ ```ts
216
+ export default Migration.alter(User, {
217
+ addExpressionIndex: [
218
+ { expressions: "lower(email)", name: "idx_email_ci" },
219
+ { expressions: "lower(name)", name: "idx_name_ci" },
220
+ { expressions: ["year(created_at)", "status"] },
221
+ ],
222
+ }, {
223
+ down() {
224
+ this.dropIndex("idx_email_ci");
225
+ this.dropIndex("idx_name_ci");
226
+ },
227
+ });
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Specialized indexes
233
+
234
+ ### Full-text — `addFullText` / `dropFullText`
235
+
236
+ ```ts
237
+ export default Migration.alter(Article, {
238
+ addFullText: [
239
+ {
240
+ columns: ["title", "body"],
241
+ options: { name: "ft_article_search", language: "english" },
242
+ },
243
+ ],
244
+ }, {
245
+ down() {
246
+ this.dropFullText("ft_article_search");
247
+ },
248
+ });
249
+ ```
250
+
251
+ ### Geo-spatial — `addGeoIndex` / `dropGeoIndex`
252
+
253
+ ```ts
254
+ export default Migration.alter(Store, {
255
+ addGeoIndex: [{ column: "location" }],
256
+ }, {
257
+ down() {
258
+ this.dropGeoIndex("location");
259
+ },
260
+ });
261
+ ```
262
+
263
+ Options: `{ name?, type?: "2dsphere" | "2d", min?, max? }`
264
+
265
+ ### Vector (AI embeddings) — `addVectorIndex` / `dropVectorIndex`
266
+
267
+ ```ts
268
+ export default Migration.alter(Document, {
269
+ addVectorIndex: [{
270
+ column: "embedding",
271
+ options: { dimensions: 1536, similarity: "cosine", name: "idx_doc_embedding" },
272
+ }],
273
+ }, {
274
+ down() {
275
+ this.dropVectorIndex("embedding");
276
+ },
277
+ });
278
+ ```
279
+
280
+ Similarity options: `"cosine"` | `"euclidean"` | `"dotProduct"`.
281
+
282
+ ### TTL (MongoDB) — `addTTLIndex` / `dropTTLIndex`
283
+
284
+ Expires documents automatically after a fixed duration:
285
+
286
+ ```ts
287
+ export default Migration.alter(Session, {
288
+ addTTLIndex: [{ column: "created_at", expireAfterSeconds: 86400 }], // 24 h
289
+ }, {
290
+ down() {
291
+ this.dropTTLIndex("created_at");
292
+ },
293
+ });
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Constraints
299
+
300
+ ### Foreign keys — `addForeign` / `dropForeign`
301
+
302
+ Pass a model class or a raw table-name string for `references`:
303
+
304
+ ```ts
305
+ import { Migration } from "@warlock.js/cascade";
306
+ import { Team } from "app/teams/models/team";
307
+ import { User } from "../user.model";
308
+
309
+ export default Migration.alter(User, {
310
+ addForeign: [
311
+ { column: "team_id", references: Team, onDelete: "cascade" },
312
+ { column: "owner_id", references: "users", on: "id", onDelete: "setNull" },
313
+ ],
314
+ }, {
315
+ down() {
316
+ this.dropForeign("team_id", Team.table);
317
+ this.dropForeign("owner_id", "users");
318
+ },
319
+ });
320
+ ```
321
+
322
+ `onDelete` / `onUpdate` values: `"cascade"` | `"restrict"` | `"setNull"` | `"noAction"`. Both default to `"restrict"` when omitted.
323
+
324
+ Drop by constraint name when you named it manually:
325
+
326
+ ```ts
327
+ dropForeign: [{ columnOrConstraint: "fk_my_custom_name" }]
328
+ ```
329
+
330
+ ### CHECK constraints — `addCheck` / `dropCheck`
331
+
332
+ ```ts
333
+ export default Migration.alter(Product, {
334
+ addCheck: [
335
+ { name: "price_positive", expression: "price_cents >= 0" },
336
+ { name: "stock_non_negative", expression: "stock >= 0" },
337
+ ],
338
+ }, {
339
+ down() {
340
+ this.dropCheck("price_positive");
341
+ this.dropCheck("stock_non_negative");
342
+ },
343
+ });
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Raw SQL inside an alter
349
+
350
+ Use `raw` when you need a one-off SQL statement alongside declarative changes (e.g. backfilling a new column in the same migration when the table is small):
351
+
352
+ ```ts
353
+ export default Migration.alter(User, {
354
+ add: {
355
+ full_name: text().nullable(),
356
+ },
357
+ raw: `UPDATE users SET full_name = first_name || ' ' || last_name`,
358
+ }, {
359
+ down() {
360
+ this.dropColumn("full_name");
361
+ },
362
+ });
363
+ ```
364
+
365
+ Pass an array for multiple statements:
366
+
367
+ ```ts
368
+ raw: [
369
+ `UPDATE users SET status = 'active' WHERE status IS NULL`,
370
+ `UPDATE users SET role = 'member' WHERE role IS NULL`,
371
+ ]
372
+ ```
373
+
374
+ ---
375
+
376
+ ## Writing `down()` — the rollback function
377
+
378
+ `Migration.alter` **never** auto-infers rollback. Supply `down()` in options whenever you want `cascade migrate:rollback` to work. Inside `down()`, `this` is a full `Migration` instance — every class-form builder is available:
379
+
380
+ | Operation | Class-form call in `down()` |
381
+ |---|---|
382
+ | Drop an added column | `this.dropColumn("name")` |
383
+ | Re-add a dropped column | `this.text("name").nullable()` |
384
+ | Undo a rename | `this.renameColumn("new", "old")` |
385
+ | Undo a column modify | `this.text("col").notNullable()` |
386
+ | Drop a plain index (by name) | `this.dropIndex("idx_name")` |
387
+ | Drop a plain index (by columns) | `this.dropIndex(["col_a", "col_b"])` |
388
+ | Drop a unique constraint | `this.dropUnique("email")` or `this.dropUnique(["a", "b"])` |
389
+ | Add a unique constraint back | `this.unique("email")` |
390
+ | Add a plain index back | `this.index("email", "idx_name")` |
391
+ | Drop a foreign key | `this.dropForeign("col", "ref_table")` |
392
+ | Drop a CHECK constraint | `this.dropCheck("constraint_name")` |
393
+ | Drop full-text index | `this.dropFullText("ft_name")` |
394
+ | Drop geo index | `this.dropGeoIndex("column")` |
395
+ | Drop vector index | `this.dropVectorIndex("column")` |
396
+ | Drop TTL index | `this.dropTTLIndex("column")` |
397
+ | Raw SQL | `this.raw("SQL statement")` |
398
+
399
+ If a migration is genuinely irreversible, throw inside `down()` so accidental rollbacks fail loudly:
400
+
401
+ ```ts
402
+ {
403
+ down() {
404
+ throw new Error("This migration is irreversible — restore from backup.");
405
+ },
406
+ }
407
+ ```
408
+
409
+ ---
410
+
411
+ ## Options (`MigrationAlterOptions`)
412
+
413
+ | Key | Type | Purpose |
414
+ |---|---|---|
415
+ | `down` | `(this: Migration) => void \| Promise<void>` | Rollback logic (not auto-inferred) |
416
+ | `up` | `(this: Migration) => void \| Promise<void>` | Extra imperative logic to run after declarative changes |
417
+ | `order` | `number` | Execution order override (default `0`) |
418
+ | `createdAt` | `string` | ISO timestamp override for migration name ordering |
419
+ | `transactional` | `boolean` | Wrap the migration in a DB transaction |
420
+
421
+ The `up` hook runs **after** the declarative schema changes, making it useful for data backfills or conditional DDL that depends on the added schema:
422
+
423
+ ```ts
424
+ export default Migration.alter(User, {
425
+ add: { verified_at: timestamp().nullable() },
426
+ }, {
427
+ up() {
428
+ // backfill: mark existing confirmed users as verified
429
+ this.raw(`UPDATE users SET verified_at = updated_at WHERE status = 'confirmed'`);
430
+ },
431
+ down() {
432
+ this.dropColumn("verified_at");
433
+ },
434
+ });
435
+ ```
436
+
437
+ ---
438
+
439
+ ## Common recipes
440
+
441
+ ### Add a column + foreign key together
442
+
443
+ ```ts
444
+ import { Migration, uuid } from "@warlock.js/cascade";
445
+ import { Team } from "app/teams/models/team";
446
+ import { User } from "../user.model";
447
+
448
+ export default Migration.alter(User, {
449
+ add: {
450
+ team_id: uuid().nullable(),
451
+ },
452
+ addForeign: [
453
+ { column: "team_id", references: Team, onDelete: "setNull" },
454
+ ],
455
+ addIndex: [{ columns: "team_id" }],
456
+ }, {
457
+ down() {
458
+ this.dropForeign("team_id", Team.table);
459
+ this.dropIndex("team_id");
460
+ this.dropColumn("team_id");
461
+ },
462
+ });
463
+ ```
464
+
465
+ ### Swap unique → plain index
466
+
467
+ ```ts
468
+ export default Migration.alter(User, {
469
+ dropUnique: [["email"]],
470
+ addIndex: [{ columns: "email", name: "users_email_index" }],
471
+ }, {
472
+ down() {
473
+ this.dropIndex("users_email_index");
474
+ this.unique("email");
475
+ },
476
+ });
477
+ ```
478
+
479
+ ### Rename + widen a column
480
+
481
+ ```ts
482
+ export default Migration.alter(Post, {
483
+ rename: { body: "content" },
484
+ modify: { content: text().notNullable() },
485
+ }, {
486
+ down() {
487
+ this.renameColumn("content", "body");
488
+ },
489
+ });
490
+ ```
491
+
492
+ ### Multiple operations in one migration
493
+
494
+ Combine freely — all operations run in a single `up()` call:
495
+
496
+ ```ts
497
+ export default Migration.alter(Product, {
498
+ add: { sku: text().unique().notNullable() },
499
+ drop: ["old_code"],
500
+ rename: { price: "price_cents" },
501
+ modify: { price_cents: integer().notNullable() },
502
+ addIndex: [{ columns: ["category_id", "status"], name: "idx_cat_status" }],
503
+ addCheck: [{ name: "price_non_negative", expression: "price_cents >= 0" }],
504
+ }, {
505
+ down() {
506
+ this.dropCheck("price_non_negative");
507
+ this.dropIndex("idx_cat_status");
508
+ this.renameColumn("price_cents", "price");
509
+ this.text("old_code").nullable();
510
+ this.dropColumn("sku");
511
+ },
512
+ });
513
+ ```
514
+
515
+ ---
516
+
517
+ ## Things NOT to do
518
+
519
+ - **Don't edit a shipped migration.** If it's already run in any environment, add a new migration on top.
520
+ - **Don't skip `down()` for reversible changes.** Without it, `cascade migrate:rollback` is a no-op on your migration.
521
+ - **Don't put large backfills and schema changes together.** Schema change first (nullable column or default), backfill second — in its own migration or a background job. This keeps rollback safe.
522
+ - **Don't use `raw` for something the declarative API already covers.** Use `addIndex`, `addUnique`, etc. — raw SQL bypasses Cascade's driver abstraction and breaks on non-Postgres sources.
523
+ - **Don't declare `id`, `createdAt`, or `updatedAt`** — they're managed by the framework.
524
+
525
+ ---
526
+
527
+ ## See also
528
+
529
+ - [`@warlock.js/cascade/write-migration/SKILL.md`](@warlock.js/cascade/write-migration/SKILL.md) — `Migration.create` for brand-new tables + all column helpers
530
+ - [`@warlock.js/cascade/run-cascade-cli/SKILL.md`](@warlock.js/cascade/run-cascade-cli/SKILL.md) — CLI flags + programmatic Operations API
531
+ - [`@warlock.js/cascade/manage-data-sources/SKILL.md`](@warlock.js/cascade/manage-data-sources/SKILL.md) — multi-DB migrations
@@ -1,48 +0,0 @@
1
- import { exportMigrationsSQL } from "../../operations/migrations.mjs";
2
- import { loadMigrations } from "../load-migrations.mjs";
3
- import { withCliConnection } from "../with-cli-connection.mjs";
4
- import { defineCommand } from "citty";
5
-
6
- //#region ../../@warlock.js/cascade/src/cli/commands/migrate-export-sql.ts
7
- /**
8
- * `cascade migrate:export-sql` — write phase-ordered `.up.sql` /
9
- * `.down.sql` files for the registered migrations under
10
- * `<cwd>/database/sql/`. No DB writes occur.
11
- */
12
- const migrateExportSqlCommand = defineCommand({
13
- meta: {
14
- name: "migrate:export-sql",
15
- description: "Write phase-ordered SQL files for the registered migrations."
16
- },
17
- args: {
18
- "pending-only": {
19
- type: "boolean",
20
- description: "Export only pending migrations.",
21
- default: false
22
- },
23
- compact: {
24
- type: "boolean",
25
- alias: "c",
26
- description: "Strip generated comments and blank lines.",
27
- default: false
28
- },
29
- path: {
30
- type: "string",
31
- alias: "p",
32
- description: "Glob pattern overriding the default ./migrations/**/*.{ts,js,mjs,cjs}."
33
- }
34
- },
35
- async run({ args }) {
36
- await withCliConnection(async () => {
37
- await loadMigrations(args.path);
38
- await exportMigrationsSQL({
39
- pendingOnly: Boolean(args["pending-only"]),
40
- compact: Boolean(args.compact)
41
- });
42
- });
43
- }
44
- });
45
-
46
- //#endregion
47
- export { migrateExportSqlCommand };
48
- //# sourceMappingURL=migrate-export-sql.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-export-sql.mjs","names":[],"sources":["../../../../../../../@warlock.js/cascade/src/cli/commands/migrate-export-sql.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { exportMigrationsSQL } from \"../../operations/migrations\";\nimport { loadMigrations } from \"../load-migrations\";\nimport { withCliConnection } from \"../with-cli-connection\";\n\n/**\n * `cascade migrate:export-sql` — write phase-ordered `.up.sql` /\n * `.down.sql` files for the registered migrations under\n * `<cwd>/database/sql/`. No DB writes occur.\n */\nexport const migrateExportSqlCommand = defineCommand({\n meta: {\n name: \"migrate:export-sql\",\n description: \"Write phase-ordered SQL files for the registered migrations.\",\n },\n args: {\n \"pending-only\": {\n type: \"boolean\",\n description: \"Export only pending migrations.\",\n default: false,\n },\n compact: {\n type: \"boolean\",\n alias: \"c\",\n description: \"Strip generated comments and blank lines.\",\n default: false,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"Glob pattern overriding the default ./migrations/**/*.{ts,js,mjs,cjs}.\",\n },\n },\n async run({ args }) {\n await withCliConnection(async () => {\n await loadMigrations(args.path);\n\n await exportMigrationsSQL({\n pendingOnly: Boolean(args[\"pending-only\"]),\n compact: Boolean(args.compact),\n });\n });\n },\n});\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,0BAA0B,cAAc;CACnD,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACX;EACA,MAAM;GACJ,MAAM;GACN,OAAO;GACP,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,kBAAkB,YAAY;GAClC,MAAM,eAAe,KAAK,IAAI;GAE9B,MAAM,oBAAoB;IACxB,aAAa,QAAQ,KAAK,eAAe;IACzC,SAAS,QAAQ,KAAK,OAAO;GAC/B,CAAC;EACH,CAAC;CACH;AACF,CAAC"}
@@ -1,26 +0,0 @@
1
- import { listExecutedMigrations } from "../../operations/migrations.mjs";
2
- import { printExecutedMigrations } from "../printers.mjs";
3
- import { withCliConnection } from "../with-cli-connection.mjs";
4
- import { defineCommand } from "citty";
5
-
6
- //#region ../../@warlock.js/cascade/src/cli/commands/migrate-list.ts
7
- /**
8
- * `cascade migrate:list` — print every migration that has been executed
9
- * against the configured data source. Reads the migrations table directly;
10
- * does not load files from disk.
11
- */
12
- const migrateListCommand = defineCommand({
13
- meta: {
14
- name: "migrate:list",
15
- description: "List every migration that has been executed against the data source."
16
- },
17
- async run() {
18
- await withCliConnection(async () => {
19
- printExecutedMigrations(await listExecutedMigrations());
20
- });
21
- }
22
- });
23
-
24
- //#endregion
25
- export { migrateListCommand };
26
- //# sourceMappingURL=migrate-list.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-list.mjs","names":[],"sources":["../../../../../../../@warlock.js/cascade/src/cli/commands/migrate-list.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { listExecutedMigrations } from \"../../operations/migrations\";\nimport { printExecutedMigrations } from \"../printers\";\nimport { withCliConnection } from \"../with-cli-connection\";\n\n/**\n * `cascade migrate:list` — print every migration that has been executed\n * against the configured data source. Reads the migrations table directly;\n * does not load files from disk.\n */\nexport const migrateListCommand = defineCommand({\n meta: {\n name: \"migrate:list\",\n description: \"List every migration that has been executed against the data source.\",\n },\n async run() {\n await withCliConnection(async () => {\n const executed = await listExecutedMigrations();\n\n printExecutedMigrations(executed);\n });\n },\n});\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBAAqB,cAAc;CAC9C,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM,MAAM;EACV,MAAM,kBAAkB,YAAY;GAGlC,wBAAwB,MAFD,uBAAuB,CAEd;EAClC,CAAC;CACH;AACF,CAAC"}
@@ -1,50 +0,0 @@
1
- import { rollbackMigrations } from "../../operations/migrations.mjs";
2
- import { loadMigrations } from "../load-migrations.mjs";
3
- import { printRunSummary } from "../printers.mjs";
4
- import { withCliConnection } from "../with-cli-connection.mjs";
5
- import { defineCommand } from "citty";
6
-
7
- //#region ../../@warlock.js/cascade/src/cli/commands/migrate-rollback.ts
8
- /**
9
- * `cascade migrate:rollback` — undo the most recent batch (or every executed
10
- * migration with `--all`). Migration files are loaded so the runner has the
11
- * `down()` methods available.
12
- */
13
- const migrateRollbackCommand = defineCommand({
14
- meta: {
15
- name: "migrate:rollback",
16
- description: "Roll back the most recent batch — or everything with --all."
17
- },
18
- args: {
19
- all: {
20
- type: "boolean",
21
- alias: "a",
22
- description: "Roll back every executed migration. Overrides --batches.",
23
- default: false
24
- },
25
- batches: {
26
- type: "string",
27
- description: "Roll back the last N batches (ignored when --all is set). Default: 1."
28
- },
29
- path: {
30
- type: "string",
31
- alias: "p",
32
- description: "Glob pattern overriding the default ./migrations/**/*.{ts,js,mjs,cjs}."
33
- }
34
- },
35
- async run({ args }) {
36
- await withCliConnection(async () => {
37
- await loadMigrations(args.path);
38
- const batches = args.batches ? Number(args.batches) : void 0;
39
- if (batches !== void 0 && (!Number.isFinite(batches) || batches <= 0)) throw new Error(`Cascade CLI: --batches must be a positive integer, received "${args.batches}".`);
40
- printRunSummary(await rollbackMigrations({
41
- all: Boolean(args.all),
42
- batches
43
- }));
44
- });
45
- }
46
- });
47
-
48
- //#endregion
49
- export { migrateRollbackCommand };
50
- //# sourceMappingURL=migrate-rollback.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-rollback.mjs","names":[],"sources":["../../../../../../../@warlock.js/cascade/src/cli/commands/migrate-rollback.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { rollbackMigrations } from \"../../operations/migrations\";\nimport { loadMigrations } from \"../load-migrations\";\nimport { printRunSummary } from \"../printers\";\nimport { withCliConnection } from \"../with-cli-connection\";\n\n/**\n * `cascade migrate:rollback` — undo the most recent batch (or every executed\n * migration with `--all`). Migration files are loaded so the runner has the\n * `down()` methods available.\n */\nexport const migrateRollbackCommand = defineCommand({\n meta: {\n name: \"migrate:rollback\",\n description: \"Roll back the most recent batch — or everything with --all.\",\n },\n args: {\n all: {\n type: \"boolean\",\n alias: \"a\",\n description: \"Roll back every executed migration. Overrides --batches.\",\n default: false,\n },\n batches: {\n type: \"string\",\n description: \"Roll back the last N batches (ignored when --all is set). Default: 1.\",\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"Glob pattern overriding the default ./migrations/**/*.{ts,js,mjs,cjs}.\",\n },\n },\n async run({ args }) {\n await withCliConnection(async () => {\n await loadMigrations(args.path);\n\n const batches = args.batches ? Number(args.batches) : undefined;\n\n if (batches !== undefined && (!Number.isFinite(batches) || batches <= 0)) {\n throw new Error(\n `Cascade CLI: --batches must be a positive integer, received \"${args.batches}\".`,\n );\n }\n\n const results = await rollbackMigrations({\n all: Boolean(args.all),\n batches,\n });\n\n printRunSummary(results);\n });\n },\n});\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,yBAAyB,cAAc;CAClD,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,KAAK;GACH,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,OAAO;GACP,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,kBAAkB,YAAY;GAClC,MAAM,eAAe,KAAK,IAAI;GAE9B,MAAM,UAAU,KAAK,UAAU,OAAO,KAAK,OAAO,IAAI;GAEtD,IAAI,YAAY,WAAc,CAAC,OAAO,SAAS,OAAO,KAAK,WAAW,IACpE,MAAM,IAAI,MACR,gEAAgE,KAAK,QAAQ,GAC/E;GAQF,gBAAgB,MALM,mBAAmB;IACvC,KAAK,QAAQ,KAAK,GAAG;IACrB;GACF,CAAC,CAEsB;EACzB,CAAC;CACH;AACF,CAAC"}