moviewyrm/bookwyrm/migrations/0102_remove_connector_local.py

42 lines
1.2 KiB
Python
Raw Normal View History

2021-09-30 17:47:53 +00:00
# Generated by Django 3.2.5 on 2021-09-30 17:46
2021-09-14 22:26:18 +00:00
from django.db import migrations
2021-09-30 17:54:31 +00:00
from bookwyrm.settings import DOMAIN
def remove_self_connector(app_registry, schema_editor):
"""set the new phsyical format field based on existing format data"""
db_alias = schema_editor.connection.alias
app_registry.get_model("bookwyrm", "Connector").objects.using(db_alias).filter(
2021-09-30 18:06:12 +00:00
connector_file="self_connector"
2021-09-30 17:54:31 +00:00
).delete()
def reverse(app_registry, schema_editor):
"""doesn't need to do anything"""
db_alias = schema_editor.connection.alias
model = app_registry.get_model("bookwyrm", "Connector")
model.objects.using(db_alias).create(
identifier=DOMAIN,
name="Local",
local=True,
connector_file="self_connector",
base_url=f"https://{DOMAIN}",
books_url=f"https://{DOMAIN}/book",
covers_url=f"https://{DOMAIN}/images/",
search_url=f"https://{DOMAIN}/search?q=",
isbn_search_url=f"https://{DOMAIN}/isbn/",
priority=1,
)
2021-09-14 22:26:18 +00:00
class Migration(migrations.Migration):
dependencies = [
2021-09-30 17:47:53 +00:00
("bookwyrm", "0101_auto_20210929_1847"),
2021-09-14 22:26:18 +00:00
]
operations = [
2021-09-30 17:54:31 +00:00
migrations.RunPython(remove_self_connector, reverse),
2021-09-14 22:26:18 +00:00
]