Skip to content

Commit f6d6908

Browse files
RostyslavKachanjdobes
authored andcommitted
chore: add new owner_id field to system_platform
1 parent f1523d8 commit f6d6908

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎common/peewee_model.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class SystemPlatform(BaseModelRW):
216216
mssql = BooleanField(null=True)
217217
ansible = BooleanField(null=True)
218218
rhsm_version = TextField(null=True)
219+
owner_id = UUIDField(null=True)
219220

220221
class Meta:
221222
"""system_platform table metadata"""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE system_platform ADD COLUMN owner_id UUID;
2+
CREATE INDEX ON system_platform(owner_id);

‎database/schema/ve_db_postgresql.sql‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS db_version (
1717
) TABLESPACE pg_default;
1818

1919
-- set the schema version directly in the insert statement here!!
20-
INSERT INTO db_version (name, version) VALUES ('schema_version', 162);
20+
INSERT INTO db_version (name, version) VALUES ('schema_version', 163);
2121
-- INSERT INTO db_version (name, version) VALUES ('schema_version', :schema_version);
2222

2323

@@ -234,6 +234,7 @@ CREATE TABLE IF NOT EXISTS system_platform (
234234
mssql BOOLEAN,
235235
ansible BOOLEAN,
236236
rhsm_version TEXT,
237+
owner_id UUID,
237238
sap_ids TEXT[],
238239
group_set_id BIGINT,
239240
tag_set_id BIGINT,
@@ -278,6 +279,8 @@ CREATE INDEX ON system_platform(updated_timestamp);
278279

279280
CREATE INDEX ON system_platform(rhsm_version);
280281

282+
CREATE INDEX ON system_platform(owner_id);
283+
281284
CREATE TRIGGER system_platform_set_first_reported
282285
BEFORE INSERT ON system_platform
283286
FOR EACH ROW EXECUTE PROCEDURE set_first_reported();

‎listener/inventory_processor.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,19 @@ async def _db_import_system(self, conn, fields: dict, org_id: str, inventory_id:
335335
(rh_account_id, inventory_id, s3_url, vmaas_json, json_checksum, display_name,
336336
stale_timestamp, stale_warning_timestamp, culled_timestamp,
337337
host_type, last_upload, stale, operating_system_id, sap_ids, group_set_id, tag_set_id, insights_id, updated_timestamp,
338-
mssql, ansible, rhsm_version)
338+
mssql, ansible, rhsm_version, owner_id)
339339
VALUES (%(rh_account_id)s, %(inventory_id)s, %(s3_url)s, %(vmaas_json)s, %(json_checksum)s, %(display_name)s,
340340
%(stale_timestamp)s, %(stale_warning_timestamp)s, %(culled_timestamp)s,
341341
%(host_type)s, %(last_upload)s, 'F', %(operating_system_id)s, %(sap_ids)s, %(group_set_id)s, %(tag_set_id)s, %(insights_id)s,
342-
%(updated_timestamp)s, %(mssql)s, %(ansible)s, %(rhsm_version)s)
342+
%(updated_timestamp)s, %(mssql)s, %(ansible)s, %(rhsm_version)s, %(owner_id)s)
343343
ON CONFLICT (inventory_id) DO UPDATE SET
344344
rh_account_id = EXCLUDED.rh_account_id, inventory_id = EXCLUDED.inventory_id, s3_url = EXCLUDED.s3_url, vmaas_json = EXCLUDED.vmaas_json,
345345
json_checksum = EXCLUDED.json_checksum, display_name = EXCLUDED.display_name, stale_timestamp = EXCLUDED.stale_timestamp,
346346
stale_warning_timestamp = EXCLUDED.stale_warning_timestamp, culled_timestamp = EXCLUDED.culled_timestamp,
347347
host_type = EXCLUDED.host_type, last_upload = EXCLUDED.last_upload, stale = EXCLUDED.stale, operating_system_id = EXCLUDED.operating_system_id,
348348
sap_ids = EXCLUDED.sap_ids, group_set_id = EXCLUDED.group_set_id, tag_set_id = EXCLUDED.tag_set_id,
349349
insights_id = EXCLUDED.insights_id, updated_timestamp = EXCLUDED.updated_timestamp,
350-
mssql = EXCLUDED.mssql, ansible = EXCLUDED.ansible, rhsm_version = EXCLUDED.rhsm_version
350+
mssql = EXCLUDED.mssql, ansible = EXCLUDED.ansible, rhsm_version = EXCLUDED.rhsm_version, owner_id = EXCLUDED.owner_id
351351
RETURNING (xmax = 0) AS inserted, unchanged_since, last_evaluation, id, when_deleted
352352
"""
353353
else:
@@ -371,7 +371,8 @@ async def _db_import_system(self, conn, fields: dict, org_id: str, inventory_id:
371371
updated_timestamp = %(updated_timestamp)s,
372372
mssql = %(mssql)s,
373373
ansible = %(ansible)s,
374-
rhsm_version = %(rhsm_version)s
374+
rhsm_version = %(rhsm_version)s,
375+
owner_id = %(owner_id)s
375376
WHERE id = %(system_id)s
376377
RETURNING (xmax = 0) AS inserted, unchanged_since, last_evaluation, id, when_deleted
377378
"""
@@ -494,6 +495,7 @@ async def _process_upload(self, msg: InventoryMsg):
494495
rhsm_version = system_profile.get("rhsm", {}).get("version")
495496
insert_fields["insights_id"] = msg.msg["host"].get("insights_id")
496497
insert_fields["updated_timestamp"] = msg.msg["host"].get("updated")
498+
insert_fields["owner_id"] = system_profile.get("owner_id")
497499
insert_fields["mssql"] = mssql
498500
insert_fields["ansible"] = ansible
499501
insert_fields["rhsm_version"] = rhsm_version

0 commit comments

Comments
 (0)