wrolpi/alembic/versions/4b54ad052e2e_reindex_archives.py
Roland ae9d188391
Adding FileGroup.published_date/author/etc. Creating script which converts a Singlefile to an Archive FileGroup files.
Parsing SingleFile datetime using dates.strpdate.

Adding timezone when no timezone info is available.

Installing python-dateutil to assist in handling diverse datetime strings.

Reworking refresh progress to use idempotency to display more accurate progress.  Only logging that files have been invalidated if they used to be indexed.

Clearing archives to force re-index.

Ignoring 'Unknown' author from PDF metadata. Using file_title when pdf metadata title is empty.
2023-10-23 18:09:08 -06:00

32 lines
712 B
Python

"""Reindex archives.
Revision ID: 4b54ad052e2e
Revises: 6b0b249a4f81
Create Date: 2023-10-20 13:28:55.517086
"""
import os
from alembic import op
from sqlalchemy.orm import Session
# revision identifiers, used by Alembic.
revision = '4b54ad052e2e'
down_revision = '6b0b249a4f81'
branch_labels = None
depends_on = None
DOCKERIZED = True if os.environ.get('DOCKER', '').lower().startswith('t') else False
def upgrade():
bind = op.get_bind()
session = Session(bind=bind)
# Archives must be re-indexed because of the previous revision.
session.execute("UPDATE file_group SET indexed=false WHERE model='archive'")
session.execute("DELETE FROM archive") # noqa
def downgrade():
pass