Skip to content

Commit

Permalink
fix(DB): RHINENG-1986 add missing os_minor_version to tailorings
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Nov 1, 2023
1 parent bd2b8ac commit 1331420
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
6 changes: 6 additions & 0 deletions db/migrate/20231101162444_update_tailorings_to_version_2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class UpdateTailoringsToVersion2 < ActiveRecord::Migration[7.0]
def change

update_view :tailorings, version: 2, revert_to_version: 1
end
end
34 changes: 16 additions & 18 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_10_26_194802) do
ActiveRecord::Schema[7.0].define(version: 2023_11_01_162444) do
# These are extensions that must be enabled in order to support this database
enable_extension "dblink"
enable_extension "pgcrypto"
Expand Down Expand Up @@ -311,16 +311,6 @@
rules.identifier
FROM rules;
SQL
create_view "tailorings", sql_definition: <<-SQL
SELECT profiles.id,
profiles.policy_id,
profiles.parent_profile_id AS profile_id,
profiles.value_overrides,
profiles.created_at,
profiles.updated_at
FROM profiles
WHERE (profiles.parent_profile_id IS NOT NULL);
SQL
create_view "v2_policies", sql_definition: <<-SQL
SELECT policies.id,
policies.name AS title,
Expand All @@ -337,6 +327,17 @@
FROM policy_hosts
GROUP BY policy_hosts.policy_id) sq ON ((sq.policy_id = policies.id)));
SQL
create_view "tailorings", sql_definition: <<-SQL
SELECT profiles.id,
profiles.policy_id,
profiles.parent_profile_id AS profile_id,
profiles.value_overrides,
profiles.os_minor_version,
profiles.created_at,
profiles.updated_at
FROM profiles
WHERE (profiles.parent_profile_id IS NOT NULL);
SQL
create_function :tailorings_insert, sql_definition: <<-'SQL'
CREATE OR REPLACE FUNCTION public.tailorings_insert()
RETURNS trigger
Expand Down Expand Up @@ -456,16 +457,13 @@
SQL


create_trigger :tailorings_insert, sql_definition: <<-SQL
CREATE TRIGGER tailorings_insert INSTEAD OF INSERT ON public.tailorings FOR EACH ROW EXECUTE FUNCTION tailorings_insert()
SQL
create_trigger :v2_policies_insert, sql_definition: <<-SQL
CREATE TRIGGER v2_policies_insert INSTEAD OF INSERT ON public.v2_policies FOR EACH ROW EXECUTE FUNCTION v2_policies_insert()
create_trigger :v2_policies_update, sql_definition: <<-SQL
CREATE TRIGGER v2_policies_update INSTEAD OF UPDATE ON public.v2_policies FOR EACH ROW EXECUTE FUNCTION v2_policies_update()
SQL
create_trigger :v2_policies_delete, sql_definition: <<-SQL
CREATE TRIGGER v2_policies_delete INSTEAD OF DELETE ON public.v2_policies FOR EACH ROW EXECUTE FUNCTION v2_policies_delete()
SQL
create_trigger :v2_policies_update, sql_definition: <<-SQL
CREATE TRIGGER v2_policies_update INSTEAD OF UPDATE ON public.v2_policies FOR EACH ROW EXECUTE FUNCTION v2_policies_update()
create_trigger :v2_policies_insert, sql_definition: <<-SQL
CREATE TRIGGER v2_policies_insert INSTEAD OF INSERT ON public.v2_policies FOR EACH ROW EXECUTE FUNCTION v2_policies_insert()
SQL
end
9 changes: 9 additions & 0 deletions db/views/tailorings_v02.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT
"profiles"."id",
"profiles"."policy_id",
"profiles"."parent_profile_id" AS "profile_id",
"profiles"."value_overrides",
"profiles"."os_minor_version",
"profiles"."created_at",
"profiles"."updated_at"
FROM "profiles" WHERE "profiles"."parent_profile_id" IS NOT NULL;

0 comments on commit 1331420

Please sign in to comment.