Files
threshold/internal/db/schema/migrations/postgres/17/02_hostplugin.up.sql
T
Todd a4ea99047f Remove Prefix Id and Plugin Name fields (#1563)
* Remove Prefix Id and Plugin Name fields.  Creating catalogs now require either the plugin id or the name of the plugin resource (but not both).  Host Catalogs and Host Sets API resources now have a read only plugin field populated with plugin info.  Host Catalogs have a plugin id field as a top level field.
2021-09-24 13:16:13 -07:00

76 lines
2.4 KiB
PL/PgSQL

begin;
/*
┌──────────────────┐
│ plugin │
├──────────────────┤
│public_id (pk) │
│scope_id (fk) │
└──────────────────┘
┼
┼
│
┼
┼
┌──────────────────┐
│ plugin_host │
├──────────────────┤
│public_id (pk) │
│scope_id (fk) │
│name │
│description │
│version │
│plugin_name │
│id_prefix │
└──────────────────┘
*/
create table plugin_host (
public_id wt_plugin_id primary key,
scope_id wt_scope_id not null
-- TODO: Allow plugins to be created in different scopes and
-- constrain the host-catalog's plugin reference accordingly.
constraint iam_scope_global_fkey
references iam_scope_global(scope_id)
on delete cascade
on update cascade,
name wt_name,
description text,
create_time wt_timestamp,
update_time wt_timestamp,
version wt_version,
constraint plugin_fkey
foreign key (scope_id, public_id)
references plugin(scope_id, public_id)
on delete cascade
on update cascade,
constraint plugin_host_scope_id_name_uq
unique(scope_id, name)
);
create trigger update_version_column after update on plugin_host
for each row execute procedure update_version_column();
create trigger update_time_column before update on plugin_host
for each row execute procedure update_time_column();
create trigger default_create_time_column before insert on plugin_host
for each row execute procedure default_create_time();
create trigger immutable_columns before update on plugin_host
for each row execute procedure immutable_columns('public_id', 'create_time');
create trigger insert_plugin_subtype before insert on plugin_host
for each row execute procedure insert_plugin_subtype();
create trigger update_plugin_subtype before update on plugin_host
for each row execute procedure update_plugin_subtype();
create trigger delete_plugin_subtype after delete on plugin_host
for each row execute procedure delete_plugin_subtype();
insert into oplog_ticket (name, version)
values
('plugin_host', 1);
commit;