@@ -535,7 +535,9 @@ describe.sequential('PostgresMigrationPlanner - reconciliation integration', ()
535535 expect ( nullable . rows [ 0 ] ?. is_nullable ) . toBe ( 'NO' ) ;
536536 } ) ;
537537
538- it (
538+ // TML-2089: the existence-only postcheck (IS NOT NULL) passes before the operation runs
539+ // because the column already has a (wrong) default. The idempotency probe skips SET DEFAULT.
540+ it . fails (
539541 'applies ALTER DEFAULT to change an existing column default' ,
540542 { timeout : testTimeout } ,
541543 async ( ) => {
@@ -589,7 +591,9 @@ describe.sequential('PostgresMigrationPlanner - reconciliation integration', ()
589591 // Compound scenarios — multiple reconciliation operations in a single plan
590592 // ==========================================================================
591593
592- it ( 'changes column type and default together' , { timeout : testTimeout } , async ( ) => {
594+ // TML-2135: when type_mismatch and default_mismatch co-occur on the same column, no single
595+ // two-operation order is safe. The planner must emit three operations: dropDefault → alterType → setDefault.
596+ it . fails ( 'changes column type and default together' , { timeout : testTimeout } , async ( ) => {
593597 const baselineContract = makeContract (
594598 {
595599 config : makeTable ( {
@@ -903,50 +907,56 @@ describe.sequential('PostgresMigrationPlanner - reconciliation integration', ()
903907 expect ( indexExists . rows [ 0 ] ?. exists ) . toBe ( true ) ;
904908 } ) ;
905909
906- it ( 'changes a literal default to a function default' , { timeout : testTimeout } , async ( ) => {
907- const baselineContract = makeContract (
908- {
909- item : makeTable ( {
910- id : { nativeType : 'uuid' , codecId : 'pg/uuid@1' , nullable : false } ,
911- uid : {
912- nativeType : 'uuid' ,
913- codecId : 'pg/uuid@1' ,
914- nullable : false ,
915- default : { kind : 'literal' , value : '00000000-0000-0000-0000-000000000000' } ,
916- } ,
917- } ) ,
918- } ,
919- 'fn-default-baseline' ,
920- ) ;
921- await applyBaseline ( driver ! , baselineContract ) ;
910+ // TML-2089: same as "applies ALTER DEFAULT" — the existence-only postcheck (IS NOT NULL)
911+ // passes before the operation runs because the column already has a (wrong) default.
912+ it . fails (
913+ 'changes a literal default to a function default' ,
914+ { timeout : testTimeout } ,
915+ async ( ) => {
916+ const baselineContract = makeContract (
917+ {
918+ item : makeTable ( {
919+ id : { nativeType : 'uuid' , codecId : 'pg/uuid@1' , nullable : false } ,
920+ uid : {
921+ nativeType : 'uuid' ,
922+ codecId : 'pg/uuid@1' ,
923+ nullable : false ,
924+ default : { kind : 'literal' , value : '00000000-0000-0000-0000-000000000000' } ,
925+ } ,
926+ } ) ,
927+ } ,
928+ 'fn-default-baseline' ,
929+ ) ;
930+ await applyBaseline ( driver ! , baselineContract ) ;
922931
923- const updatedContract = makeContract (
924- {
925- item : makeTable ( {
926- id : { nativeType : 'uuid' , codecId : 'pg/uuid@1' , nullable : false } ,
927- uid : {
928- nativeType : 'uuid' ,
929- codecId : 'pg/uuid@1' ,
930- nullable : false ,
931- default : { kind : 'function' , expression : 'gen_random_uuid()' } ,
932- } ,
933- } ) ,
934- } ,
935- 'fn-default-updated' ,
936- ) ;
932+ const updatedContract = makeContract (
933+ {
934+ item : makeTable ( {
935+ id : { nativeType : 'uuid' , codecId : 'pg/uuid@1' , nullable : false } ,
936+ uid : {
937+ nativeType : 'uuid' ,
938+ codecId : 'pg/uuid@1' ,
939+ nullable : false ,
940+ default : { kind : 'function' , expression : 'gen_random_uuid()' } ,
941+ } ,
942+ } ) ,
943+ } ,
944+ 'fn-default-updated' ,
945+ ) ;
937946
938- await planAndExecute ( driver ! , updatedContract ) ;
947+ await planAndExecute ( driver ! , updatedContract ) ;
939948
940- const defaultRow = await driver ! . query < { column_default : string | null } > (
941- `SELECT column_default
949+ const defaultRow = await driver ! . query < { column_default : string | null } > (
950+ `SELECT column_default
942951 FROM information_schema.columns
943952 WHERE table_schema = 'public'
944953 AND table_name = 'item'
945954 AND column_name = 'uid'` ,
946- ) ;
947- expect ( defaultRow . rows [ 0 ] ?. column_default ) . not . toBeNull ( ) ;
948- expect ( defaultRow . rows [ 0 ] ?. column_default ) . toContain ( 'gen_random_uuid' ) ;
949- } ) ;
955+ ) ;
956+ expect ( defaultRow . rows [ 0 ] ?. column_default ) . not . toBeNull ( ) ;
957+ expect ( defaultRow . rows [ 0 ] ?. column_default ) . toContain ( 'gen_random_uuid' ) ;
958+ } ,
959+ ) ;
950960
951961 it ( 'changes column type from text to enum' , { timeout : testTimeout } , async ( ) => {
952962 const baselineContract = makeContract (
0 commit comments