From a3862cb98e5da4bd78e1007cd44655018677bcd8 Mon Sep 17 00:00:00 2001 From: Mark Jacobson <52427991+marksparkza@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:07:40 +0200 Subject: [PATCH] Redefine archive access points --- ..._e64766d96146_add_upload_dir_to_archive.py | 28 ---------------- ...6063cc6c_redefine_archive_access_points.py | 32 +++++++++++++++++++ odp/db/models/archive.py | 13 +++----- 3 files changed, 37 insertions(+), 36 deletions(-) delete mode 100644 migrate/versions/2024_09_28_e64766d96146_add_upload_dir_to_archive.py create mode 100644 migrate/versions/2024_09_30_5cb26063cc6c_redefine_archive_access_points.py diff --git a/migrate/versions/2024_09_28_e64766d96146_add_upload_dir_to_archive.py b/migrate/versions/2024_09_28_e64766d96146_add_upload_dir_to_archive.py deleted file mode 100644 index 6e46bec..0000000 --- a/migrate/versions/2024_09_28_e64766d96146_add_upload_dir_to_archive.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Add upload dir to archive - -Revision ID: e64766d96146 -Revises: cecb45343667 -Create Date: 2024-09-28 15:13:41.537405 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'e64766d96146' -down_revision = 'cecb45343667' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic ### - op.add_column('archive', sa.Column('dir', sa.String(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic ### - op.drop_column('archive', 'dir') - # ### end Alembic commands ### diff --git a/migrate/versions/2024_09_30_5cb26063cc6c_redefine_archive_access_points.py b/migrate/versions/2024_09_30_5cb26063cc6c_redefine_archive_access_points.py new file mode 100644 index 0000000..daffb98 --- /dev/null +++ b/migrate/versions/2024_09_30_5cb26063cc6c_redefine_archive_access_points.py @@ -0,0 +1,32 @@ +"""Redefine archive access points + +Revision ID: 5cb26063cc6c +Revises: cecb45343667 +Create Date: 2024-09-30 11:56:41.631854 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '5cb26063cc6c' +down_revision = 'cecb45343667' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic ### + op.add_column('archive', sa.Column('download_url', sa.String(), nullable=True)) + op.add_column('archive', sa.Column('upload_url', sa.String(), nullable=True)) + op.drop_column('archive', 'url') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic ### + op.add_column('archive', sa.Column('url', sa.VARCHAR(), autoincrement=False, nullable=False)) + op.drop_column('archive', 'upload_url') + op.drop_column('archive', 'download_url') + # ### end Alembic commands ### diff --git a/odp/db/models/archive.py b/odp/db/models/archive.py index 763bbe8..c514592 100644 --- a/odp/db/models/archive.py +++ b/odp/db/models/archive.py @@ -6,10 +6,7 @@ class Archive(Base): - """A data store for digital resources. - - `url` is for downloads, `dir` for uploads. - """ + """A data store for digital resources.""" __tablename__ = 'archive' @@ -25,21 +22,21 @@ class Archive(Base): ) id = Column(String, primary_key=True) - url = Column(String, nullable=False) - dir = Column(String) adapter = Column(Enum(ArchiveAdapter), nullable=False) + download_url = Column(String) + upload_url = Column(String) scope_id = Column(String, nullable=False) scope_type = Column(Enum(ScopeType), nullable=False) scope = relationship('Scope') - _repr_ = 'id', 'url', 'dir', 'adapter', 'scope_id' + _repr_ = 'id', 'adapter', 'download_url', 'upload_url', 'scope_id' class ArchiveResource(Base): """An archived instance of a resource. - `path` is relative to `url` of the archive. + `path` is relative to the archive's upload and download URLs. """ __tablename__ = 'archive_resource'