A 添加updatedb命令代替initdb

pull/146/head
vapao 2020-07-03 15:53:08 +08:00
parent f05ab964b5
commit 861a1af622
2 changed files with 18 additions and 0 deletions

View File

@ -15,3 +15,4 @@ class Command(BaseCommand):
execute_from_command_line(args + apps) execute_from_command_line(args + apps)
execute_from_command_line(['manage.py', 'migrate']) execute_from_command_line(['manage.py', 'migrate'])
self.stdout.write(self.style.SUCCESS('初始化成功')) self.stdout.write(self.style.SUCCESS('初始化成功'))
self.stdout.write(self.style.WARNING('废弃警告v2.4.0之后将会移除该命令,请使用 python manage.py updatedb 来代替!'))

View File

@ -0,0 +1,17 @@
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
# Copyright: (c) <spug.dev@gmail.com>
# Released under the AGPL-3.0 License.
from django.core.management.base import BaseCommand
from django.core.management import execute_from_command_line
from django.conf import settings
class Command(BaseCommand):
help = '初始化/更新数据库'
def handle(self, *args, **options):
args = ['manage.py', 'makemigrations']
apps = [x.split('.')[-1] for x in settings.INSTALLED_APPS if x.startswith('apps.')]
execute_from_command_line(args + apps)
execute_from_command_line(['manage.py', 'migrate'])
self.stdout.write(self.style.SUCCESS('初始化/更新成功'))