registry/internal/database/migrations
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Tadas Antanavicius 272ee9322d
fix: add server name validation and clean invalid data before migration 009 (#591)
## Summary

This PR adds two important improvements to ensure data integrity:

1. **Adds server name format validation at the API layer** to match the
database constraint from migration 008
2. **Includes migration 008 to clean up invalid data** before applying
strict constraints in migration 009

## Changes

### Server Name Validation
- Enforces validation at the API layer matching the database constraint
- **Namespace pattern**: `[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9]` 
  - Must start and end with alphanumeric characters
  - Can contain dots and hyphens in the middle
- **Name pattern**: `[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]`
  - Must start and end with alphanumeric characters  
  - Can contain dots, underscores, and hyphens in the middle
- Provides clear, user-friendly error messages indicating which part is
invalid
- Uses DRY approach with composed regex patterns

### Migration 008: Data Cleanup
- Removes servers with invalid names or empty versions (5 servers
affected in production)
- Fixes invalid status values by setting them to 'active' (1 server
affected)
- Removes duplicate name+version combinations
- Includes comprehensive safety checks to prevent accidental data loss
- Must run before migration 009 which adds strict constraints

## Testing
- All validator tests pass
- Migration includes safety checks that match production data
- CI verification included

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-30 20:07:42 +03:00
..
001_initial_schema.sql Refactor database implementation to use PostgreSQL instead of MongoDB (#289) 2025-08-22 01:40:28 +01:00
002_add_server_extensions.sql Allow for vendor extensions on servers (#298) 2025-08-23 09:59:03 +01:00
003_simplify_to_key_value.sql Implement flattened _meta format for server extensions (#331) 2025-09-01 19:27:23 +01:00
004_update_meta_field_format.sql Fix _meta field format for MCP spec compliance (#367) 2025-09-08 11:40:04 -07:00
005_add_server_id_rename_version_id.sql Introduce serverId, rename id to versionId (#465) 2025-09-21 15:00:09 +03:00
006_migrate_server_json_camelcase.sql add migraiton file to convert snake case to camel case (#522) 2025-09-21 15:26:15 +03:00
007_add_publish_constraints.sql Fix race conditions in concurrent server publishing (#528) 2025-09-22 12:16:05 +01:00
008_clean_invalid_data.sql fix: add server name validation and clean invalid data before migration 009 (#591) 2025-09-30 20:07:42 +03:00
009_separate_official_metadata.sql fix: add server name validation and clean invalid data before migration 009 (#591) 2025-09-30 20:07:42 +03:00