wrolpi/alembic/versions/53f6780aa599_drop_urls.py
lrnselfreliance c23b014add
Feature/archive search (#70)
* Working through archive search.

* Using custom hook.

* Setting archive.contents duration creation.

* Archive search and domain list use custom hooks.

* Watching search param using value, not history.

* Search params are preserved on load.  Search and domain can be cleared.

* Fixing archive external link.

* Archive search form is new generic SearchInput.

* Reworking Archives empty states.

* Simplifying Archives logic.

* Fixing bug which displayed the wrong empty state during loading.

* Archives can be synced and deleted.

* Changing wording of archive delete.

* Removing URL table.

* Deleting domain if it has no archives.

* Fixing FE use of archive.url.  Fixing bug with get_domains.

* Universal results are displayed on Welcome page.

* Creating ExternalLink to open a link in a new tab.g

* Increasing size of search headers.

* Adding divider to ease reading.

* Adding More button below search results.

* Disabling More buttons when there are no results.

* Ordering videos by rank so linked results are at the top.

Signed-off-by: Roland <roland@learningselfreliance.com>
2022-01-03 15:13:38 -07:00

38 lines
1,022 B
Python

"""Drop URLs.
Revision ID: 53f6780aa599
Revises: 31896cc29b71
Create Date: 2022-01-03 12:25:51.575505
"""
import os
from alembic import op
from sqlalchemy.orm import Session
# revision identifiers, used by Alembic.
from modules.archive.models import Archive
revision = '53f6780aa599'
down_revision = '31896cc29b71'
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)
urls = {i['id']: i['url'] for i in session.execute('SELECT id, url FROM url')}
archives = {i['id']: i['url_id'] for i in session.execute('SELECT id, url_id FROM archive')}
session.execute('ALTER TABLE archive ADD COLUMN url TEXT')
for archive_id, url_id in archives.items():
archive = session.query(Archive).filter_by(id=archive_id).one()
archive.url = urls[url_id]
session.execute('ALTER TABLE archive DROP COLUMN url_id')
session.execute('DROP TABLE url')