Root Cause:
- Schema mismatch between user_tenant_roles table (identity schema) and
users/tenants tables (default/public schema)
- PostgreSQL FK constraints couldn't find referenced tables due to
schema mismatch
- Error: "violates foreign key constraint FK_user_tenant_roles_tenants_tenant_id"
Solution:
1. Moved users and tenants tables to identity schema
2. Created migration MoveTablesToIdentitySchemaAndAddIndexes
3. All Identity module tables now in consistent identity schema
4. Added performance index for users.email lookups
Changes:
- Updated TenantConfiguration.cs to use identity schema
- Updated UserConfiguration.cs to use identity schema
- Created migration to move tables to identity schema
- Removed old AddPerformanceIndexes migration (referenced wrong schema)
- Created new AddPerformanceIndexes migration
- Added test script test-tenant-registration.ps1
Test Results:
- Tenant registration now works successfully
- User, Tenant, and UserTenantRole all insert correctly
- FK constraints validate properly
- Access token and refresh token generated successfully
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>