Removes initialization from migration

Just doesn't seem right
This commit is contained in:
Mouse Reeve 2022-01-10 13:05:08 -08:00
parent 8928e8da26
commit dcf51020bc
4 changed files with 28 additions and 17 deletions

View file

@ -154,9 +154,30 @@ def init_link_domains(*_):
class Command(BaseCommand):
help = "Initializes the database with starter data"
def add_arguments(self, parser):
parser.add_argument(
"--limit",
default=None,
help="Limit init to specific table",
)
def handle(self, *args, **options):
init_groups()
init_permissions()
init_connectors()
init_federated_servers()
init_settings()
limit = options.get("limit")
tables = [
"group", "permission", "connector", "federatedserver", "settings", "linkdomain"
]
if limit not in tables:
raise Exception("Invalid table limit:", limit)
if not limit or limit == "group":
init_groups()
if not limit or limit == "permission":
init_permissions()
if not limit or limit == "connector":
init_connectors()
if not limit or limit == "federatedserver":
init_federated_servers()
if not limit or limit == "settings":
init_settings()
if not limit or limit == "linkdomain":
init_link_domains()

View file

@ -22,13 +22,6 @@ class Command(BaseCommand):
help = "Populate list streams for all users"
def add_arguments(self, parser):
parser.add_argument(
"--stream",
default=None,
help="Specifies which time of stream to populate",
)
# pylint: disable=no-self-use,unused-argument
def handle(self, *args, **options):
"""run feed builder"""

View file

@ -5,8 +5,6 @@ import bookwyrm.models.fields
from django.db import migrations, models
import django.db.models.deletion
from bookwyrm.management.commands.initdb import init_link_domains
class Migration(migrations.Migration):
@ -125,5 +123,4 @@ class Migration(migrations.Migration):
},
bases=("bookwyrm.link",),
),
migrations.RunPython(init_link_domains, reverse_code=migrations.RunPython.noop),
]

4
bw-dev
View file

@ -31,7 +31,7 @@ function execweb {
function initdb {
execweb python manage.py migrate
execweb python manage.py initdb
execweb python manage.py initdb "$@"
}
function makeitblack {
@ -65,7 +65,7 @@ case "$CMD" in
docker-compose run --rm --service-ports web
;;
initdb)
initdb
initdb "$@"
;;
resetdb)
clean