2023-09-18 03:31:23 -05:00
|
|
|
create type sentinel_action_result as enum ('Success', 'Failed');
|
|
|
|
|
|
|
|
create type sentinel_decision as enum ('Undecided', 'Allowed', 'Blocked', 'Challenge');
|
2023-09-14 03:32:55 -05:00
|
|
|
|
|
|
|
create table sentinel_activities (
|
|
|
|
tenant_id varchar(21) not null
|
|
|
|
references tenants (id) on update cascade on delete cascade,
|
|
|
|
id varchar(21) not null,
|
2023-09-14 09:37:55 -05:00
|
|
|
/** The target that the action was performed on. */
|
2023-09-14 03:32:55 -05:00
|
|
|
target_type varchar(32) /* @use SentinelActivityTargetType */ not null,
|
2023-09-18 03:31:23 -05:00
|
|
|
/** The target hashed identifier. */
|
|
|
|
target_hash varchar(64) not null,
|
2023-09-14 09:37:55 -05:00
|
|
|
/** The action name that was performed. */
|
2023-09-14 03:32:55 -05:00
|
|
|
action varchar(64) /* @use SentinelActivityAction */ not null,
|
2023-09-14 09:37:55 -05:00
|
|
|
/** If the action was successful or not. */
|
2023-09-18 03:31:23 -05:00
|
|
|
action_result sentinel_action_result not null,
|
2023-09-14 09:37:55 -05:00
|
|
|
/** Additional payload data if any. */
|
|
|
|
payload jsonb /* @use SentinelActivityPayload */ not null,
|
2023-09-18 03:31:23 -05:00
|
|
|
/** The sentinel decision for the action. */
|
|
|
|
decision sentinel_decision not null,
|
2023-09-18 23:03:58 -05:00
|
|
|
/** The expiry date of the decision. For instant decisions, this is the date the activity was created. */
|
2023-09-18 03:31:23 -05:00
|
|
|
decision_expires_at timestamptz not null default(now()),
|
|
|
|
/** The time the activity was created. */
|
2023-09-14 03:32:55 -05:00
|
|
|
created_at timestamptz not null default(now()),
|
|
|
|
primary key (id)
|
|
|
|
);
|
2023-09-18 03:31:23 -05:00
|
|
|
|
|
|
|
create index sentinel_activities__id
|
|
|
|
on sentinel_activities (tenant_id, id);
|
|
|
|
|
|
|
|
create index sentinel_activities__target_type_target_hash_action_action_result_decision
|
|
|
|
on sentinel_activities (tenant_id, target_type, target_hash, action, action_result, decision);
|