Questions tagged [django-migrations]

Django migrations are a way to apply changes to a database previously created, introduced in Django 1.7. This tool is used when a model is modified (adding a field, deleting a model, etc.) and you need to apply these changes to your database.

Migrations are introduced in Django 1.7 to make easier modifications in models:

Migrations are Django’s way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They’re designed to be mostly automatic, but you’ll need to know when to make migrations, when to run them, and the common problems you might run into.

There are several commands which you will use to interact with migrations and Django’s handling of database schema:

  • migrate, which is responsible for (un)applying migrations
  • makemigrations, to create new migrations files based on model modifications
  • sqlmigrate, which displays the SQL statements for a migration.
  • showmigrations, which lists a project’s migrations and their status.

This tag is not about migrating to Django from another framework. This is supposed to replace , which is a third-party mainly used until Django 1.6 to migrate models modifications.

1460 questions
0
votes
1 answer

Django: CommandError: App 'zero' does not have migrations

I trying to revert the migrations of my Django application. I have five migrations which are synced with the database. I use the following command: $ python manage.py migrate zero This fails with the following error message: CommandError: App…
JJD
  • 50,076
  • 60
  • 203
  • 339
0
votes
1 answer

Django: authentication for migrations across multiple machines?

I have been working on a Django app locally and it's now time to deploy it to a staging machine. My Postgres database on the staging machine has a different username and password to my local machine. I have got the Django app running okay on the…
Richard
  • 62,943
  • 126
  • 334
  • 542
0
votes
1 answer

Django migrate error name 'bPath' is not defined

I'm running on Django 1.7.4. # base.py PRIVATE_FOLDER_ROOT = str(PROJECT_DIR.child('web_private')) # tested: PRIVATE_FOLDER_ROOT = PROJECT_DIR.child('web_private') # tested: PRIVATE_FOLDER_ROOT = '/var/www/project/project/web_private' #…
Daviddd
  • 761
  • 2
  • 12
  • 37
0
votes
1 answer

How to make Django migrations know about changes inside a custom field?

I've made custom field, which is basically "upgraded" ForeignKey field. However, I forgot to set on_delete=models.PROTECT as default (desired default behaviour of that field). class MyReferenceField( models.ForeignKey ): def __init__(self,…
kravemir
  • 10,636
  • 17
  • 64
  • 111
0
votes
0 answers

Django use two databases for seamless updates

I have a database (PostgreSQL), which I need to update from time to time (every 6 hours). I don't want partial updates to appear on the output, so my idea is: We use two databases, let them be named prod and update. prod is all the time on duty,…
vladfau
  • 1,003
  • 11
  • 22
0
votes
1 answer

How get new django code run with old database?

I'm sorry if the name of the question is misleading but here is the deal. I have dump of the database that was used with old version of django app (django < 1.7). I have a new version of code which is using django 1.7. And now I need to upgrade some…
user1685095
  • 5,787
  • 9
  • 51
  • 100
0
votes
0 answers

Django 1.7 table already exists, followed by lookup/value error - Model doesn't exist

I'm trying to make migrations on my app, and I'be followed the advice supplied here: django 1.7 migrate gets error "table already exists" Specifically: Or if you want to avoid some actions in your migration, you can edit the migration file under…
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
0
votes
0 answers

Migration runs correct, but doesn't create new column (Django 1.7)

I want to run some migrations. Everything seems to run correctly until I want to run my website. There is a column missing. I can fix it manually, but I want to understand the mistake I make when running the migration. This is a part of my migraton…
RVE
  • 328
  • 4
  • 17
0
votes
2 answers

Django 1.7 + Django CMS - drop migration files from my repo or include virtualenv in repo?

I'm using git to version control a Django 1.7 + Django CMS 3.0.6 project. In the course of building various apps etc I'm ending up with a lot of migration files. The migration files are currently included in my git repo. Thus far I have been trying…
David Simic
  • 2,061
  • 2
  • 19
  • 33
0
votes
2 answers

How to migrate an existing django model to django-ordered-model with Django 1.7 migrations?

I have an existing model and I want to make it orderable with django-ordered-model, which I chose because it is integrated with django.contrib.admin. Right now the model is ordered by pk, and I'd like to preserve that ordering. When I run manage.py…
Aur Saraf
  • 3,214
  • 1
  • 26
  • 15
0
votes
2 answers

Best way to add Django migrations to a django project

I have a Django application initially created for version 1.6 and I've just finished the upgrade for the last version. All the models has managed = False and prior none of them was managed by south and now I want to start using Django migrations for…
alfonso.kim
  • 2,844
  • 4
  • 32
  • 37
0
votes
1 answer

Django 1.7 remove field. Unknown field(s) (field) specified for Model

I have already many models in my application. I have already used migrations in my project. But when I want to remove a field from a model, the makemigration command show me : Unknown field(s) (field) specified for Model Where (fields) is equal to…
Samuel Dauzon
  • 10,744
  • 13
  • 61
  • 94
0
votes
1 answer

Django 1.7 migration error

I changed a field from CharField to ForeignKey on a Model called Availability, when I am trying to migrate I keep getting the error below: ValueError: Lookup failed for model referenced by field reservation.Availability.location:…
Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66
0
votes
1 answer

Migration issue with custom model field

Ï'm upgrading my site to Django 1.7.1 - especially to get the neat migration feature. However, I am running into some issues regarding migrations and a custom model field. The most annoying thing about this is, that the traceback doesn't give me…
0
votes
1 answer

Error during migrate

I have a problem with migration my model to database. models.py: # coding: utf-8 from django.db import models # Create your models here. class Product(models.Model): title = models.CharField('title', max_length=100, blank=False) author =…
MarMar
  • 35
  • 1
  • 9