diff --git a/database/migrations/000047_entity_profiles_views.down.sql b/database/migrations/000047_entity_profiles_views.down.sql new file mode 100644 index 0000000000..dbc8581728 --- /dev/null +++ b/database/migrations/000047_entity_profiles_views.down.sql @@ -0,0 +1,19 @@ +-- Copyright 2024 Stacklok, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +BEGIN; + +ALTER VIEW profiles_with_entity_profiles SET (security_invoker = false); + +COMMIT; \ No newline at end of file diff --git a/database/migrations/000047_entity_profiles_views.up.sql b/database/migrations/000047_entity_profiles_views.up.sql new file mode 100644 index 0000000000..cc31ed8d9e --- /dev/null +++ b/database/migrations/000047_entity_profiles_views.up.sql @@ -0,0 +1,23 @@ +-- Copyright 2024 Stacklok, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +BEGIN; + +DROP VIEW profiles_with_entity_profiles; + +CREATE VIEW profiles_with_entity_profiles WITH (security_invoker = true) AS ( + SELECT entity_profiles.*, profiles.id as profid FROM profiles LEFT JOIN entity_profiles ON profiles.id = entity_profiles.profile_id +); + +COMMIT; \ No newline at end of file