Skip to content

Commit

Permalink
POC: migrate data from system_package table
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMraka committed Nov 22, 2023
1 parent 566972a commit 87478e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Empty file.
16 changes: 16 additions & 0 deletions database_admin/migrations/117_migrate_system_package2.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

-- migrate syste_package partitions one by one
DO
$$
DECLARE
part text;
BEGIN
FOR part IN (SELECT tablename from pg_tables t where t.tablename ~ '^system_package_[0-9]+$')
LOOP
RAISE NOTICE 'Copying the % partition', part;
EXECUTE 'INSERT INTO system_package2 (rh_account_id, system_id, name_id, package_id, installable_id, applicable_id)
( SELECT rh_account_id, system_id, name_id, package_id, NULL, NULL FROM ' ||
part || ') ON CONFLICT DO NOTHING';
END LOOP;
END
$$ LANGUAGE plpgsql;
2 changes: 1 addition & 1 deletion database_admin/schema/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations


INSERT INTO schema_migrations
VALUES (116, false);
VALUES (117, false);

-- ---------------------------------------------------------------------------
-- Functions
Expand Down

0 comments on commit 87478e2

Please sign in to comment.