Skip to content

Commit

Permalink
Add Identifier table and model definition
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-ng committed Dec 24, 2024
1 parent 08af374 commit 197c5f7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
41 changes: 41 additions & 0 deletions alembic/versions/0b2196c1c66b_add_identifier_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Add Identifier table
Revision ID: 0b2196c1c66b
Revises: 52101c205c9d
Create Date: 2024-12-24 14:22:25.117856
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '0b2196c1c66b'
down_revision: Union[str, None] = '52101c205c9d'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('identifier',
sa.Column('core_id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('pmid', sa.Integer(), nullable=True),
sa.Column('pmcid', sa.String(), nullable=True),
sa.Column('doi', sa.String(), nullable=True),
sa.Column('document_id', sa.Integer(), nullable=False),
sa.Column('provenance_id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['document_id'], ['documents.id'], name=op.f('fk_identifier_document_id_documents')),
sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], name=op.f('fk_identifier_provenance_id_provenance')),
sa.PrimaryKeyConstraint('core_id', name=op.f('pk_identifier'))
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('identifier')
# ### end Alembic commands ###
12 changes: 12 additions & 0 deletions dsst_etl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,15 @@ class RTransparentPublication(Base):

work_id = Column(Integer, ForeignKey("works.id"), nullable=True)
provenance_id = Column(Integer, ForeignKey("provenance.id"), nullable=True)


class Identifier(Base):
__tablename__ = "identifier"

core_id = Column(Integer, primary_key=True, autoincrement=True)
pmid = Column(Integer, nullable=True)
pmcid = Column(String, nullable=True)
doi = Column(String, nullable=True)
document_id = Column(ForeignKey("documents.id"), nullable=False)
provenance_id = Column(ForeignKey("provenance.id"), nullable=False)
created_at = Column(DateTime, default=func.now())

0 comments on commit 197c5f7

Please sign in to comment.