Skip to content

Commit

Permalink
Refactor Alembic migration scripts and update alembic_check.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-ng committed Dec 4, 2024
1 parent 0de9daa commit 5b3847b
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 329 deletions.
36 changes: 0 additions & 36 deletions alembic/versions/360c65a62392_fix_hash_data_in_document_table.py

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions alembic/versions/4d66a5dc782b_create_funder_column.py

This file was deleted.

32 changes: 0 additions & 32 deletions alembic/versions/5128cc2fe488_remove_fk_in_document_able.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Create RTransparentPublication tables
"""initial migration
Revision ID: 74f7f1590fb6
Revises: 4a908d10b459
Create Date: 2024-11-29 16:32:06.283873
Revision ID: 52101c205c9d
Revises:
Create Date: 2024-12-04 17:44:55.160050
"""
from typing import Sequence, Union
Expand All @@ -12,16 +12,49 @@


# revision identifiers, used by Alembic.
revision: str = '74f7f1590fb6'
down_revision: Union[str, None] = '4a908d10b459'
revision: str = '52101c205c9d'
down_revision: Union[str, None] = None
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('provenance',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('pipeline_name', sa.String(length=255), nullable=True),
sa.Column('version', sa.String(length=50), nullable=True),
sa.Column('compute', sa.Text(), nullable=True),
sa.Column('personnel', sa.Text(), nullable=True),
sa.Column('comment', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_provenance'))
)
op.create_table('documents',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('hash_data', sa.String(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('s3uri', sa.Text(), nullable=False),
sa.Column('provenance_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], name=op.f('fk_documents_provenance_id_provenance')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_documents')),
sa.UniqueConstraint('hash_data', name=op.f('uq_documents_hash_data'))
)
op.create_table('works',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('modified_at', sa.DateTime(), nullable=True),
sa.Column('initial_document_id', sa.Integer(), nullable=True),
sa.Column('primary_document_id', sa.Integer(), nullable=True),
sa.Column('provenance_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['initial_document_id'], ['documents.id'], name=op.f('fk_works_initial_document_id_documents')),
sa.ForeignKeyConstraint(['primary_document_id'], ['documents.id'], name=op.f('fk_works_primary_document_id_documents')),
sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], name=op.f('fk_works_provenance_id_provenance')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_works'))
)
op.create_table('rtransparent_publication',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(), nullable=True),
sa.Column('author', sa.String(), nullable=True),
sa.Column('is_open_code', sa.Boolean(), nullable=True),
sa.Column('is_open_data', sa.Boolean(), nullable=True),
sa.Column('year', sa.Integer(), nullable=True),
Expand Down Expand Up @@ -161,7 +194,6 @@ def upgrade() -> None:
sa.Column('affiliation_aff_id', sa.String(), nullable=True),
sa.Column('affiliation_all', sa.String(), nullable=True),
sa.Column('article', sa.String(), nullable=True),
sa.Column('author', sa.String(), nullable=True),
sa.Column('author_aff_id', sa.String(), nullable=True),
sa.Column('correspondence', sa.String(), nullable=True),
sa.Column('date_epub', sa.String(), nullable=True),
Expand Down Expand Up @@ -191,19 +223,22 @@ def upgrade() -> None:
sa.Column('pmcid_uid', sa.String(), nullable=True),
sa.Column('publisher_id', sa.String(), nullable=True),
sa.Column('subject', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('is_data_pred', sa.Boolean(), nullable=True),
sa.Column('is_code_pred', sa.Boolean(), nullable=True),
sa.Column('work_id', sa.Integer(), nullable=False),
sa.Column('provenance_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], ),
sa.ForeignKeyConstraint(['work_id'], ['works.id'], ),
sa.PrimaryKeyConstraint('id')
sa.Column('funder', sa.String(), nullable=True),
sa.Column('work_id', sa.Integer(), nullable=True),
sa.Column('provenance_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['provenance_id'], ['provenance.id'], name=op.f('fk_rtransparent_publication_provenance_id_provenance')),
sa.ForeignKeyConstraint(['work_id'], ['works.id'], name=op.f('fk_rtransparent_publication_work_id_works')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_rtransparent_publication'))
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('rtransparent_publication')
op.drop_table('works')
op.drop_table('documents')
op.drop_table('provenance')
# ### end Alembic commands ###
30 changes: 0 additions & 30 deletions alembic/versions/73817166f499_add_miss_columns.py

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions alembic/versions/8d6986c58f09_link_work_id_at_document_table.py

This file was deleted.

Loading

0 comments on commit 5b3847b

Please sign in to comment.