mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Run migrations! Added new migrations to new database.
This commit is contained in:
parent
07087af395
commit
73a3f1b03e
6 changed files with 89 additions and 25 deletions
15
bin/evennia
15
bin/evennia
|
|
@ -433,14 +433,9 @@ def create_game_directory(dirname):
|
|||
create_settings_file()
|
||||
|
||||
|
||||
def create_superuser():
|
||||
print "\nCreate a superuser below. The superuser is Player #1, the 'owner' account of the server.\n"
|
||||
django.core.management.call_command("createsuperuser", interactive=True)
|
||||
|
||||
|
||||
def check_database(exit_on_error=False):
|
||||
"""
|
||||
Check database exists and has a superuser
|
||||
Check database exists
|
||||
"""
|
||||
# Check so a database exists and is accessible
|
||||
from django.db import connection
|
||||
|
|
@ -454,14 +449,6 @@ def check_database(exit_on_error=False):
|
|||
print ERROR_DATABASE.format(traceback=e)
|
||||
sys.exit()
|
||||
return False
|
||||
|
||||
# Try to get Player#1
|
||||
from evennia.players.models import PlayerDB
|
||||
try:
|
||||
PlayerDB.objects.get(id=1)
|
||||
except PlayerDB.DoesNotExist:
|
||||
# no superuser yet. We need to create it.
|
||||
create_superuser()
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
20
evennia/comms/migrations/0005_auto_20150118_1631.py
Normal file
20
evennia/comms/migrations/0005_auto_20150118_1631.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
def convert_defaults(apps, schema_editor):
|
||||
ChannelDB = apps.get_model("comms", "ChannelDB")
|
||||
for channel in ChannelDB.objects.filter(db_typeclass_path="src.comms.comms.Channel"):
|
||||
channel.db_typeclass_path = "typeclasses.channels.Channel"
|
||||
channel.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('comms', '0004_defaultchannel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_defaults),
|
||||
]
|
||||
20
evennia/objects/migrations/0004_auto_20150118_1622.py
Normal file
20
evennia/objects/migrations/0004_auto_20150118_1622.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
def convert_defaults(apps, schema_editor):
|
||||
ObjectDB = apps.get_model("objects", "ObjectDB")
|
||||
for obj in ObjectDB.objects.filter(db_typeclass_path="src.objects.objects.Object"):
|
||||
obj.db_typeclass_path = "typeclasses.objects.Object"
|
||||
obj.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('objects', '0003_defaultcharacter_defaultexit_defaultobject_defaultroom'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_defaults),
|
||||
]
|
||||
20
evennia/players/migrations/0003_auto_20150118_1609.py
Normal file
20
evennia/players/migrations/0003_auto_20150118_1609.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
def convert_defaults(apps, schema_editor):
|
||||
PlayerDB = apps.get_model("players", "PlayerDB")
|
||||
for player in PlayerDB.objects.filter(db_typeclass_path="src.players.player.Player"):
|
||||
player.db_typeclass_path = "typeclasses.players.Player"
|
||||
player.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('players', '0002_auto_20150109_0913'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_defaults),
|
||||
]
|
||||
20
evennia/scripts/migrations/0003_auto_20150118_1625.py
Normal file
20
evennia/scripts/migrations/0003_auto_20150118_1625.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
def convert_defaults(apps, schema_editor):
|
||||
ScriptDB = apps.get_model("scripts", "ScriptDB")
|
||||
for script in ScriptDB.objects.filter(db_typeclass_path="src.scripts.scripts.Script"):
|
||||
script.db_typeclass_path = "typeclasses.scripts.Script"
|
||||
script.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('scripts', '0002_checksessions_donothing_script_scriptbase_store_validatechannelhandler_validateidmappercache_validat'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(convert_defaults),
|
||||
]
|
||||
|
|
@ -20,20 +20,17 @@ def create_config_values():
|
|||
ServerConfig.objects.conf("site_name", settings.SERVERNAME)
|
||||
ServerConfig.objects.conf("idle_timeout", settings.IDLE_TIMEOUT)
|
||||
|
||||
|
||||
def get_god_player():
|
||||
"""
|
||||
Creates the god user.
|
||||
Creates the god user and don't take no for an answer.
|
||||
"""
|
||||
try:
|
||||
god_player = PlayerDB.objects.get(id=1)
|
||||
except PlayerDB.DoesNotExist:
|
||||
txt = "\n\nNo superuser exists yet. The superuser is the 'owner'\n" \
|
||||
"account on the Evennia server. Create a new superuser using\n" \
|
||||
"the command\n\n" \
|
||||
" python manage.py createsuperuser\n\n" \
|
||||
"Follow the prompts, then restart the server."
|
||||
raise Exception(txt)
|
||||
god_player = None
|
||||
while not god_player:
|
||||
try:
|
||||
god_player = PlayerDB.objects.get(id=1)
|
||||
except PlayerDB.DoesNotExist:
|
||||
print "\nCreate a superuser below. The superuser is Player #1, the 'owner' account of the server.\n"
|
||||
django.core.management.call_command("createsuperuser", interactive=True)
|
||||
return god_player
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue