You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ON CONFLICT (store, object_type, object_id, relation, _user) DO NOTHING;
56
57
```
57
58
58
-
The `ulid` is derived deterministically from the natural key so the insert is idempotent — safe to re-run.
59
+
**3. Verify row counts match step 1**
60
+
61
+
```sql
62
+
SELECT object_type, COUNT(*) AS migrated
63
+
FROM tuple
64
+
WHERE relation ='parent_context'
65
+
AND _user LIKE'organization:%'
66
+
GROUP BY object_type
67
+
ORDER BY object_type;
68
+
```
69
+
70
+
**If something looks wrong — rollback before releasing**
59
71
60
-
**3. Verify**
72
+
Substitute `$migration_start` with the timestamp recorded in step 2.
61
73
62
-
Spot-check that `parent_context` rows now exist for the same objects that had `parent` rows:
74
+
```sql
75
+
DELETEFROM tuple
76
+
WHERE relation ='parent_context'
77
+
AND _user LIKE'organization:%'
78
+
AND inserted_at >='$migration_start';
79
+
```
80
+
81
+
---
82
+
83
+
## Release
84
+
85
+
Deploy the updated FGA model after the tuples are written. Deploying the model before the migration means objects will temporarily lose org-context permissions.
86
+
87
+
---
88
+
89
+
## Post-release steps
90
+
91
+
**4. Verify the new model is using `parent_context`**
92
+
93
+
Spot-check a known object in a known org and confirm permissions resolve correctly. Then confirm the counts are still what you expect:
63
94
64
95
```sql
65
-
SELECT object_type, COUNT(*)
96
+
SELECT object_type, COUNT(*)AS migrated
66
97
FROM tuple
67
98
WHERE relation ='parent_context'
68
99
AND _user LIKE'organization:%'
69
100
GROUP BY object_type
70
101
ORDER BY object_type;
71
102
```
72
103
73
-
**4. Deploy the updated FGA model**
104
+
**5. Clean up old `parent` tuples**
74
105
75
-
The new model must be deployed after the tuples are written. Deploying the model before the migration means objects will temporarily lose org-context permissions.
106
+
Once the new model is live and verified, the old `parent` + `organization:*` tuples are no longer read by the model and can be deleted:
76
107
77
-
**5. (Optional) Clean up old `parent` tuples**
108
+
```sql
109
+
DELETEFROM tuple
110
+
WHERE relation ='parent'
111
+
AND _user LIKE'organization:%'
112
+
AND object_type !='file';
113
+
```
78
114
79
-
Once the new model is live and verified, the old `parent` + `organization:*` tuples are no longer used and can be deleted:
0 commit comments