Skip to content

Commit

Permalink
names: remove internal_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Dec 19, 2024
1 parent 2ed6ce9 commit 4716137
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Removes internal_id from name_metadata."""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '8a91f4cfedd2'
down_revision = 'af2457652217'
branch_labels = ()
depends_on = None


def upgrade():
"""Upgrade database."""
op.drop_index('ix_name_metadata_internal_id', table_name='name_metadata')
op.drop_column('name_metadata', 'internal_id')

def downgrade():
"""Downgrade database."""
op.add_column('name_metadata', sa.Column('internal_id', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.create_index('ix_name_metadata_internal_id', 'name_metadata', ['internal_id'], unique=False)
24 changes: 0 additions & 24 deletions invenio_vocabularies/contrib/names/components.py

This file was deleted.

2 changes: 0 additions & 2 deletions invenio_vocabularies/contrib/names/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from werkzeug.local import LocalProxy

from ...services.components import PIDComponent
from .components import InternalIDComponent

names_schemes = LocalProxy(lambda: current_app.config["VOCABULARIES_NAMES_SCHEMES"])

Expand Down Expand Up @@ -68,7 +67,6 @@ class NamesSearchOptions(SearchOptions):

service_components = [
# Order of components are important!
InternalIDComponent,
DataComponent,
PIDComponent,
RelationsComponent,
Expand Down
2 changes: 0 additions & 2 deletions invenio_vocabularies/contrib/names/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@
# cannot set to nullable=False because it would fail at
# service level when create({}), see records-resources.
"pid": db.Column(db.String(255), unique=True),
"internal_id": db.Column(db.String(255), nullable=True, index=True),
},
schema_version="1.0.0",
schema_path="local://names/name-v1.0.0.json",
index_name="names-name-v2.0.0",
record_cls_attrs={"internal_id": ModelField("internal_id", dump=False)},
record_relations=name_relations,
record_dumper=SearchDumper(
model_fields={"pid": ("id", str)},
Expand Down
1 change: 0 additions & 1 deletion invenio_vocabularies/contrib/names/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class NameSchema(BaseVocabularySchema, ModePIDFieldVocabularyMixin):
so it does not inherit from it.
"""

internal_id = fields.Str(allow_none=True)
name = SanitizedUnicode()
given_name = SanitizedUnicode()
family_name = SanitizedUnicode()
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/names/test_names_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_simple_flow(app, service, identity, name_full_data, example_affiliation
# Fail to retrieve it
# - db
# only the metadata is removed from the record, it is still resolvable
base_keys = {"created", "updated", "id", "links", "revision_id", "internal_id"}
base_keys = {"created", "updated", "id", "links", "revision_id"}
deleted_rec = service.read(identity, id_).to_dict()
assert set(deleted_rec.keys()) == base_keys
# - search
Expand Down

0 comments on commit 4716137

Please sign in to comment.