Move cache table creation to a migration

This commit is contained in:
Christopher C. Wells 2023-07-24 12:26:28 -07:00 committed by Christopher Charbonneau Wells
parent fc383dff18
commit 4df816984d
8 changed files with 18 additions and 25 deletions

View File

@ -5,8 +5,7 @@ tasks:
pipenv install --three && pipenv install --three &&
npm install -g gulp-cli && npm install -g gulp-cli &&
npm install && npm install &&
gulp migrate && gulp migrate
gulp createcachetable
env: env:
DJANGO_SETTINGS_MODULE: babybuddy.settings.gitpod DJANGO_SETTINGS_MODULE: babybuddy.settings.gitpod
command: gulp command: gulp

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
python manage.py migrate python manage.py migrate
python manage.py createcachetable
gunicorn babybuddy.wsgi:application --timeout 30 --log-file - gunicorn babybuddy.wsgi:application --timeout 30 --log-file -

View File

@ -62,11 +62,6 @@ class Command(BaseCommand):
options["migration_name"] = None options["migration_name"] = None
migrate.handle(*args, **options) migrate.handle(*args, **options)
# Create cache table.
call_command("createcachetable", verbosity=verbosity)
if verbosity > 0:
self.stdout.write(self.style.SUCCESS("Cache table created."))
# Clear cache. # Clear cache.
cache.clear() cache.clear()
if verbosity > 0: if verbosity > 0:

View File

@ -0,0 +1,16 @@
# Generated by Django 4.2.3 on 2023-07-24 19:09
from django.db import migrations
from django.core.management import call_command
def create_cache_table(apps, schema_editor):
call_command("createcachetable", verbosity=0)
class Migration(migrations.Migration):
dependencies = [
("babybuddy", "0028_alter_settings_language_alter_settings_timezone"),
]
operations = [migrations.RunPython(create_cache_table, migrations.RunPython.noop)]

View File

@ -64,12 +64,6 @@ information and steps below to set up a local development environment for Baby B
```shell ```shell
gulp migrate gulp migrate
``` ```
1. Create cache table
```shell
gulp createcachetable
```
1. Build assets and run the server 1. Build assets and run the server

View File

@ -57,11 +57,6 @@ for more details about other options and functionality of this command.
Create a test coverage report. See [`.coveragerc`](https://github.com/babybuddy/babybuddy/tree/master/.coveragerc) Create a test coverage report. See [`.coveragerc`](https://github.com/babybuddy/babybuddy/tree/master/.coveragerc)
for default settings information. for default settings information.
### `createcachetable`
Executes Django's `createcachetable` management task. See [django-admin createcachetable](https://docs.djangoproject.com/en/4.0/ref/django-admin/#createcachetable)
for more details about other options and functionality of this command.
### `extras` ### `extras`
Copies "extra" files (fonts, images and server root contents) to the build Copies "extra" files (fonts, images and server root contents) to the build

View File

@ -66,7 +66,7 @@ application before pushing the babybuddy source code:
```shell ```shell
CC_PYTHON_BACKEND=uwsgi CC_PYTHON_BACKEND=uwsgi
CC_PYTHON_MANAGE_TASKS=migrate, createcachetable CC_PYTHON_MANAGE_TASKS=migrate
CC_PYTHON_MODULE=babybuddy.wsgi:application CC_PYTHON_MODULE=babybuddy.wsgi:application
DJANGO_SETTINGS_MODULE=babybuddy.settings.clever-cloud DJANGO_SETTINGS_MODULE=babybuddy.settings.clever-cloud
SECRET_KEY=<CHANGE TO SOMETHING RANDOM> SECRET_KEY=<CHANGE TO SOMETHING RANDOM>
@ -151,7 +151,6 @@ and any number of children).
```shell ```shell
export DJANGO_SETTINGS_MODULE=babybuddy.settings.production export DJANGO_SETTINGS_MODULE=babybuddy.settings.production
python manage.py migrate python manage.py migrate
python manage.py createcachetable
``` ```
9. Set appropriate permissions on the database and data folder 9. Set appropriate permissions on the database and data folder

View File

@ -273,10 +273,6 @@ gulp.task('compilemessages', () => {
return _runInPipenv(['python', 'manage.py', 'compilemessages']); return _runInPipenv(['python', 'manage.py', 'compilemessages']);
}); });
gulp.task('createcachetable', () => {
return _runInPipenv(['python', 'manage.py', 'createcachetable']);
});
gulp.task('fake', () => { gulp.task('fake', () => {
return _runInPipenv(['python', 'manage.py', 'fake']); return _runInPipenv(['python', 'manage.py', 'fake']);
}); });