-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC: migrate data from system_package table
- Loading branch information
1 parent
566972a
commit 87478e2
Showing
3 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
16 changes: 16 additions & 0 deletions
16
database_admin/migrations/117_migrate_system_package2.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters