mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +00:00
Merge pull request #2025 from bookwyrm-social/upgrade-scripts
Run miscellaneous scripts during update
This commit is contained in:
commit
8969958e51
6 changed files with 76 additions and 1 deletions
54
bookwyrm/management/commands/instance_version.py
Normal file
54
bookwyrm/management/commands/instance_version.py
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
""" Get your admin code to allow install """
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
from bookwyrm import models
|
||||||
|
from bookwyrm.settings import VERSION
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
|
class Command(BaseCommand):
|
||||||
|
"""command-line options"""
|
||||||
|
|
||||||
|
help = "What version is this?"
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
"""specify which function to run"""
|
||||||
|
parser.add_argument(
|
||||||
|
"--current",
|
||||||
|
action="store_true",
|
||||||
|
help="Version stored in database",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--target",
|
||||||
|
action="store_true",
|
||||||
|
help="Version stored in settings",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--update",
|
||||||
|
action="store_true",
|
||||||
|
help="Update database version",
|
||||||
|
)
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
"""execute init"""
|
||||||
|
site = models.SiteSettings.objects.get()
|
||||||
|
current = site.version or "0.0.1"
|
||||||
|
target = VERSION
|
||||||
|
if options.get("current"):
|
||||||
|
print(current)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.get("target"):
|
||||||
|
print(target)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.get("update"):
|
||||||
|
site.version = target
|
||||||
|
site.save()
|
||||||
|
return
|
||||||
|
|
||||||
|
if current != target:
|
||||||
|
print(f"{current}/{target}")
|
||||||
|
else:
|
||||||
|
print(current)
|
18
bookwyrm/migrations/0145_sitesettings_version.py
Normal file
18
bookwyrm/migrations/0145_sitesettings_version.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.12 on 2022-03-16 18:10
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bookwyrm", "0144_alter_announcement_display_type"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="sitesettings",
|
||||||
|
name="version",
|
||||||
|
field=models.CharField(blank=True, max_length=10, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -27,6 +27,7 @@ class SiteSettings(models.Model):
|
||||||
default_theme = models.ForeignKey(
|
default_theme = models.ForeignKey(
|
||||||
"Theme", null=True, blank=True, on_delete=models.SET_NULL
|
"Theme", null=True, blank=True, on_delete=models.SET_NULL
|
||||||
)
|
)
|
||||||
|
version = models.CharField(null=True, blank=True, max_length=10)
|
||||||
|
|
||||||
# admin setup options
|
# admin setup options
|
||||||
install_mode = models.BooleanField(default=False)
|
install_mode = models.BooleanField(default=False)
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
||||||
env = Env()
|
env = Env()
|
||||||
env.read_env()
|
env.read_env()
|
||||||
DOMAIN = env("DOMAIN")
|
DOMAIN = env("DOMAIN")
|
||||||
VERSION = "0.3.3"
|
VERSION = "0.3.4"
|
||||||
|
|
||||||
RELEASE_API = env(
|
RELEASE_API = env(
|
||||||
"RELEASE_API",
|
"RELEASE_API",
|
||||||
|
|
1
bw-dev
1
bw-dev
|
@ -163,6 +163,7 @@ case "$CMD" in
|
||||||
update)
|
update)
|
||||||
git pull
|
git pull
|
||||||
docker-compose build
|
docker-compose build
|
||||||
|
./update.sh
|
||||||
runweb python manage.py migrate
|
runweb python manage.py migrate
|
||||||
runweb python manage.py collectstatic --no-input
|
runweb python manage.py collectstatic --no-input
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
1
updates/0.3.4.sh
Executable file
1
updates/0.3.4.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
./bw-dev migrate django_celery_beat
|
Loading…
Reference in a new issue