CREATE TABLE migration_roster (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
    project_id UUID NOT NULL REFERENCES migration_projects(id) ON DELETE CASCADE,
    email TEXT NOT NULL,
    display_name TEXT NOT NULL DEFAULT '',
    alternate_emails TEXT[] NOT NULL DEFAULT '{}',
    status TEXT NOT NULL DEFAULT 'pending',
    invite_id UUID REFERENCES migration_invites(id) ON DELETE SET NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE (project_id, email),
    CONSTRAINT migration_roster_status_check CHECK (status IN ('pending', 'invited', 'claimed'))
);

CREATE INDEX idx_migration_roster_project ON migration_roster(project_id);
CREATE INDEX idx_migration_roster_status ON migration_roster(status);
CREATE INDEX idx_migration_roster_invite ON migration_roster(invite_id);
