forked from mirrors/bookwyrm
Remove/re-add connector in migration
This commit is contained in:
parent
e6e44decf9
commit
38f82fe660
1 changed files with 29 additions and 0 deletions
|
@ -1,6 +1,34 @@
|
||||||
# Generated by Django 3.2.5 on 2021-09-30 17:46
|
# Generated by Django 3.2.5 on 2021-09-30 17:46
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
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(
|
||||||
|
local=True
|
||||||
|
).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,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
@ -10,6 +38,7 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.RunPython(remove_self_connector, reverse),
|
||||||
migrations.RemoveField(
|
migrations.RemoveField(
|
||||||
model_name="connector",
|
model_name="connector",
|
||||||
name="local",
|
name="local",
|
||||||
|
|
Loading…
Reference in a new issue