Unistore : Ensure Watch works in HA mode (#94120)

* Revert "Revert "Unistore : Ensure Watch works in HA mode." (#94097)"

This reverts commit 7c3fc2f261.

* make previous_resource_version nullable

* handle nil case
This commit is contained in:
Georges Chaudy
2024-10-07 10:01:53 +02:00
committed by GitHub
parent 3bda6c2c0a
commit 03f55e5288
28 changed files with 483 additions and 699 deletions
@@ -10,8 +10,7 @@ func initResourceTables(mg *migrator.Migrator) string {
marker := "Initialize resource tables"
mg.AddMigration(marker, &migrator.RawSQLMigration{})
tables := []migrator.Table{}
tables = append(tables, migrator.Table{
resource_table := migrator.Table{
Name: "resource",
Columns: []*migrator.Column{
// primary identifier
@@ -33,9 +32,8 @@ func initResourceTables(mg *migrator.Migrator) string {
Indices: []*migrator.Index{
{Cols: []string{"namespace", "group", "resource", "name"}, Type: migrator.UniqueIndex},
},
})
tables = append(tables, migrator.Table{
}
resource_history_table := migrator.Table{
Name: "resource_history",
Columns: []*migrator.Column{
// primary identifier
@@ -62,7 +60,9 @@ func initResourceTables(mg *migrator.Migrator) string {
// index to support watch poller
{Cols: []string{"resource_version"}, Type: migrator.IndexType},
},
})
}
tables := []migrator.Table{resource_table, resource_history_table}
// tables = append(tables, migrator.Table{
// Name: "resource_label_set",
@@ -97,5 +97,13 @@ func initResourceTables(mg *migrator.Migrator) string {
}
}
mg.AddMigration("Add column previous_resource_version in resource_history", migrator.NewAddColumnMigration(resource_history_table, &migrator.Column{
Name: "previous_resource_version", Type: migrator.DB_BigInt, Nullable: true,
}))
mg.AddMigration("Add column previous_resource_version in resource", migrator.NewAddColumnMigration(resource_table, &migrator.Column{
Name: "previous_resource_version", Type: migrator.DB_BigInt, Nullable: true,
}))
return marker
}