Skip to content

oarepo_oaipmh_harvester.alembic.1791708839_oai_harvest_records_utc_datetimes

oarepo_oaipmh_harvester.alembic.1791708839_oai_harvest_records_utc_datetimes

Store oai harvest record datestamp and harvested_at as timezone aware (UTC) timestamps.

upgrade() -> None

Upgrade database.

Source code in oarepo_oaipmh_harvester/alembic/1791708839_oai_harvest_records_utc_datetimes.py
def upgrade() -> None:
    """Upgrade database."""
    for column in COLUMNS:
        # existing naive values are UTC
        op.alter_column(
            "oai_harvest_records",
            column,
            type_=sa.DateTime(timezone=True),
            existing_type=sa.DateTime(),
            existing_nullable=False,
            postgresql_using=f"{column} AT TIME ZONE 'UTC'",
        )

downgrade() -> None

Downgrade database.

Source code in oarepo_oaipmh_harvester/alembic/1791708839_oai_harvest_records_utc_datetimes.py
def downgrade() -> None:
    """Downgrade database."""
    for column in COLUMNS:
        op.alter_column(
            "oai_harvest_records",
            column,
            type_=sa.DateTime(),
            existing_type=sa.DateTime(timezone=True),
            existing_nullable=False,
            postgresql_using=f"{column} AT TIME ZONE 'UTC'",
        )