Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

This page is a work in progress. It will be updated as new advice becomes available.

At the IDRC, we develop with OER Commons running in a vagrant virtual machine.

When we update the OER Commons codebase, it is often necessary to rebuild the database and run various scripts to bring the environment up-to-date with the latest code. This page attempts to summarize the steps necessary for this, describing various shell commands that need to be run.

Setting up the code to work in your environment

Make sure 'development.py' has the following things properly pointing at your personal instance:

SESSION_COOKIE_DOMAIN = "<your machine>" # May be your IP, or 'localhost'
DEFAULT_SITE_DOMAIN = "<your machine>:8000"

MICROSITES = {"arabic": {"domain": "arabic.<your machine>:8000"}}

Make sure 'settings.py' has the following things paths set properly (our local environment is different than what's specified in github):

SCSS_EXECUTABLE = "/opt/ruby/bin/sass"
COFFESCRIPT_EXECUTABLE = "/usr/bin/coffee"
SCSS_USE_COMPASS = True

To completely rebuild

Log in to the vagrant VM:

vagrant ssh

Become superuser, drop the database and recreate it:

sudo -i
su - postgres
dropdb oercommons_db
createdb -O oercommons_user -E UTF-8 --locale=en_US.UTF-8 -T template0 oercommons_db
exit
exit

Activate the virtual environment:

cd /vagrant/oercommons
source ./virtualenv/bin/activate

Remove django and run the buildout config:

rm -rf src/django
./bin/buildout -c buildout-dev.cfg

Creates any database tables that have not already been created. (you'll be asked to create a django admin account):

./bin/django syncdb

Note: If this fails, run it a second time.

Run the migration scripts:

./bin/django migrate

Note: Sometimes this fails. If so, check the output to see which table seems to be missing (try ./bin/django migrate --list). Run the migration specific to that table, then try re-running the entire thing again:

./bin/django migrate <whatever's missing>
./bin/django migrate

You may have to repeat this process a few times.

Load static files:

./bin/django build_static -l 

Create users in the database:

./bin/django shell
from django.contrib.auth.models import User
from users.models import Profile
Profile.objects.create(user=User.objects.get(pk=1))

Use Ctrl+D to exit the shell.

Set up the initial data:

./bin/django loaddata apps/materials/fixtures/initial_data.json
./bin/django loaddata apps/materials/fixtures/microsites.json

Remove the compiled python files:

find . -name '*.pyc' -delete

Restart Jetty:

sudo invoke-rc.d jetty stop
sudo invoke-rc.d jetty start

Exit the vagrant VM and restart it.

  • No labels