unified-storage: sqlkv migrations (#114790)

* unified-storage: create resource_events table and add key_path column to resource_history

* Update resource_history_insert template

* update test snapshots

* use latin encoding for key_path and bump size to 2048
This commit is contained in:
Will Assis
2025-12-04 09:21:17 -05:00
committed by GitHub
parent c88314296b
commit 994e1dd58f
6 changed files with 30 additions and 8 deletions
@@ -12,7 +12,8 @@ INSERT INTO {{ .Ident "resource_history" }}
{{ .Ident "previous_resource_version"}},
{{ .Ident "generation"}},
{{ .Ident "value" }},
{{ .Ident "action" }}
{{ .Ident "action" }},
{{ .Ident "key_path" }}
)
VALUES (
@@ -28,6 +29,7 @@ INSERT INTO {{ .Ident "resource_history" }}
{{ .Arg .WriteEvent.PreviousRV }},
{{ .Arg .Generation }},
{{ .Arg .WriteEvent.Value }},
{{ .Arg .WriteEvent.Type }}
{{ .Arg .WriteEvent.Type }},
{{ .Arg .KeyPath }}
)
;
@@ -185,5 +185,18 @@ func initResourceTables(mg *migrator.Migrator) string {
Name: "UQE_resource_last_import_time_last_import_time",
}))
mg.AddMigration("Add key_path column to resource_history", migrator.NewAddColumnMigration(resource_history_table, &migrator.Column{
Name: "key_path", Type: migrator.DB_NVarchar, Length: 2048, Nullable: false, Default: "", IsLatin: true,
}))
resource_events_table := migrator.Table{
Name: "resource_events",
Columns: []*migrator.Column{
{Name: "key_path", Type: migrator.DB_NVarchar, Length: 2048, Nullable: false, IsPrimaryKey: true, IsLatin: true},
{Name: "value", Type: migrator.DB_MediumText, Nullable: false},
},
}
mg.AddMigration("create table "+resource_events_table.Name, migrator.NewAddTableMigration(resource_events_table))
return marker
}
+1
View File
@@ -84,6 +84,7 @@ type sqlResourceRequest struct {
WriteEvent resource.WriteEvent
Generation int64
Folder string
KeyPath string
// Useful when batch writing
ResourceVersion int64
@@ -9,7 +9,8 @@ INSERT INTO `resource_history`
`previous_resource_version`,
`generation`,
`value`,
`action`
`action`,
`key_path`
)
VALUES (
'',
@@ -21,6 +22,7 @@ INSERT INTO `resource_history`
1234,
789,
'[]',
'UNKNOWN'
'UNKNOWN',
''
)
;
@@ -9,7 +9,8 @@ INSERT INTO "resource_history"
"previous_resource_version",
"generation",
"value",
"action"
"action",
"key_path"
)
VALUES (
'',
@@ -21,6 +22,7 @@ INSERT INTO "resource_history"
1234,
789,
'[]',
'UNKNOWN'
'UNKNOWN',
''
)
;
@@ -9,7 +9,8 @@ INSERT INTO "resource_history"
"previous_resource_version",
"generation",
"value",
"action"
"action",
"key_path"
)
VALUES (
'',
@@ -21,6 +22,7 @@ INSERT INTO "resource_history"
1234,
789,
'[]',
'UNKNOWN'
'UNKNOWN',
''
)
;