summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorprathamesh2017-03-13 13:14:33 +0530
committerprathamesh2017-03-13 13:14:33 +0530
commit4ce30381757815f851fce701ee61d86001a6624b (patch)
tree40e1db50821d54803171346625a5f1cafcf72ae2 /yaksh
parent1a50fb3407550869cf988b307f24af62ad3e57e7 (diff)
downloadonline_test-4ce30381757815f851fce701ee61d86001a6624b.tar.gz
online_test-4ce30381757815f851fce701ee61d86001a6624b.tar.bz2
online_test-4ce30381757815f851fce701ee61d86001a6624b.zip
Added migration commands to the script.
Removed migrate with run-syncdb argument because this does not create migration files, so further migrations become difficult. Model changes are detected by make_migrations and the migrate command applies those migrations. This is done every time when user runs a demo. There is no harm in doing so.
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/scripts/cli.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/yaksh/scripts/cli.py b/yaksh/scripts/cli.py
index 4a58e48..a1a49ee 100644
--- a/yaksh/scripts/cli.py
+++ b/yaksh/scripts/cli.py
@@ -101,10 +101,6 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR):
'fixture_dir': fixture_dir})
urls_template_path = path.join(TEMPLATE_DIR, 'demo_urls.py')
urls_target_path = path.join(project_path, 'demo_urls.py')
- command = ("python ../manage.py migrate --run-syncdb "
- "--noinput --settings={0}.demo_settings").format(
- project_name)
-
loaddata_command = ("python ../manage.py loaddata "
"--settings={0}.demo_settings {1}").format(
project_name, fixture_path)
@@ -115,14 +111,18 @@ def create_demo(project_name='yaksh_demo', project_dir=CUR_DIR):
)
# Create demo_urls file
_render_demo_files(urls_template_path, urls_target_path)
- # Run syncdb
- subprocess.call(
- "{0}; {1}".format(command, loaddata_command), shell=True
- )
+ # Create database and load initial data
+ command_path = path.join(top_dir, 'manage.py')
+ _check_migrations(project_name, command_path)
+ _migrate(project_name, command_path)
+ subprocess.call(loaddata_command, shell=True)
def run_demo(project_name, top_dir):
with _chdir(top_dir):
+ command_path = path.join(top_dir, 'manage.py')
+ _check_migrations(project_name, command_path)
+ _migrate(project_name, command_path)
command = ("python manage.py runserver "
"--settings={0}.demo_settings").format(project_name)
subprocess.call(command, shell=True)
@@ -136,6 +136,18 @@ def run_server(args=None):
print("Error: {0}\nExiting yaksh code server".format(e))
+def _check_migrations(project_name, command_path):
+ migrations = ("python {0} makemigrations --settings={1}.demo_settings"
+ ).format(command_path, project_name)
+ subprocess.call(migrations, shell=True)
+
+
+def _migrate(project_name, command_path):
+ migrate = ("python {0} migrate --settings={1}.demo_settings"
+ ).format(command_path, project_name)
+ subprocess.call(migrate, shell=True)
+
+
def _render_demo_files(template_path, output_path, context=None):
with open(template_path, 'r') as template_file:
content = template_file.read()