@@ -400,6 +400,118 @@ FROM timescaledb_information.jobs
400400
401401 #endregion
402402
403+ #region Generate_Alter_DropCreatedBefore_job_settings_change_skips_alter_job
404+
405+ [ Fact ]
406+ public void Generate_Alter_DropCreatedBefore_job_settings_change_skips_alter_job ( )
407+ {
408+ // Arrange
409+ AlterRetentionPolicyOperation operation = new ( )
410+ {
411+ Schema = "public" ,
412+ TableName = "TestTable" ,
413+ DropAfter = null ,
414+ OldDropAfter = null ,
415+ DropCreatedBefore = "30 days" ,
416+ OldDropCreatedBefore = "30 days" ,
417+ InitialStart = null ,
418+ OldInitialStart = null ,
419+ ScheduleInterval = "2 days" , // <-- Changed from "1 day"
420+ OldScheduleInterval = "1 day"
421+ } ;
422+
423+ // No recreation needed, but alter_job is skipped for DropCreatedBefore due to TimescaleDB bug #9446.
424+ RetentionPolicyOperationGenerator generator = new ( true ) ;
425+ List < string > result = generator . Generate ( operation ) ;
426+
427+ // Assert
428+ Assert . Empty ( result ) ;
429+ }
430+
431+ #endregion
432+
433+ #region Generate_Alter_MaxRuntime_change_emits_alter_job
434+
435+ [ Fact ]
436+ public void Generate_Alter_MaxRuntime_change_emits_alter_job ( )
437+ {
438+ // Arrange
439+ AlterRetentionPolicyOperation operation = new ( )
440+ {
441+ Schema = "public" ,
442+ TableName = "TestTable" ,
443+ DropAfter = "7 days" ,
444+ OldDropAfter = "7 days" ,
445+ DropCreatedBefore = null ,
446+ OldDropCreatedBefore = null ,
447+ InitialStart = null ,
448+ OldInitialStart = null ,
449+ MaxRuntime = "2 hours" , // <-- Changed from "1 hour"
450+ OldMaxRuntime = "1 hour" ,
451+ ScheduleInterval = "1 day" ,
452+ OldScheduleInterval = "1 day" ,
453+ MaxRetries = - 1 ,
454+ OldMaxRetries = - 1 ,
455+ RetryPeriod = "1 day" ,
456+ OldRetryPeriod = "1 day"
457+ } ;
458+
459+ string expected = @".Sql(@""
460+ SELECT alter_job(job_id, max_runtime => INTERVAL '2 hours')
461+ FROM timescaledb_information.jobs
462+ WHERE proc_name = 'policy_retention' AND hypertable_schema = 'public' AND hypertable_name = 'TestTable';
463+ "")" ;
464+
465+ // Act
466+ string result = GetGeneratedCode ( operation ) ;
467+
468+ // Assert
469+ Assert . Equal ( SqlHelper . NormalizeSql ( expected ) , SqlHelper . NormalizeSql ( result ) ) ;
470+ }
471+
472+ #endregion
473+
474+ #region Generate_Alter_RetryPeriod_change_emits_alter_job
475+
476+ [ Fact ]
477+ public void Generate_Alter_RetryPeriod_change_emits_alter_job ( )
478+ {
479+ // Arrange
480+ AlterRetentionPolicyOperation operation = new ( )
481+ {
482+ Schema = "public" ,
483+ TableName = "TestTable" ,
484+ DropAfter = "7 days" ,
485+ OldDropAfter = "7 days" ,
486+ DropCreatedBefore = null ,
487+ OldDropCreatedBefore = null ,
488+ InitialStart = null ,
489+ OldInitialStart = null ,
490+ ScheduleInterval = "1 day" ,
491+ OldScheduleInterval = "1 day" ,
492+ MaxRuntime = "00:00:00" ,
493+ OldMaxRuntime = "00:00:00" ,
494+ MaxRetries = - 1 ,
495+ OldMaxRetries = - 1 ,
496+ RetryPeriod = "30 minutes" , // <-- Changed from "1 day"
497+ OldRetryPeriod = "1 day"
498+ } ;
499+
500+ string expected = @".Sql(@""
501+ SELECT alter_job(job_id, retry_period => INTERVAL '30 minutes')
502+ FROM timescaledb_information.jobs
503+ WHERE proc_name = 'policy_retention' AND hypertable_schema = 'public' AND hypertable_name = 'TestTable';
504+ "")" ;
505+
506+ // Act
507+ string result = GetGeneratedCode ( operation ) ;
508+
509+ // Assert
510+ Assert . Equal ( SqlHelper . NormalizeSql ( expected ) , SqlHelper . NormalizeSql ( result ) ) ;
511+ }
512+
513+ #endregion
514+
403515 // --- Tests for runtime quoting (isDesignTime=false) ---
404516
405517 private static List < string > GetRuntimeStatements ( dynamic operation )
0 commit comments