@@ -29,6 +29,98 @@ export interface BaseSchemaChangeInstruction {
2929 author ?: string ;
3030}
3131
32+ /**
33+ * Database impact assessment for a field change.
34+ * Describes how the change affects the underlying database schema.
35+ */
36+ export interface DatabaseImpact {
37+ /**
38+ * Type of database operation required.
39+ * - 'alter_column': Modify column properties (type, constraints, default)
40+ * - 'rename_column': Rename a column
41+ * - 'drop_column': Remove a column
42+ * - 'add_column': Add a new column
43+ * - 'rebuild_table': Requires full table rebuild (complex changes)
44+ * - 'no_change': Schema-level only, no database changes
45+ */
46+ operation : 'alter_column' | 'rename_column' | 'drop_column' | 'add_column' | 'rebuild_table' | 'no_change' ;
47+
48+ /**
49+ * Whether this change requires data migration.
50+ * If true, existing records must be updated.
51+ */
52+ requires_data_migration : boolean ;
53+
54+ /**
55+ * Whether this change may cause data loss.
56+ * Examples: type narrowing, dropping columns, shortening text length
57+ */
58+ may_cause_data_loss : boolean ;
59+
60+ /**
61+ * Estimated risk level for this change.
62+ * - 'low': Safe, reversible change (e.g., adding nullable field)
63+ * - 'medium': May affect queries or require downtime (e.g., adding index)
64+ * - 'high': Requires careful planning (e.g., type change with data migration)
65+ * - 'critical': May cause data loss or extended downtime (e.g., dropping column)
66+ */
67+ risk_level ?: 'low' | 'medium' | 'high' | 'critical' ;
68+
69+ /**
70+ * Expected downtime for this change.
71+ * Format: ISO 8601 duration (e.g., 'PT5M' for 5 minutes, 'PT2H' for 2 hours)
72+ */
73+ estimated_downtime ?: string ;
74+
75+ /**
76+ * Notes about the database impact for human review.
77+ */
78+ notes ?: string ;
79+ }
80+
81+ /**
82+ * Database upgrade script information.
83+ * Contains the generated DDL/DML statements for applying the migration.
84+ */
85+ export interface UpgradeScript {
86+ /**
87+ * Target database dialect.
88+ * Examples: 'postgresql', 'mysql', 'sqlite', 'mongodb', 'mssql'
89+ */
90+ dialect : string ;
91+
92+ /**
93+ * SQL or database-specific statements to apply the change (forward migration).
94+ * For SQL: DDL statements (ALTER TABLE, CREATE INDEX, etc.)
95+ * For MongoDB: Update operations
96+ */
97+ up_statements : string [ ] ;
98+
99+ /**
100+ * SQL or database-specific statements to rollback the change (reverse migration).
101+ * Only present if the change is reversible.
102+ */
103+ down_statements ?: string [ ] ;
104+
105+ /**
106+ * Pre-migration checks or validations to run before applying changes.
107+ * Examples: Check for data integrity, verify no duplicate values before adding UNIQUE constraint
108+ */
109+ pre_checks ?: string [ ] ;
110+
111+ /**
112+ * Post-migration validations to ensure the change was successful.
113+ * Examples: Verify column exists, check data was migrated correctly
114+ */
115+ post_checks ?: string [ ] ;
116+
117+ /**
118+ * Estimated execution time for this script.
119+ * Format: ISO 8601 duration
120+ */
121+ estimated_execution_time ?: string ;
122+ }
123+
32124/**
33125 * Instruction to update (modify) a field in an object.
34126 * Can rename, change type, or update properties of an existing field.
@@ -62,6 +154,19 @@ export interface FieldUpdateInstruction extends BaseSchemaChangeInstruction {
62154 * Should be a valid JavaScript expression or function body.
63155 */
64156 transform_script ?: string ;
157+
158+ /**
159+ * Database impact assessment for this field change.
160+ * Describes the effect on the underlying database schema.
161+ */
162+ database_impact ?: DatabaseImpact ;
163+
164+ /**
165+ * Generated upgrade scripts for different database dialects.
166+ * Maps dialect name to upgrade script.
167+ * Example: { postgresql: {...}, mysql: {...} }
168+ */
169+ upgrade_scripts ?: Record < string , UpgradeScript > ;
65170}
66171
67172/**
@@ -86,6 +191,19 @@ export interface FieldDeleteInstruction extends BaseSchemaChangeInstruction {
86191
87192 /** Backup location if using 'archive' strategy */
88193 archive_location ?: string ;
194+
195+ /**
196+ * Database impact assessment for this field deletion.
197+ * Describes the effect on the underlying database schema.
198+ */
199+ database_impact ?: DatabaseImpact ;
200+
201+ /**
202+ * Generated upgrade scripts for different database dialects.
203+ * Maps dialect name to upgrade script.
204+ * Example: { postgresql: {...}, mysql: {...} }
205+ */
206+ upgrade_scripts ?: Record < string , UpgradeScript > ;
89207}
90208
91209/**
@@ -118,6 +236,19 @@ export interface ObjectUpdateInstruction extends BaseSchemaChangeInstruction {
118236
119237 /** Updated properties (label, description, icon, etc.) */
120238 changes : ObjectUpdateChanges ;
239+
240+ /**
241+ * Database impact assessment for this object change.
242+ * Describes the effect on the underlying database schema.
243+ */
244+ database_impact ?: DatabaseImpact ;
245+
246+ /**
247+ * Generated upgrade scripts for different database dialects.
248+ * Maps dialect name to upgrade script.
249+ * Example: { postgresql: {...}, mysql: {...} }
250+ */
251+ upgrade_scripts ?: Record < string , UpgradeScript > ;
121252}
122253
123254/**
@@ -147,6 +278,19 @@ export interface ObjectDeleteInstruction extends BaseSchemaChangeInstruction {
147278 * - 'nullify': Set foreign key references to null
148279 */
149280 cascade_strategy ?: 'cascade' | 'fail' | 'nullify' ;
281+
282+ /**
283+ * Database impact assessment for this object deletion.
284+ * Describes the effect on the underlying database schema.
285+ */
286+ database_impact ?: DatabaseImpact ;
287+
288+ /**
289+ * Generated upgrade scripts for different database dialects.
290+ * Maps dialect name to upgrade script.
291+ * Example: { postgresql: {...}, mysql: {...} }
292+ */
293+ upgrade_scripts ?: Record < string , UpgradeScript > ;
150294}
151295
152296/**
0 commit comments