1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require '20200501150153_permission_table_constants'
7 class FrozenGroups < ActiveRecord::Migration[5.0]
9 create_table :frozen_groups, :id => false do |t|
12 add_index :frozen_groups, :uuid, :unique => true
14 ActiveRecord::Base.connection.execute %{
15 create or replace function project_subtree_with_is_frozen (starting_uuid varchar(27), starting_is_frozen boolean)
16 returns table (uuid varchar(27), is_frozen boolean)
21 project_subtree(uuid, is_frozen) as (
22 values (starting_uuid, starting_is_frozen)
24 select groups.uuid, project_subtree.is_frozen or groups.frozen_by_uuid is not null
25 from groups join project_subtree on project_subtree.uuid = groups.owner_uuid
27 select uuid, is_frozen from project_subtree;
31 # Initialize the table. After this, it is updated incrementally.
32 # See app/models/group.rb#update_frozen_groups
37 drop_table :frozen_groups