@@ -66,11 +66,13 @@ const footprintMap: Record<JsonStatement['type'], JsonStatement['type'][]> = {
6666 create_pk : [ 'drop_pk' , 'create_pk' ] ,
6767
6868 // Foreign key operations
69- create_fk : [ 'create_fk' ] ,
69+ create_fk : [ 'create_fk' , 'drop_constraint' ] ,
7070
71- // TODO statements
72- drop_constraint : [ ] ,
73- create_check : [ ] ,
71+ // Constraint operations (FK drops / check drops)
72+ drop_constraint : [ 'drop_constraint' , 'create_fk' , 'create_check' ] ,
73+
74+ // Check constraint operations
75+ create_check : [ 'create_check' , 'drop_constraint' ] ,
7476
7577 // View operations
7678 create_view : [ 'create_view' , 'drop_view' , 'rename_view' , 'alter_view' ] ,
@@ -177,6 +179,21 @@ export function footprint(statement: JsonStatement, snapshot?: MysqlSnapshot): [
177179
178180 const statementFootprint = [ formatFootprint ( statement . type , info . objectName , info . columnName ) ] ;
179181
182+ // For column-level operations, also produce a table-level statement footprint.
183+ // This allows table-level operations (e.g. drop_table) whose conflict footprints
184+ // use an empty column name to match against any column operation on that table,
185+ // including newly-added columns not present in the parent snapshot.
186+ const columnOps : JsonStatement [ 'type' ] [ ] = [
187+ 'add_column' ,
188+ 'drop_column' ,
189+ 'alter_column' ,
190+ 'recreate_column' ,
191+ 'rename_column' ,
192+ ] ;
193+ if ( columnOps . includes ( statement . type ) && info . columnName !== '' ) {
194+ statementFootprint . push ( formatFootprint ( statement . type , info . objectName , '' ) ) ;
195+ }
196+
180197 let conflictFootprints = conflictingTypes . map ( ( conflictType ) =>
181198 formatFootprint ( conflictType , info . objectName , info . columnName )
182199 ) ;
@@ -298,17 +315,15 @@ function findFootprintIntersections(
298315export const getReasonsFromStatements = async (
299316 aStatements : JsonStatement [ ] ,
300317 bStatements : JsonStatement [ ] ,
301- snapshotLeft ?: MysqlSnapshot ,
302- snapshotRight ?: MysqlSnapshot ,
318+ parentSnapshot ?: MysqlSnapshot ,
303319) => {
304- // const parentSnapshot = snapshot ?? drySnapshot;
305320 const branchAFootprints = generateLeafFootprints (
306321 aStatements ,
307- snapshotLeft ,
322+ parentSnapshot ,
308323 ) ;
309324 const branchBFootprints = generateLeafFootprints (
310325 bStatements ,
311- snapshotRight ,
326+ parentSnapshot ,
312327 ) ;
313328
314329 return findFootprintIntersections (
0 commit comments