Skip to content

Commit 67166fe

Browse files
committed
RHINENG-20474: updated to reflect current schema
1 parent da62c71 commit 67166fe

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

dev/test_generate_data.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ do $$
106106
rnd_date1 := now() - make_interval(days => (rnd*30)::int);
107107
rnd_date2 := rnd_date1 + make_interval(days => (rnd*10)::int);
108108
insert into system_platform
109-
(inventory_id, display_name, rh_account_id, vmaas_json, json_checksum, last_updated, unchanged_since, last_upload, packages_installed, packages_updatable)
109+
(inventory_id, display_name, rh_account_id, vmaas_json, json_checksum,
110+
last_updated, unchanged_since, last_upload, last_evaluation,
111+
packages_installed, packages_installable, packages_applicable)
110112
values
111-
(gen_uuid, gen_uuid, trunc(rnd*rh_accounts)+1, json_data[trunc(rnd*3)], json_hash[trunc(rnd*3)], rnd_date2, rnd_date1, rnd_date2, trunc(rnd*1000), trunc(rnd*50))
113+
(gen_uuid, gen_uuid, trunc(rnd*rh_accounts)+1, json_data[trunc(rnd*3)], json_hash[trunc(rnd*3)],
114+
rnd_date2, rnd_date1, rnd_date2, rnd_date2,
115+
trunc(rnd*1000), trunc(rnd*50), trunc(rnd*50))
112116
on conflict do nothing;
113117
if mod(cnt, (wanted*progress/100)::int) = 0 then
114118
raise notice 'created % system_platforms', cnt;
@@ -121,7 +125,7 @@ $$
121125
;
122126

123127
-- fill inventory.hosts from system platform
124-
delete from inventory.hosts;
128+
truncate table inventory.hosts;
125129
insert into inventory.hosts (id, account, display_name, tags, updated, created, stale_timestamp,
126130
system_profile, reporter, per_reporter_staleness, org_id, groups )
127131
select sp.inventory_id, substr(ac.name, 0, 10), sp.display_name, '{}', sp.last_updated, sp.last_updated, coalesce(sp.stale_timestamp, now()),
@@ -350,7 +354,6 @@ do $$
350354
progress int;
351355
pkgs int;
352356
accounts int;
353-
update_data jsonb := '[{"evra": "5.10.13-200.fc31.x86_64", "advisory": "RH-100", "status": "Applicable"}]'::jsonb;
354357
rnd float;
355358
rnd1 float;
356359
rnd2 float;
@@ -369,8 +372,8 @@ do $$
369372
rnd1 := (0.8 + rnd * 0.4) * pkg_per_system;
370373
rnd2 := (pkgs-rnd-1) * rnd;
371374

372-
insert into system_package (rh_account_id, system_id, package_id, update_data, name_id)
373-
(select row.id, sp.id, p.id, update_data, p.name_id
375+
insert into system_package2 (rh_account_id, system_id, name_id, package_id, installable_id, applicable_id)
376+
(select row.id, sp.id, p.name_id, p.id, p.id, p.id
374377
from (select id, name_id from package limit rnd1::int offset rnd2::int) p,
375378
(select id from system_platform where rh_account_id = row.id) sp
376379
)
@@ -386,9 +389,6 @@ do $$
386389
$$
387390
;
388391

389-
-- copy data from old system_package to new
390-
insert into system_package2 (select rh_account_id, system_id, name_id, package_id, package_id, package_id from system_package);
391-
392392
-- show size of whole system_platform table
393393
SELECT
394394
parent.relname AS parent,
@@ -398,4 +398,4 @@ SELECT
398398
FROM pg_inherits
399399
JOIN pg_class parent ON pg_inherits.inhparent = parent.oid
400400
JOIN pg_class child ON pg_inherits.inhrelid = child.oid
401-
WHERE parent.relname in ('system_package', 'system_package2');
401+
WHERE parent.relname in ('system_platform', 'system_package2');

0 commit comments

Comments
 (0)