Deploying Django App stack that's been developed using South? - django

So, I've my application stack and I'm ready to deploy it to my webserver.
I'm deploying to a fresh, clean and blank database, so what command to I run? Do I run ./manage.py syncdb or do I use a South command to setup the database?

./manage.py syncdb
./manage.py migrate

Related

What is the easiest way to reset migrations in Heroku CLI?

I recently deployed Django REST API project on Heroku and I wanted to remove migrations and migrate again.
I have tried:
heroku run python manage.py migrate --app cyberminds-backend zero
but it returns:
CommandError: No installed app with label 'zero'
What are the easiest steps or commands to achieve this?

Django on Heroku - ProgrammingError at / relation "..." does not exist

I'm getting this error. I know you usually get this error because the databases wasn't properly migrated.
When I run heroku local web, the website works fine when I go to localhost:5000.
However after I deploy the app to heroku with git push heroku master, the error comes up.
In other words, it works in my local environment. But it does not work after deploying to heroku.
I have Heroku-Postgres installed as an add-on in heroku.
What could be causing this?
excute migrations and makemigrations in bash heroku. open the terminal in the local project folder and give the following commands:
heroku run bash
~$ ./manage.py makemigrations
~$ ./manage.py migrate
~$ exit
The following steps did it for me
Make all the necessary migrations (python manage.py makemigrations) and migrate (python manage.py migrate) locally,
push to heroku master
and finally running heroku run python manage.py migrate
Solved the issue
I experienced the same error after making a change to a model and then deploying this change to heroku.
The only way I managed to fix this problem was to do the following:
Reset the database in heroku
Delete the migrations files from the migrations folder for the broken app locally (but keep the directory and the __init__.py file)
Run python manage.py makemigrations and python manage.py migrate. This will repopulate the migrations folder with clean migration files.
Push changes to master (ensure that you do not have migrations directories in .gitignore files.
Deploy changes to heroku
Run the heroku shell heroku run bash
Run python manage.py migrate
I was able to do this because my tables did not have much data in, but I would try to avoid resetting the database if I had more data in my tables.

Deploying Django app to Heroku via CircleCI: How to migrate database?

How can I run python manage.py makemigrations and python manage.py migrate automatically when deploying a Django app to Heroku via CircleCI. It seems all commands run local to CircleCI, but not on the deployed application in production.
Is there a way?
python manage.py makemigrations should be running locally, and you may commit the migration files along with the code.
Regaridng the migrations, open your Procfile and add this line: release: python manage.py migrate.
This will tell Heroku to migrate before deploying a new version of your code.

Running Django syncdb and migrations with Chef

We are moving towards deploying our Django apps with Chef. One question I have is what is the best way to handle the following commands:
./manage.py syncdb
./manage.py migrate --noinput
./manage.py collectstatic --noinput
I'm using the application cookbook. We normally handled these with a Fabric script, and I'd like to continue using Fabric if possible. Is there a best practice on how to handle this? Use a callback such as before_restart to execute the Fabric commands to syncdb, migrate, and collectstatic?
This cookbook contains an attribute called migration_command

problems updating DB to heroku with south migrations

I have a Django proyect running in heroku for some time now, the thing is that, tree days ago, I've tryed to update my schema model but, every time I write
heroku run python manage.py migrate quizzer
heroku keeps telling me that everything's up to date, but I've changed my models.py folder and run schema migration as always.
If you know why this is happening or how can I force a schema migration to my heroku app please tell me how.
Ps: I cannot delete the hole database as the data stored in heroku and the data stored in my local server database are not the same, and I don't want to loose the data of my users
Here is a workflow for running a schemamigration on quizzer after modifying your models.py
./manage.py schemamigration quizzer --auto # create migration
./manage.py migrate quizzer # apply migration locally
git add .
git commit -m "Changed quizzer models, added schemamigration"
git push heroku
heroku run python manage.py migrate quizzer # apply migration on heroku
It sounds like you might have forgotten to check your migration file (usually found in appname/migrations) into git, commit it and push it to heroku.
I had this problem too. I solved this by running heroku restart and running the migrate command again. Don't know why it works (suspect it has to do with initial), but at least it works.
Hope that helps!
South might be missing from requirements.txt. Try:
pip freeze > requirements.txt
...followed by another git add/commit/push.
Also, according to the South installation instructions, syncdb must be run first, "to make the South migration-tracking tables". So try:
heroku run python manage.py syncdb
...then try the migrate command again.