Skip to content

[Core, Arango] Database Migration: Add Repository Type Field to Database Schema #1516

@AronPerez

Description

@AronPerez

Description

As a database administrator, I want to add a 'type' field to all existing repository documents and ensure new repositories have this field so that the system can distinguish between Globus and metadata-only repositories.

Migration Script Example

// Migration: add_repo_type_field.js
db._query(`
  FOR repo IN repo
  FILTER \!HAS(repo, 'type')
  UPDATE repo WITH { type: 'globus' } IN repo
  RETURN NEW
`);

// Validation
const reposWithoutType = db._query(`
  FOR repo IN repo
  FILTER \!HAS(repo, 'type')
  RETURN repo
`).toArray();

if (reposWithoutType.length > 0) {
  throw new Error(`Migration failed: ${reposWithoutType.length} repos still missing type field`);
}

Rollback Script

// Rollback: remove_repo_type_field.js
db._query(`
  FOR repo IN repo
  UPDATE repo WITH { type: null } IN repo
  OPTIONS { keepNull: false }
  RETURN NEW
`);

Acceptance Criteria

  • Create migration script to add 'type' field to existing repository documents
  • Set default value of 'globus' for all existing repositories
  • Ensure migration is idempotent (can be run multiple times safely)
  • Create rollback script to remove type field if needed
  • Validate that all repositories have a type field after migration
  • Update any database indexes that might be affected
  • Test migration on a copy of production data
  • Document migration procedure and rollback steps

Resources

  • Engineering Design Document: spec.md - Data Model Impact section
  • Repository collection: ArangoDB 'repo' collection
  • Migration approach from spec:
    {
      "filter": { "type": { "": false } },
      "update": { "": { "type": "globus" } }
    }

Dependencies

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions