Issue
Domain registration for naturalelementsearlylearning.com.au failed with error:
Status Code: 500 Internal Server Error
Error: "Failed to submit domain registration request"
Details: "column \"domain_type\" of relation \"domain_registration_requests\" does not exist"
Root Cause
The backend code (routes/domainRequests.js) was attempting to INSERT a domain_type column that didn't exist in the production database table.
Code expectation:
domain_type = 'registration', // Default value in destructuring
SQL INSERT statement:
INSERT INTO domain_registration_requests (
tenant_id, customer_id, contract_id, domain_name, domain_type, years, ...
Actual database schema: Missing domain_type column
Why This Happened
- The original schema file (2026_02_11_domain_registration_requests.sql) didn't include domain_type
- Code was enhanced to support different domain request types (registration, transfer, renewal, dns-only)
- Database schema was not updated when code was enhanced
- Development environment may have had the column manually added
- Production database was missing the column
Resolution
Immediate Fix (Production)
Added the missing column directly to production database:
ALTER TABLE domain_registration_requests
ADD COLUMN domain_type VARCHAR(50) DEFAULT 'registration';
Applied: March 9, 2026 at approximately 14:30 UTC
Schema Updates
- Updated base schema: rmm-psa-database/2026_02_11_domain_registration_requests.sql
- Added domain_type column with:
- Type: VARCHAR(50)
- Default: 'registration'
- Constraint: CHECK (domain_type IN ('registration', 'transfer', 'renewal', 'dns-only'))
- Created migration: rmm-psa-database/migrations/2026_03_09_add_domain_type_column.sql
- Safe migration with existence check
- Can be run on any database (idempotent)
- Adds column only if it doesn't exist
Domain Type Values
The domain_type column supports:
- registration (default) - Register a new domain for the first time
- transfer - Transfer an existing domain from another registrar
- renewal - Renew/extend an existing domain registration
- dns-only - DNS management without domain registration
Testing
After the fix, domain registration should work correctly. To test:
- Visit the customer portal
- Navigate to domain registration
- Search for an available domain
- Fill in contact information
- Submit the registration request
The request should now:
- ✅ Create a record in domain_registration_requests table
- ✅ Set domain_type to 'registration' by default
- ✅ Set status to 'pending'
- ✅ Notify root tenant admins
- ✅ Return success response to customer
Verification Query
To verify the fix in production:
SELECT column_name, data_type, column_default
FROM information_schema.columns
WHERE table_name = 'domain_registration_requests'
AND column_name = 'domain_type';
SELECT request_id, domain_name, domain_type, status, created_at, requested_by
FROM domain_registration_requests
WHERE domain_name = 'naturalelementsearlylearning.com.au'
ORDER BY created_at DESC;
Related Files
Commits
- Schema fix: Updated base schema and created migration
- Backend enhancement: Enhanced logging for domain registration debugging
Next Steps
- ✅ Column added to production database
- ✅ Schema files updated
- ✅ Migration created for future deployments
- ⏳ User should retry domain registration
- ⏳ Verify request appears in database
- ⏳ Confirm admin notification received
Prevention
To prevent similar issues:
- Schema-first approach: Update schema files before or with code changes
- Migration discipline: Create migrations for all schema changes
- Development parity: Ensure dev/staging databases match production schema
- Integration tests: Add tests that exercise full request flow
- Schema validation: Consider adding automated schema validation in CI/CD
Contact
If issues persist after this fix, check:
- Backend logs: /api/domain-requests endpoint
- Database: domain_registration_requests table
- Error response from API call