Skip to content

Commit

Permalink
Follow up: Add Datastore Version Registry Extension
Browse files Browse the repository at this point in the history
When upgrading Trove, the trove-manage script fails
to upgrade the database when the DBDatastoreVersion
table is not empty.

This patch will help us fix above error

Change-Id: Ib615032747f89daf7f8500c7e2df4064fab05314
  • Loading branch information
botranvan authored and wchy1001 committed Nov 5, 2024
1 parent 3ff6390 commit 596134e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
36 changes: 22 additions & 14 deletions api-ref/source/samples/datastore-version-show-response.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"version": {
"datastore": "cc9ee471-e781-43bf-a796-423c5d549997",
"id": "4eb0179d-fe11-4556-9422-5267d2fc7625",
"links": [
{
"href": "https://127.0.0.1:8779/v1.0/9f8dd5eacb074c9f87d2d822c9092aa5/datastores/versions/4eb0179d-fe11-4556-9422-5267d2fc7625",
"rel": "self"
},
{
"href": "https://127.0.0.1:8779/datastores/versions/4eb0179d-fe11-4556-9422-5267d2fc7625",
"rel": "bookmark"
}
],
"name": "12",
"version": "5.7.29"
"id": "800774c4-0505-4ae7-8cf9-aae131e065ae",
"name": "5.7",
"version": "5.7",
"links": [
{
"href": "https://127.0.0.1:8779/v1.0/0600c20b16444bfa979b879b099805a1/datastores/versions/800774c4-0505-4ae7-8cf9-aae131e065ae",
"rel": "self"
},
{
"href": "https://127.0.0.1:8779/datastores/versions/800774c4-0505-4ae7-8cf9-aae131e065ae",
"rel": "bookmark"
}
],
"datastore": "3423e828-3355-48ef-9c16-5c41e7c196fb",
"active": true,
"packages": "",
"image": null,
"registry_ext": "trove.guestagent.datastore.mysql.manager.Manager",
"repl_strategy": "trove.guestagent.strategies.replication.mysql_gtid.MysqlGTIDReplication",
"image_tags": [
"trove"
]
}
}
5 changes: 5 additions & 0 deletions releasenotes/notes/fix-db-migration-b47ae342b4645b66.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
fix a bug where the trove-manage script fails to upgrade
the database when the DBDatastoreVersion table is not empty.
3 changes: 2 additions & 1 deletion trove/datastore/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class DBCapabilityOverrides(dbmodels.DatabaseModelBase):

class DBDatastoreVersion(dbmodels.DatabaseModelBase):
_data_fields = ['datastore_id', 'name', 'image_id', 'image_tags',
'packages', 'active', 'manager', 'version']
'packages', 'active', 'manager', 'version',
'registry_ext', 'repl_strategy']
_table_name = 'datastore_versions'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def upgrade() -> None:
'repl_namespace': repl_namespaces.get(dsv_manager, ''),
'repl_strategy': repl_strategies.get(dsv_manager, '')
}
ds_versions_table = table("datastore_versions", column("", String))
ds_versions_table = table(
"datastore_versions",
column("id", String),
column("registry_ext", String),
column("repl_strategy", String))
op.execute(
ds_versions_table.update()
.where(ds_versions_table.c.id == dsv_id)
Expand Down

0 comments on commit 596134e

Please sign in to comment.