@stacksjs/types 0.70.76 → 0.70.78

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.
@@ -46,6 +46,10 @@ export declare interface DatabaseOptions {
46
46
  }
47
47
  migrations: string
48
48
  migrationLocks: string
49
+ safety?: {
50
+ confirmMigrate?: boolean
51
+ migrateFresh?: 'allow' | 'confirm' | 'disabled'
52
+ }
49
53
  queryLogging?: {
50
54
  enabled: boolean
51
55
  slowThreshold: number
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/types",
3
3
  "type": "module",
4
- "version": "0.70.76",
4
+ "version": "0.70.78",
5
5
  "description": "The Stacks framework types.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -59,7 +59,7 @@
59
59
  "meilisearch": "^0.59.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@stacksjs/validation": "0.70.76",
62
+ "@stacksjs/validation": "0.70.78",
63
63
  "@types/bun": "^1.3.11",
64
64
  "typescript": "^7.0.2"
65
65
  },
package/src/database.ts CHANGED
@@ -55,6 +55,38 @@ export interface DatabaseOptions {
55
55
  migrations: string
56
56
  migrationLocks: string
57
57
 
58
+ /**
59
+ * Safety guards for the destructive migration commands.
60
+ *
61
+ * These gate `buddy migrate` and `buddy migrate:fresh` behind explicit
62
+ * human confirmation so an absent-minded command can't silently wipe or
63
+ * reshape a database. Every value can be overridden per-run by an env
64
+ * var (see each field) so CI/automation has an escape hatch.
65
+ */
66
+ safety?: {
67
+ /**
68
+ * Require an interactive confirmation before `buddy migrate` applies
69
+ * anything. Bypass a single run with `--force`; automation without a
70
+ * TTY (CI) proceeds without prompting. Env override: `DB_MIGRATE_CONFIRM`.
71
+ *
72
+ * @default true
73
+ */
74
+ confirmMigrate?: boolean
75
+
76
+ /**
77
+ * Guard level for `buddy migrate:fresh`, which DROPS every table before
78
+ * re-migrating (total data loss):
79
+ * - `'allow'` run after a typed confirmation; `--force` bypasses it
80
+ * - `'confirm'` always require the typed confirmation; `--force` does NOT bypass
81
+ * - `'disabled'` refuse to run at all (the hard kill-switch)
82
+ *
83
+ * Env override: `DB_MIGRATE_FRESH` (`allow` | `confirm` | `disabled`).
84
+ *
85
+ * @default 'allow' in local/dev, 'disabled' when APP_ENV is production
86
+ */
87
+ migrateFresh?: 'allow' | 'confirm' | 'disabled'
88
+ }
89
+
58
90
  // Query logging configuration
59
91
  queryLogging?: {
60
92
  enabled: boolean