Cleanup old entries from resource_last_import_time table. (#112438)

* Cleanup old entries from resource_last_import_time table.

* Add index for last_import_time column.

* Address review feedback.
This commit is contained in:
Peter Štibraný
2025-10-23 11:17:08 +00:00
committed by GitHub
parent 9021719437
commit a4aa3529c8
10 changed files with 82 additions and 8 deletions
@@ -116,7 +116,7 @@ func initResourceTables(mg *migrator.Migrator) string {
},
})
tables = append(tables, migrator.Table{
resource_last_import_time := migrator.Table{
Name: "resource_last_import_time",
Columns: []*migrator.Column{
{Name: "group", Type: migrator.DB_NVarchar, Length: 190, Nullable: false},
@@ -125,7 +125,8 @@ func initResourceTables(mg *migrator.Migrator) string {
{Name: "last_import_time", Type: migrator.DB_DateTime, Nullable: false},
},
PrimaryKeys: []string{"group", "resource", "namespace"},
})
}
tables = append(tables, resource_last_import_time)
// Initialize all tables
for t := range tables {
@@ -178,5 +179,11 @@ func initResourceTables(mg *migrator.Migrator) string {
Name: "IDX_resource_history_namespace_group_resource_name_generation",
}))
mg.AddMigration("Add UQE_resource_last_import_time_last_import_time index", migrator.NewAddIndexMigration(resource_last_import_time, &migrator.Index{
Cols: []string{"last_import_time"},
Type: migrator.IndexType,
Name: "UQE_resource_last_import_time_last_import_time",
}))
return marker
}