@jmruthers/pace-core 0.5.190 → 0.5.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DataTable-IVYljGJ6.d.ts → DataTable-Be6dH_dR.d.ts} +1 -1
- package/dist/{DataTable-ON3IXISJ.js → DataTable-WKRZD47S.js} +6 -6
- package/dist/{PublicPageProvider-C4uxosp6.d.ts → PublicPageProvider-ULXC_u6U.d.ts} +1 -1
- package/dist/{UnifiedAuthProvider-X5NXANVI.js → UnifiedAuthProvider-FTSG5XH7.js} +3 -3
- package/dist/{api-I6UCQ5S6.js → api-IHKALJZD.js} +2 -2
- package/dist/{chunk-J2XXC7R5.js → chunk-6LTQQAT6.js} +77 -111
- package/dist/chunk-6LTQQAT6.js.map +1 -0
- package/dist/{chunk-STYK4OH2.js → chunk-6TQDD426.js} +10 -10
- package/dist/chunk-6TQDD426.js.map +1 -0
- package/dist/{chunk-DZWK57KZ.js → chunk-G37KK66H.js} +1 -1
- package/dist/{chunk-DZWK57KZ.js.map → chunk-G37KK66H.js.map} +1 -1
- package/dist/{chunk-73HSNNOQ.js → chunk-LOMZXPSN.js} +13 -13
- package/dist/{chunk-Y4BUBBHD.js → chunk-OETXORNB.js} +3 -3
- package/dist/{chunk-RUYZKXOD.js → chunk-ROXMHMY2.js} +5 -3
- package/dist/chunk-ROXMHMY2.js.map +1 -0
- package/dist/{chunk-SDMHPX3X.js → chunk-ULHIJK66.js} +56 -21
- package/dist/{chunk-SDMHPX3X.js.map → chunk-ULHIJK66.js.map} +1 -1
- package/dist/{chunk-VVBAW5A5.js → chunk-VKB2CO4Z.js} +46 -35
- package/dist/chunk-VKB2CO4Z.js.map +1 -0
- package/dist/{chunk-HQVPB5MZ.js → chunk-VRGWKHDB.js} +6 -6
- package/dist/{chunk-NIU6J6OX.js → chunk-XNYQOL3Z.js} +16 -16
- package/dist/chunk-XNYQOL3Z.js.map +1 -0
- package/dist/{chunk-4QYC5L4K.js → chunk-XYXSXPUK.js} +22 -27
- package/dist/chunk-XYXSXPUK.js.map +1 -0
- package/dist/components.d.ts +3 -3
- package/dist/components.js +8 -8
- package/dist/{database.generated-DI89OQeI.d.ts → database.generated-CzIvgcPu.d.ts} +165 -201
- package/dist/hooks.d.ts +12 -12
- package/dist/hooks.js +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +18 -23
- package/dist/index.js.map +1 -1
- package/dist/providers.js +2 -2
- package/dist/rbac/index.d.ts +1 -1
- package/dist/rbac/index.js +6 -6
- package/dist/{types-Bwgl--Xo.d.ts → types-CEpcvwwF.d.ts} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/{usePublicRouteParams-DxIDS4bC.d.ts → usePublicRouteParams-TZe0gy-4.d.ts} +1 -1
- package/dist/utils.d.ts +8 -8
- package/dist/utils.js +2 -2
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/Logger.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +2 -2
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +2 -2
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +5 -5
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/enums/LogLevel.md +1 -1
- package/docs/api/enums/RBACErrorCode.md +1 -1
- package/docs/api/enums/RPCFunction.md +1 -1
- package/docs/api/interfaces/AddressFieldProps.md +1 -1
- package/docs/api/interfaces/AddressFieldRef.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/AutocompleteOptions.md +1 -1
- package/docs/api/interfaces/AvatarProps.md +1 -1
- package/docs/api/interfaces/BadgeProps.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CalendarProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/ComplianceResult.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/DatabaseComplianceResult.md +1 -1
- package/docs/api/interfaces/DatabaseIssue.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventAppRoleData.md +1 -1
- package/docs/api/interfaces/ExportColumn.md +1 -1
- package/docs/api/interfaces/ExportOptions.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/FormFieldProps.md +1 -1
- package/docs/api/interfaces/FormProps.md +1 -1
- package/docs/api/interfaces/GrantEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoggerConfig.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/ParsedAddress.md +2 -2
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/ProgressProps.md +1 -1
- package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/QuickFix.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
- package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
- package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +2 -2
- package/docs/api/interfaces/RBACContext.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPerformanceMetrics.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckResult.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
- package/docs/api/interfaces/RBACResult.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantParams.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeParams.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateParams.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
- package/docs/api/interfaces/RBACRolesListParams.md +1 -1
- package/docs/api/interfaces/RBACRolesListResult.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
- package/docs/api/interfaces/ResourcePermissions.md +1 -1
- package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RoleManagementResult.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/SetupIssue.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/TabsContentProps.md +1 -1
- package/docs/api/interfaces/TabsListProps.md +1 -1
- package/docs/api/interfaces/TabsProps.md +1 -1
- package/docs/api/interfaces/TabsTriggerProps.md +1 -1
- package/docs/api/interfaces/TextareaProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
- package/docs/api/interfaces/UseFormDialogReturn.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +2 -2
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +2 -2
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +2 -2
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +16 -16
- package/docs/migration/README.md +18 -0
- package/docs/migration/database-changes-december-2025.md +767 -0
- package/docs/migration/person-scoped-profiles-migration-guide.md +472 -0
- package/package.json +1 -1
- package/src/__tests__/public-recipe-view.test.ts +10 -10
- package/src/__tests__/rls-policies.test.ts +13 -13
- package/src/components/AddressField/README.md +6 -6
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +35 -15
- package/src/components/Select/Select.test.tsx +4 -1
- package/src/components/Select/Select.tsx +60 -15
- package/src/hooks/__tests__/usePermissionCache.simple.test.ts +192 -0
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +741 -0
- package/src/hooks/__tests__/usePublicEvent.simple.test.ts +703 -0
- package/src/hooks/__tests__/usePublicEvent.unit.test.ts +581 -0
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +9 -8
- package/src/hooks/public/usePublicEvent.ts +8 -8
- package/src/hooks/public/usePublicFileDisplay.ts +2 -2
- package/src/hooks/useFileDisplay.ts +8 -9
- package/src/hooks/useQueryCache.ts +6 -6
- package/src/hooks/useSecureDataAccess.test.ts +8 -8
- package/src/hooks/useSecureDataAccess.ts +15 -11
- package/src/providers/__tests__/OrganisationProvider.test.tsx +27 -21
- package/src/rbac/hooks/useRBAC.simple.test.ts +95 -0
- package/src/rbac/utils/__tests__/eventContext.test.ts +2 -2
- package/src/rbac/utils/__tests__/eventContext.unit.test.ts +490 -0
- package/src/rbac/utils/eventContext.ts +5 -2
- package/src/services/AuthService.ts +37 -8
- package/src/services/OrganisationService.ts +92 -139
- package/src/services/__tests__/OrganisationService.pagination.test.ts +34 -8
- package/src/services/__tests__/OrganisationService.test.ts +218 -86
- package/src/types/database.generated.ts +166 -201
- package/src/types/supabase.ts +2 -2
- package/src/utils/__tests__/secureDataAccess.unit.test.ts +3 -2
- package/src/utils/file-reference/index.ts +4 -4
- package/src/utils/google-places/googlePlacesUtils.ts +1 -1
- package/src/utils/google-places/types.ts +1 -1
- package/src/utils/request-deduplication.ts +4 -4
- package/src/utils/security/secureDataAccess.test.ts +1 -1
- package/src/utils/security/secureDataAccess.ts +7 -4
- package/src/utils/storage/README.md +1 -1
- package/dist/chunk-4QYC5L4K.js.map +0 -1
- package/dist/chunk-J2XXC7R5.js.map +0 -1
- package/dist/chunk-NIU6J6OX.js.map +0 -1
- package/dist/chunk-RUYZKXOD.js.map +0 -1
- package/dist/chunk-STYK4OH2.js.map +0 -1
- package/dist/chunk-VVBAW5A5.js.map +0 -1
- /package/dist/{DataTable-ON3IXISJ.js.map → DataTable-WKRZD47S.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-X5NXANVI.js.map → UnifiedAuthProvider-FTSG5XH7.js.map} +0 -0
- /package/dist/{api-I6UCQ5S6.js.map → api-IHKALJZD.js.map} +0 -0
- /package/dist/{chunk-73HSNNOQ.js.map → chunk-LOMZXPSN.js.map} +0 -0
- /package/dist/{chunk-Y4BUBBHD.js.map → chunk-OETXORNB.js.map} +0 -0
- /package/dist/{chunk-HQVPB5MZ.js.map → chunk-VRGWKHDB.js.map} +0 -0
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
# Database Changes - December 2025
|
|
2
|
+
|
|
3
|
+
**Version:** 0.5.190+
|
|
4
|
+
**Migration Date:** 2025-12-06
|
|
5
|
+
**Breaking Changes:** Yes
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This document details the database schema changes made in December 2025 that affect consuming applications. There are two major changes:
|
|
10
|
+
|
|
11
|
+
1. **Table Naming Standardization** (2025-12-06) - All tables renamed to follow `app_entity` pattern
|
|
12
|
+
2. **Person-Scoped Profiles Migration** (2025-12-05) - Profiles migrated from organisation-scoped to person-scoped
|
|
13
|
+
|
|
14
|
+
**⚠️ CRITICAL**: Both changes are **breaking changes** and require code updates in consuming applications.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Change 1: Table Naming Standardization
|
|
19
|
+
|
|
20
|
+
**Migration:** `20251206111258_standardize_table_naming_app_entity.sql`
|
|
21
|
+
**Date:** 2025-12-06
|
|
22
|
+
|
|
23
|
+
### Purpose
|
|
24
|
+
|
|
25
|
+
All tables have been renamed to follow the `app_entity` naming convention:
|
|
26
|
+
- **Core infrastructure tables** → `core_*` prefix
|
|
27
|
+
- **Application-specific tables** → `{app}_*` prefix (e.g., `cake_*`, `trac_*`, `medi_*`)
|
|
28
|
+
- **Shared PACE tables** → `core_*` prefix (since PACE is the overall suite)
|
|
29
|
+
|
|
30
|
+
### Table Renames
|
|
31
|
+
|
|
32
|
+
#### Core Infrastructure Tables
|
|
33
|
+
|
|
34
|
+
| Old Name | New Name | Notes |
|
|
35
|
+
|----------|----------|-------|
|
|
36
|
+
| `organisations` | `core_organisations` | Core organisation table |
|
|
37
|
+
| `event` | `core_events` | Core event table |
|
|
38
|
+
| `file_references` | `core_file_references` | File reference system |
|
|
39
|
+
| `form_context_types` | `core_form_context_types` | Form system |
|
|
40
|
+
| `form_field_config` | `core_form_field_config` | Form system |
|
|
41
|
+
| `form_fields` | `core_form_fields` | Form system |
|
|
42
|
+
| `form_response_values` | `core_form_response_values` | Form system |
|
|
43
|
+
| `form_responses` | `core_form_responses` | Form system |
|
|
44
|
+
| `forms` | `core_forms` | Form system |
|
|
45
|
+
| `event_app_access` | `core_event_app_access` | Event access control |
|
|
46
|
+
| `organisation_app_access` | `core_organisation_app_access` | Organisation access control |
|
|
47
|
+
| `organisation_audit_log` | `core_organisation_audit_log` | Audit logging |
|
|
48
|
+
|
|
49
|
+
#### PACE Tables (Renamed to `core_*`)
|
|
50
|
+
|
|
51
|
+
| Old Name | New Name | Notes |
|
|
52
|
+
|----------|----------|-------|
|
|
53
|
+
| `pace_person` | `core_person` | Person records |
|
|
54
|
+
| `pace_member` | `core_member` | Membership profiles |
|
|
55
|
+
| `pace_contact` | `core_contact` | Contact profiles |
|
|
56
|
+
| `pace_address` | `core_address` | Address records |
|
|
57
|
+
| `pace_phone` | `core_phone` | Phone records |
|
|
58
|
+
| `pace_consent` | `core_consent` | Consent records |
|
|
59
|
+
| `pace_consent_type` | `core_consent_type` | Consent types |
|
|
60
|
+
| `pace_contact_type` | `core_contact_type` | Contact types |
|
|
61
|
+
| `pace_field_list` | `core_field_list` | Field lists |
|
|
62
|
+
| `pace_gender_type` | `core_gender_type` | Gender types |
|
|
63
|
+
| `pace_identification` | `core_identification` | Identification records |
|
|
64
|
+
| `pace_identification_type` | `core_identification_type` | Identification types |
|
|
65
|
+
| `pace_member_role` | `core_member_role` | Member roles |
|
|
66
|
+
| `pace_membership_type` | `core_membership_type` | Membership types |
|
|
67
|
+
| `pace_merchandise` | `core_merchandise` | Merchandise records |
|
|
68
|
+
| `pace_phone_type` | `core_phone_type` | Phone types |
|
|
69
|
+
| `pace_pronoun_type` | `core_pronoun_type` | Pronoun types |
|
|
70
|
+
| `pace_qualification` | `core_qualification` | Qualification records |
|
|
71
|
+
| `pace_role_type` | `core_role_type` | Role types |
|
|
72
|
+
|
|
73
|
+
### View Changes
|
|
74
|
+
|
|
75
|
+
#### Membership Views
|
|
76
|
+
|
|
77
|
+
| Old Name | New Name | Notes |
|
|
78
|
+
|----------|----------|-------|
|
|
79
|
+
| `organisation_memberships` | **DROPPED** | Merged into `core_organisation_memberships` |
|
|
80
|
+
| `user_organisation_memberships` | **DROPPED** | Merged into `core_organisation_memberships` |
|
|
81
|
+
| - | `core_organisation_memberships` | **NEW** - Unified membership view |
|
|
82
|
+
|
|
83
|
+
**New View Details:**
|
|
84
|
+
|
|
85
|
+
The `core_organisation_memberships` view provides a unified view of organisation memberships:
|
|
86
|
+
|
|
87
|
+
```sql
|
|
88
|
+
CREATE VIEW core_organisation_memberships AS
|
|
89
|
+
SELECT
|
|
90
|
+
id,
|
|
91
|
+
user_id,
|
|
92
|
+
organisation_id,
|
|
93
|
+
role,
|
|
94
|
+
(role = ANY (ARRAY['org_admin'::rbac_organisation_role, 'leader'::rbac_organisation_role])) AS is_primary,
|
|
95
|
+
granted_at AS joined_at,
|
|
96
|
+
status,
|
|
97
|
+
created_at,
|
|
98
|
+
updated_at,
|
|
99
|
+
granted_by AS created_by,
|
|
100
|
+
revoked_by AS updated_by,
|
|
101
|
+
granted_at,
|
|
102
|
+
revoked_at,
|
|
103
|
+
valid_from,
|
|
104
|
+
valid_to,
|
|
105
|
+
notes
|
|
106
|
+
FROM rbac_organisation_roles ror
|
|
107
|
+
WHERE ror.status = 'active'::text
|
|
108
|
+
AND ror.revoked_at IS NULL
|
|
109
|
+
AND ror.valid_from <= NOW()
|
|
110
|
+
AND (ror.valid_to IS NULL OR ror.valid_to >= NOW())
|
|
111
|
+
AND ror.role IN (
|
|
112
|
+
'org_admin'::rbac_organisation_role,
|
|
113
|
+
'leader'::rbac_organisation_role,
|
|
114
|
+
'member'::rbac_organisation_role,
|
|
115
|
+
'supporter'::rbac_organisation_role
|
|
116
|
+
);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Key Features:**
|
|
120
|
+
- Returns only active, non-revoked memberships
|
|
121
|
+
- Includes all membership roles (org_admin, leader, member, supporter)
|
|
122
|
+
- Respects valid time windows (valid_from/valid_to)
|
|
123
|
+
- Optimized for RLS policies with `security_barrier=true` and `security_invoker=true`
|
|
124
|
+
|
|
125
|
+
#### Application-Specific Views
|
|
126
|
+
|
|
127
|
+
| Old Name | New Name | Notes |
|
|
128
|
+
|----------|----------|-------|
|
|
129
|
+
| `public_recipe_details` | `cake_public_recipe_details` | CAKE app public recipe view |
|
|
130
|
+
|
|
131
|
+
### Breaking Changes
|
|
132
|
+
|
|
133
|
+
#### 1. Direct Table Queries
|
|
134
|
+
|
|
135
|
+
**Before:**
|
|
136
|
+
```typescript
|
|
137
|
+
// ❌ This will fail - table name changed
|
|
138
|
+
const { data } = await supabase
|
|
139
|
+
.from('organisations')
|
|
140
|
+
.select('*');
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**After:**
|
|
144
|
+
```typescript
|
|
145
|
+
// ✅ Use new table name
|
|
146
|
+
const { data } = await supabase
|
|
147
|
+
.from('core_organisations')
|
|
148
|
+
.select('*');
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### 2. View Queries
|
|
152
|
+
|
|
153
|
+
**Before:**
|
|
154
|
+
```typescript
|
|
155
|
+
// ❌ This will fail - view dropped
|
|
156
|
+
const { data } = await supabase
|
|
157
|
+
.from('organisation_memberships')
|
|
158
|
+
.select('*')
|
|
159
|
+
.eq('organisation_id', orgId);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**After:**
|
|
163
|
+
```typescript
|
|
164
|
+
// ✅ Use new unified view
|
|
165
|
+
const { data } = await supabase
|
|
166
|
+
.from('core_organisation_memberships')
|
|
167
|
+
.select('*')
|
|
168
|
+
.eq('organisation_id', orgId);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### 3. Joins and Relationships
|
|
172
|
+
|
|
173
|
+
**Before:**
|
|
174
|
+
```typescript
|
|
175
|
+
// ❌ This will fail - table names changed
|
|
176
|
+
const { data } = await supabase
|
|
177
|
+
.from('pace_person')
|
|
178
|
+
.select('*, pace_member(*), organisations(*)')
|
|
179
|
+
.eq('id', personId);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**After:**
|
|
183
|
+
```typescript
|
|
184
|
+
// ✅ Use new table names
|
|
185
|
+
const { data } = await supabase
|
|
186
|
+
.from('core_person')
|
|
187
|
+
.select('*, core_member(*), core_organisations(*)')
|
|
188
|
+
.eq('id', personId);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### 4. File References
|
|
192
|
+
|
|
193
|
+
**Before:**
|
|
194
|
+
```typescript
|
|
195
|
+
// ❌ This will fail - table name changed
|
|
196
|
+
const { data } = await supabase
|
|
197
|
+
.from('file_references')
|
|
198
|
+
.select('*')
|
|
199
|
+
.eq('table_name', 'pace_person')
|
|
200
|
+
.eq('record_id', personId);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**After:**
|
|
204
|
+
```typescript
|
|
205
|
+
// ✅ Use new table names
|
|
206
|
+
const { data } = await supabase
|
|
207
|
+
.from('core_file_references')
|
|
208
|
+
.select('*')
|
|
209
|
+
.eq('table_name', 'core_person') // Also update table_name values
|
|
210
|
+
.eq('record_id', personId);
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Important**: The `table_name` column in `core_file_references` has been updated to use new table names. If you're querying by `table_name`, ensure you use the new names:
|
|
214
|
+
- `'pace_person'` → `'core_person'`
|
|
215
|
+
- `'event'` → `'core_events'`
|
|
216
|
+
- `'pace_member'` → `'core_member'`
|
|
217
|
+
- `'pace_contact'` → `'core_contact'`
|
|
218
|
+
- etc.
|
|
219
|
+
|
|
220
|
+
#### 5. Event Queries
|
|
221
|
+
|
|
222
|
+
**Before:**
|
|
223
|
+
```typescript
|
|
224
|
+
// ❌ This will fail - table name changed
|
|
225
|
+
const { data } = await supabase
|
|
226
|
+
.from('event')
|
|
227
|
+
.select('*')
|
|
228
|
+
.eq('event_id', eventId);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**After:**
|
|
232
|
+
```typescript
|
|
233
|
+
// ✅ Use new table name
|
|
234
|
+
const { data } = await supabase
|
|
235
|
+
.from('core_events')
|
|
236
|
+
.select('*')
|
|
237
|
+
.eq('event_id', eventId);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### RPC Functions Updated
|
|
241
|
+
|
|
242
|
+
The following RPC functions have been updated to use the new table names:
|
|
243
|
+
|
|
244
|
+
- `data_file_reference_url_get` - Now queries `core_file_references`
|
|
245
|
+
- `data_file_reference_get` - Now queries `core_file_references`
|
|
246
|
+
- `data_file_reference_delete` - Now queries `core_file_references`
|
|
247
|
+
- `check_user_pace_member_access` - Now queries `core_person` and `core_member`
|
|
248
|
+
- `check_user_medi_profile_access` - Now queries `core_member`
|
|
249
|
+
- `check_user_pace_contact_access` - Now queries `core_person` and `core_contact`
|
|
250
|
+
- `check_user_event_access` - Now queries `core_events`
|
|
251
|
+
- `check_public_event_visible` - Now queries `core_events`
|
|
252
|
+
- `get_event_organisation_id` - Now queries `core_events`
|
|
253
|
+
- `is_event_visible` - Now queries `core_events`
|
|
254
|
+
- `data_user_events_get` - Now queries `core_events`
|
|
255
|
+
- `data_user_organisation_roles_get` - Now queries `core_organisations`
|
|
256
|
+
- `data_user_organisations_get` - Now queries `core_organisations`
|
|
257
|
+
- `get_public_event_by_code` - Now queries `core_events` and `core_file_references`
|
|
258
|
+
- `app_cake_dish_create` - Now queries `core_events`
|
|
259
|
+
- `app_cake_dish_update` - Now queries `core_events`
|
|
260
|
+
- `app_cake_unit_create` - Now queries `core_events`
|
|
261
|
+
- `app_base_application_create` - Now queries `core_person` and `core_events`
|
|
262
|
+
- `app_pace_contact_update` - Now queries `core_contact`, `core_person`, `core_member`, `core_phone`
|
|
263
|
+
- `set_super_admin_override` - Now queries `core_organisations`
|
|
264
|
+
- `get_organisation_members` - Now uses `core_organisation_memberships` view
|
|
265
|
+
|
|
266
|
+
**Note**: RPC function signatures have not changed - only internal table references. Your RPC calls should continue to work, but ensure you're using the correct table names in any direct queries.
|
|
267
|
+
|
|
268
|
+
### TypeScript Type Updates
|
|
269
|
+
|
|
270
|
+
After applying migrations, **regenerate your database types**:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npx supabase gen types typescript --project-id <your-project-id> > src/types/database.generated.ts
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The updated types will reflect:
|
|
277
|
+
- All table names changed to `core_*` or `{app}_*` prefixes
|
|
278
|
+
- View names updated
|
|
279
|
+
- Relationship types updated
|
|
280
|
+
|
|
281
|
+
### Migration Checklist
|
|
282
|
+
|
|
283
|
+
Use this checklist to identify areas in your app that need updates:
|
|
284
|
+
|
|
285
|
+
#### Database Queries
|
|
286
|
+
- [ ] Search codebase for `from('organisations')` → Update to `from('core_organisations')`
|
|
287
|
+
- [ ] Search codebase for `from('event')` → Update to `from('core_events')`
|
|
288
|
+
- [ ] Search codebase for `from('file_references')` → Update to `from('core_file_references')`
|
|
289
|
+
- [ ] Search codebase for `from('pace_*')` → Update to `from('core_*')`
|
|
290
|
+
- [ ] Search codebase for `from('organisation_memberships')` → Update to `from('core_organisation_memberships')`
|
|
291
|
+
- [ ] Search codebase for `from('user_organisation_memberships')` → Update to `from('core_organisation_memberships')`
|
|
292
|
+
- [ ] Search codebase for `from('public_recipe_details')` → Update to `from('cake_public_recipe_details')`
|
|
293
|
+
|
|
294
|
+
#### TypeScript Types
|
|
295
|
+
- [ ] Regenerate database types from current schema
|
|
296
|
+
- [ ] Update all type references to use new table names
|
|
297
|
+
- [ ] Update interface definitions that reference old table names
|
|
298
|
+
|
|
299
|
+
#### File References
|
|
300
|
+
- [ ] Update `table_name` values in file reference queries to use new table names
|
|
301
|
+
- [ ] Review file upload code that sets `table_name`
|
|
302
|
+
- [ ] Update file reference display components
|
|
303
|
+
|
|
304
|
+
#### Joins and Relationships
|
|
305
|
+
- [ ] Update all `.select()` statements with joins to use new table names
|
|
306
|
+
- [ ] Review relationship queries (e.g., `pace_person(*)` → `core_person(*)`)
|
|
307
|
+
- [ ] Update foreign key lookups
|
|
308
|
+
|
|
309
|
+
#### RLS Policies
|
|
310
|
+
- [ ] Review any custom RLS policies that reference old table names
|
|
311
|
+
- [ ] Update policy definitions if you have custom policies
|
|
312
|
+
|
|
313
|
+
### Code Migration Examples
|
|
314
|
+
|
|
315
|
+
#### Example 1: Organisation Query
|
|
316
|
+
|
|
317
|
+
**Before:**
|
|
318
|
+
```typescript
|
|
319
|
+
const { data: organisations } = await supabase
|
|
320
|
+
.from('organisations')
|
|
321
|
+
.select('*')
|
|
322
|
+
.eq('is_active', true);
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**After:**
|
|
326
|
+
```typescript
|
|
327
|
+
const { data: organisations } = await supabase
|
|
328
|
+
.from('core_organisations')
|
|
329
|
+
.select('*')
|
|
330
|
+
.eq('is_active', true);
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Example 2: Event Query with Joins
|
|
334
|
+
|
|
335
|
+
**Before:**
|
|
336
|
+
```typescript
|
|
337
|
+
const { data: events } = await supabase
|
|
338
|
+
.from('event')
|
|
339
|
+
.select(`
|
|
340
|
+
*,
|
|
341
|
+
organisations(*)
|
|
342
|
+
`)
|
|
343
|
+
.eq('organisation_id', orgId);
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**After:**
|
|
347
|
+
```typescript
|
|
348
|
+
const { data: events } = await supabase
|
|
349
|
+
.from('core_events')
|
|
350
|
+
.select(`
|
|
351
|
+
*,
|
|
352
|
+
core_organisations(*)
|
|
353
|
+
`)
|
|
354
|
+
.eq('organisation_id', orgId);
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### Example 3: Person with Member Profile
|
|
358
|
+
|
|
359
|
+
**Before:**
|
|
360
|
+
```typescript
|
|
361
|
+
const { data: person } = await supabase
|
|
362
|
+
.from('pace_person')
|
|
363
|
+
.select(`
|
|
364
|
+
*,
|
|
365
|
+
pace_member(*)
|
|
366
|
+
`)
|
|
367
|
+
.eq('id', personId)
|
|
368
|
+
.single();
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**After:**
|
|
372
|
+
```typescript
|
|
373
|
+
const { data: person } = await supabase
|
|
374
|
+
.from('core_person')
|
|
375
|
+
.select(`
|
|
376
|
+
*,
|
|
377
|
+
core_member(*)
|
|
378
|
+
`)
|
|
379
|
+
.eq('id', personId)
|
|
380
|
+
.single();
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### Example 4: Organisation Memberships
|
|
384
|
+
|
|
385
|
+
**Before:**
|
|
386
|
+
```typescript
|
|
387
|
+
const { data: memberships } = await supabase
|
|
388
|
+
.from('organisation_memberships')
|
|
389
|
+
.select('*')
|
|
390
|
+
.eq('organisation_id', orgId)
|
|
391
|
+
.eq('user_id', userId);
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**After:**
|
|
395
|
+
```typescript
|
|
396
|
+
const { data: memberships } = await supabase
|
|
397
|
+
.from('core_organisation_memberships')
|
|
398
|
+
.select('*')
|
|
399
|
+
.eq('organisation_id', orgId)
|
|
400
|
+
.eq('user_id', userId);
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
#### Example 5: File References
|
|
404
|
+
|
|
405
|
+
**Before:**
|
|
406
|
+
```typescript
|
|
407
|
+
const { data: files } = await supabase
|
|
408
|
+
.from('file_references')
|
|
409
|
+
.select('*')
|
|
410
|
+
.eq('table_name', 'pace_person')
|
|
411
|
+
.eq('record_id', personId);
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**After:**
|
|
415
|
+
```typescript
|
|
416
|
+
const { data: files } = await supabase
|
|
417
|
+
.from('core_file_references')
|
|
418
|
+
.select('*')
|
|
419
|
+
.eq('table_name', 'core_person') // Updated table_name value
|
|
420
|
+
.eq('record_id', personId);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Change 2: Person-Scoped Profiles Migration
|
|
426
|
+
|
|
427
|
+
**Migration:** `20251205211120_migrate_profiles_to_person_scoped.sql` + related migrations
|
|
428
|
+
**Date:** 2025-12-05
|
|
429
|
+
**Documentation:** See [Person-Scoped Profiles Migration Guide](./person-scoped-profiles-migration-guide.md)
|
|
430
|
+
|
|
431
|
+
### Quick Summary
|
|
432
|
+
|
|
433
|
+
Profiles have been migrated from **organisation-scoped** to **person-scoped**:
|
|
434
|
+
|
|
435
|
+
- **One membership profile** (`core_member`) per person (regardless of organisation)
|
|
436
|
+
- **One medical profile** (`medi_profile`) per person
|
|
437
|
+
- **Multiple contact profiles** (`core_contact`) per person
|
|
438
|
+
|
|
439
|
+
### Key Changes
|
|
440
|
+
|
|
441
|
+
1. **Removed `organisation_id`** from:
|
|
442
|
+
- `core_member` (was `pace_member`)
|
|
443
|
+
- `medi_profile`
|
|
444
|
+
- `core_contact` (was `pace_contact`)
|
|
445
|
+
- Related tables: `medi_condition`, `medi_diet`, `medi_action_plan`, `core_consent`, `core_identification`, `core_qualification`
|
|
446
|
+
|
|
447
|
+
2. **Removed `member_id`** from `core_contact` (now uses `person_id` directly)
|
|
448
|
+
|
|
449
|
+
3. **Added unique constraint** on `core_member.person_id` (one membership per person)
|
|
450
|
+
|
|
451
|
+
### Impact on Table Naming
|
|
452
|
+
|
|
453
|
+
Note that the person-scoped profiles migration happened **before** the table naming standardization. The tables were renamed as part of the standardization:
|
|
454
|
+
|
|
455
|
+
- `pace_member` → `core_member` (person-scoped, no `organisation_id`)
|
|
456
|
+
- `pace_contact` → `core_contact` (person-scoped, uses `person_id` instead of `member_id`)
|
|
457
|
+
- `pace_person` → `core_person`
|
|
458
|
+
|
|
459
|
+
### Combined Migration Example
|
|
460
|
+
|
|
461
|
+
**Before (Old Schema):**
|
|
462
|
+
```typescript
|
|
463
|
+
// ❌ Old table names + organisation-scoped
|
|
464
|
+
const { data } = await supabase
|
|
465
|
+
.from('pace_member')
|
|
466
|
+
.select('*')
|
|
467
|
+
.eq('person_id', personId)
|
|
468
|
+
.eq('organisation_id', orgId); // ❌ organisation_id no longer exists
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**After (New Schema):**
|
|
472
|
+
```typescript
|
|
473
|
+
// ✅ New table names + person-scoped
|
|
474
|
+
const { data } = await supabase
|
|
475
|
+
.from('core_member')
|
|
476
|
+
.select('*')
|
|
477
|
+
.eq('person_id', personId); // ✅ No organisation_id needed
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Complete Migration Checklist
|
|
483
|
+
|
|
484
|
+
### Phase 1: Table Naming Updates
|
|
485
|
+
|
|
486
|
+
- [ ] Update all `from('organisations')` → `from('core_organisations')`
|
|
487
|
+
- [ ] Update all `from('event')` → `from('core_events')`
|
|
488
|
+
- [ ] Update all `from('file_references')` → `from('core_file_references')`
|
|
489
|
+
- [ ] Update all `from('pace_*')` → `from('core_*')`
|
|
490
|
+
- [ ] Update all `from('organisation_memberships')` → `from('core_organisation_memberships')`
|
|
491
|
+
- [ ] Update all `from('user_organisation_memberships')` → `from('core_organisation_memberships')`
|
|
492
|
+
- [ ] Update all `from('public_recipe_details')` → `from('cake_public_recipe_details')`
|
|
493
|
+
- [ ] Update all `.select()` joins to use new table names
|
|
494
|
+
- [ ] Update `table_name` values in file reference queries
|
|
495
|
+
- [ ] Regenerate TypeScript types
|
|
496
|
+
|
|
497
|
+
### Phase 2: Person-Scoped Profiles Updates
|
|
498
|
+
|
|
499
|
+
- [ ] Remove `organisation_id` filters from profile table queries
|
|
500
|
+
- [ ] Update `pace_contact` queries to use `person_id` instead of `member_id`
|
|
501
|
+
- [ ] Update profile creation logic (no `organisation_id` needed)
|
|
502
|
+
- [ ] Review profile access patterns (person-scoped, not org-scoped)
|
|
503
|
+
- [ ] See [Person-Scoped Profiles Migration Guide](./person-scoped-profiles-migration-guide.md) for detailed checklist
|
|
504
|
+
|
|
505
|
+
### Phase 3: Testing
|
|
506
|
+
|
|
507
|
+
- [ ] Test all database queries with new table names
|
|
508
|
+
- [ ] Test profile queries (person-scoped)
|
|
509
|
+
- [ ] Test file reference queries
|
|
510
|
+
- [ ] Test organisation membership queries
|
|
511
|
+
- [ ] Test event queries
|
|
512
|
+
- [ ] Verify RLS policies work correctly
|
|
513
|
+
- [ ] Test cross-organisation scenarios
|
|
514
|
+
|
|
515
|
+
### Phase 4: Type Updates
|
|
516
|
+
|
|
517
|
+
- [ ] Regenerate TypeScript types from current schema
|
|
518
|
+
- [ ] Update all type references
|
|
519
|
+
- [ ] Fix TypeScript compilation errors
|
|
520
|
+
- [ ] Update interface definitions
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## RPC Functions Reference
|
|
525
|
+
|
|
526
|
+
All RPC functions have been updated internally to use the new table names. Function signatures remain the same, so your RPC calls should continue to work without changes.
|
|
527
|
+
|
|
528
|
+
However, if you're using RPC functions that return data with table names (e.g., in `table_name` columns), ensure you handle the new table names correctly.
|
|
529
|
+
|
|
530
|
+
### Updated RPC Functions
|
|
531
|
+
|
|
532
|
+
The following RPC functions now use new table names internally:
|
|
533
|
+
|
|
534
|
+
**File Reference Functions:**
|
|
535
|
+
- `data_file_reference_url_get`
|
|
536
|
+
- `data_file_reference_get`
|
|
537
|
+
- `data_file_reference_delete`
|
|
538
|
+
- `data_file_reference_create`
|
|
539
|
+
|
|
540
|
+
**Profile Functions:**
|
|
541
|
+
- `data_pace_member_profile_get`
|
|
542
|
+
- `data_pace_linked_profiles_list`
|
|
543
|
+
- `data_pace_contacts_list`
|
|
544
|
+
- `data_pace_contact_get`
|
|
545
|
+
- `app_pace_contact_update`
|
|
546
|
+
|
|
547
|
+
**Event Functions:**
|
|
548
|
+
- `data_user_events_get`
|
|
549
|
+
- `get_public_event_by_code`
|
|
550
|
+
- `check_user_event_access`
|
|
551
|
+
- `check_public_event_visible`
|
|
552
|
+
|
|
553
|
+
**Organisation Functions:**
|
|
554
|
+
- `data_user_organisations_get`
|
|
555
|
+
- `data_user_organisation_roles_get`
|
|
556
|
+
- `get_organisation_members`
|
|
557
|
+
|
|
558
|
+
**Application Functions:**
|
|
559
|
+
- `app_cake_dish_create`
|
|
560
|
+
- `app_cake_dish_update`
|
|
561
|
+
- `app_cake_unit_create`
|
|
562
|
+
- `app_base_application_create`
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
## Common Issues and Solutions
|
|
567
|
+
|
|
568
|
+
### Issue 1: "relation does not exist"
|
|
569
|
+
|
|
570
|
+
**Error:**
|
|
571
|
+
```
|
|
572
|
+
relation "organisations" does not exist
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
**Solution:**
|
|
576
|
+
Update table name to `core_organisations`:
|
|
577
|
+
```typescript
|
|
578
|
+
// ❌ Old
|
|
579
|
+
.from('organisations')
|
|
580
|
+
|
|
581
|
+
// ✅ New
|
|
582
|
+
.from('core_organisations')
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### Issue 2: "column does not exist"
|
|
586
|
+
|
|
587
|
+
**Error:**
|
|
588
|
+
```
|
|
589
|
+
column "organisation_id" does not exist in table "core_member"
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
**Solution:**
|
|
593
|
+
Remove `organisation_id` filters from profile table queries. Profiles are now person-scoped:
|
|
594
|
+
```typescript
|
|
595
|
+
// ❌ Old
|
|
596
|
+
.from('core_member')
|
|
597
|
+
.eq('organisation_id', orgId) // ❌ Column doesn't exist
|
|
598
|
+
|
|
599
|
+
// ✅ New
|
|
600
|
+
.from('core_member')
|
|
601
|
+
.eq('person_id', personId) // ✅ Person-scoped
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### Issue 3: View not found
|
|
605
|
+
|
|
606
|
+
**Error:**
|
|
607
|
+
```
|
|
608
|
+
relation "organisation_memberships" does not exist
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
**Solution:**
|
|
612
|
+
Use the new unified view:
|
|
613
|
+
```typescript
|
|
614
|
+
// ❌ Old
|
|
615
|
+
.from('organisation_memberships')
|
|
616
|
+
|
|
617
|
+
// ✅ New
|
|
618
|
+
.from('core_organisation_memberships')
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### Issue 4: File reference table_name mismatch
|
|
622
|
+
|
|
623
|
+
**Error:**
|
|
624
|
+
```
|
|
625
|
+
No file references found (table_name mismatch)
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
**Solution:**
|
|
629
|
+
Update `table_name` values to use new table names:
|
|
630
|
+
```typescript
|
|
631
|
+
// ❌ Old
|
|
632
|
+
.eq('table_name', 'pace_person')
|
|
633
|
+
|
|
634
|
+
// ✅ New
|
|
635
|
+
.eq('table_name', 'core_person')
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
---
|
|
639
|
+
|
|
640
|
+
## Testing Recommendations
|
|
641
|
+
|
|
642
|
+
### 1. Search and Replace Strategy
|
|
643
|
+
|
|
644
|
+
Use your IDE's search and replace to update table names:
|
|
645
|
+
|
|
646
|
+
1. **Search for old table names:**
|
|
647
|
+
- `'organisations'` → `'core_organisations'`
|
|
648
|
+
- `'event'` → `'core_events'`
|
|
649
|
+
- `'pace_person'` → `'core_person'`
|
|
650
|
+
- `'pace_member'` → `'core_member'`
|
|
651
|
+
- etc.
|
|
652
|
+
|
|
653
|
+
2. **Update view references:**
|
|
654
|
+
- `'organisation_memberships'` → `'core_organisation_memberships'`
|
|
655
|
+
- `'user_organisation_memberships'` → `'core_organisation_memberships'`
|
|
656
|
+
|
|
657
|
+
3. **Update file reference table_name values:**
|
|
658
|
+
- `'pace_person'` → `'core_person'`
|
|
659
|
+
- `'event'` → `'core_events'`
|
|
660
|
+
- etc.
|
|
661
|
+
|
|
662
|
+
### 2. TypeScript Type Regeneration
|
|
663
|
+
|
|
664
|
+
After migrations are applied:
|
|
665
|
+
|
|
666
|
+
```bash
|
|
667
|
+
# Regenerate types from current schema
|
|
668
|
+
npx supabase gen types typescript --project-id <your-project-id> > src/types/database.generated.ts
|
|
669
|
+
|
|
670
|
+
# Fix any TypeScript errors
|
|
671
|
+
npm run type-check
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
### 3. Integration Testing
|
|
675
|
+
|
|
676
|
+
Test the following scenarios:
|
|
677
|
+
|
|
678
|
+
- [ ] Organisation queries
|
|
679
|
+
- [ ] Event queries
|
|
680
|
+
- [ ] Person/profile queries
|
|
681
|
+
- [ ] File reference queries
|
|
682
|
+
- [ ] Organisation membership queries
|
|
683
|
+
- [ ] Cross-organisation profile access
|
|
684
|
+
- [ ] RPC function calls
|
|
685
|
+
|
|
686
|
+
### 4. RLS Policy Verification
|
|
687
|
+
|
|
688
|
+
Verify RLS policies work correctly:
|
|
689
|
+
|
|
690
|
+
- [ ] Organisation access checks
|
|
691
|
+
- [ ] Event access checks
|
|
692
|
+
- [ ] Person/profile access checks
|
|
693
|
+
- [ ] File reference access checks
|
|
694
|
+
- [ ] Membership view access
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## Support and Questions
|
|
699
|
+
|
|
700
|
+
### Migration Files
|
|
701
|
+
|
|
702
|
+
All migration files are located in:
|
|
703
|
+
- `supabase/migrations/20251206111258_standardize_table_naming_app_entity.sql`
|
|
704
|
+
- `supabase/migrations/20251205211120_migrate_profiles_to_person_scoped.sql`
|
|
705
|
+
- `supabase/migrations/20251205211121_schema_changes_person_scoped_profiles.sql`
|
|
706
|
+
- Related migration files in `supabase/migrations/`
|
|
707
|
+
|
|
708
|
+
### Documentation
|
|
709
|
+
|
|
710
|
+
- [Person-Scoped Profiles Migration Guide](./person-scoped-profiles-migration-guide.md)
|
|
711
|
+
- [API & RPC Standard](../standards/02-api-and-rpc-standard.md)
|
|
712
|
+
- [Database Schema Requirements](../architecture/database-schema-requirements.md)
|
|
713
|
+
|
|
714
|
+
### Getting Help
|
|
715
|
+
|
|
716
|
+
If you encounter issues:
|
|
717
|
+
|
|
718
|
+
1. **Check Migration Status**: Verify all migrations are applied
|
|
719
|
+
2. **Verify Types**: Regenerate TypeScript types from current schema
|
|
720
|
+
3. **Review RLS**: Ensure RLS policies are correctly applied
|
|
721
|
+
4. **Check Logs**: Review Supabase logs for errors
|
|
722
|
+
5. **Search Codebase**: Use search to find all references to old table names
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
|
|
726
|
+
## Summary
|
|
727
|
+
|
|
728
|
+
**Key Takeaways:**
|
|
729
|
+
|
|
730
|
+
1. **Table Naming:**
|
|
731
|
+
- All core tables → `core_*` prefix
|
|
732
|
+
- All PACE tables → `core_*` prefix
|
|
733
|
+
- Application tables → `{app}_*` prefix
|
|
734
|
+
- Update all queries to use new table names
|
|
735
|
+
|
|
736
|
+
2. **Views:**
|
|
737
|
+
- `organisation_memberships` and `user_organisation_memberships` → `core_organisation_memberships`
|
|
738
|
+
- `public_recipe_details` → `cake_public_recipe_details`
|
|
739
|
+
|
|
740
|
+
3. **Profiles:**
|
|
741
|
+
- Person-scoped (not organisation-scoped)
|
|
742
|
+
- Remove `organisation_id` from profile queries
|
|
743
|
+
- Use `person_id` instead of `member_id` for contacts
|
|
744
|
+
|
|
745
|
+
4. **File References:**
|
|
746
|
+
- Update `table_name` values to use new table names
|
|
747
|
+
|
|
748
|
+
5. **Types:**
|
|
749
|
+
- Regenerate TypeScript types after migrations
|
|
750
|
+
|
|
751
|
+
6. **Testing:**
|
|
752
|
+
- Test all database queries
|
|
753
|
+
- Test profile access patterns
|
|
754
|
+
- Verify RLS policies work correctly
|
|
755
|
+
|
|
756
|
+
**Migration Order:**
|
|
757
|
+
1. Apply person-scoped profiles migrations (Dec 5)
|
|
758
|
+
2. Apply table naming standardization (Dec 6)
|
|
759
|
+
3. Update code to use new table names
|
|
760
|
+
4. Regenerate TypeScript types
|
|
761
|
+
5. Test thoroughly
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
**Last Updated:** 2025-12-06
|
|
766
|
+
**Version:** 0.5.190+
|
|
767
|
+
|