Skip to content

Commit 2f71729

Browse files
committed
Remove retired grant directives (replaced with graphql invite links)
1 parent 373e942 commit 2f71729

8 files changed

Lines changed: 26 additions & 258 deletions

File tree

crates/agent/src/directives/grant.rs

Lines changed: 0 additions & 252 deletions
This file was deleted.

crates/agent/src/directives/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use validator::Validate;
1111
pub mod accept_demo_tenant;
1212
pub mod beta_onboard;
1313
pub mod click_to_accept;
14-
pub mod grant;
1514
pub mod storage_mappings;
1615

1716
/// JobStatus is the possible outcomes of a handled directive operation.
@@ -43,7 +42,6 @@ pub enum Directive {
4342
BetaOnboard(beta_onboard::Directive),
4443
ClickToAccept(click_to_accept::Directive),
4544
AcceptDemoTenant(accept_demo_tenant::Directive),
46-
Grant(grant::Directive),
4745
StorageMappings(storage_mappings::Directive),
4846
}
4947

@@ -134,7 +132,6 @@ impl DirectiveHandler {
134132
}
135133
Ok(Directive::ClickToAccept(d)) => click_to_accept::apply(d, row, txn).await?,
136134
Ok(Directive::AcceptDemoTenant(d)) => accept_demo_tenant::apply(d, row, txn).await?,
137-
Ok(Directive::Grant(d)) => grant::apply(d, row, txn).await?,
138135
Ok(Directive::StorageMappings(d)) => {
139136
storage_mappings::apply(d, row, &self.logs_tx, txn).await?
140137
}

crates/agent/src/integration_tests/harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl TestHarness {
596596

597597
pub async fn add_user_grant(&mut self, user_id: Uuid, role: &str, capability: Capability) {
598598
let mut txn = self.pool.begin().await.unwrap();
599-
control_plane_api::directives::grant::upsert_user_grant(
599+
control_plane_api::grants::upsert_user_grant(
600600
user_id,
601601
role,
602602
capability,

crates/control-plane-api/src/directives/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod accept_demo_tenant;
22
pub mod beta_onboard;
3-
pub mod grant;
43
pub mod storage_mappings;
54

65
use crate::TextJson;
File renamed without changes.

crates/control-plane-api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod discovers;
1212
pub mod draft;
1313
mod envelope;
1414
pub mod evolutions;
15+
pub mod grants;
1516
mod interval;
1617
pub mod jobs;
1718
pub mod live_specs;

crates/control-plane-api/src/server/public/graphql/invite_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl InviteLinksMutation {
313313
}
314314

315315
// Upsert the user grant (only upgrades capability, never downgrades).
316-
crate::directives::grant::upsert_user_grant(
316+
crate::grants::upsert_user_grant(
317317
claims.sub,
318318
&invite.catalog_prefix,
319319
invite.capability,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
begin;
2+
3+
-- Phase 3: Retire grant directives.
4+
-- The invite links system (Phase 1a-b) has fully replaced grant directives.
5+
-- Drop the transitional dual-write triggers and clean up old directive rows.
6+
7+
-- Drop triggers first, then their backing functions.
8+
drop trigger if exists mirror_grant_directive on public.directives;
9+
drop trigger if exists sync_directive_removal on public.directives;
10+
11+
drop function if exists internal.mirror_grant_directive_to_invite_links();
12+
drop function if exists internal.sync_directive_removal_to_invite_links();
13+
14+
-- Delete applied_directives for grant directives (FK will not cascade from directives).
15+
delete from applied_directives
16+
where directive_id in (
17+
select id from directives where spec->>'type' = 'grant'
18+
);
19+
20+
-- Delete the grant directives themselves.
21+
delete from directives where spec->>'type' = 'grant';
22+
23+
commit;

0 commit comments

Comments
 (0)