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
0 answers

Django migrations don't recognize removal of NOT NULL

So I've recently made the jump from South to native Django migrations. All went smoothly with migrating my migrations, however some recent changes have not worked. I had a model thus: class MyModel(models.Model): f1 = models.IntegerField() Which…
fredley
  • 32,953
  • 42
  • 145
  • 236
0
votes
1 answer

Django's makemigrations with RegexValidator throws TypeError

I'm updating my app for Django 1.7 and tried to python manage.py makemigrations with the result of the following error: TypeError: unbound method deconstruct() must be called with RegexValidator instance as first argument (got nothing…
yofee
  • 1,287
  • 12
  • 25
0
votes
1 answer

Why do migrations fail on test, but not on migrate?

I'm using Django==1.7, and have four applications: frontend game geo people The apps settings is like this: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', …
Luis Masuelli
  • 12,079
  • 10
  • 49
  • 87
0
votes
1 answer

django south internal db functions in django 1.7

I have a project that was using the following internal db commands from South and was wondering if anyone knows how to do the same in django 1.7's new migrations. from south import db ... db.delete_column(table,name) ... db.add_column(table, name,…
tr33hous
  • 1,622
  • 1
  • 15
  • 26
0
votes
2 answers

Duplicate model field in Django

A duplicate model field is giving me trouble (no such table appname_modelname when I run my webpage). Whenever I do ./manage.py migrate appname, it gives me "duplicate field". I checked my models.py, there is only one of them there. How do I delete…
KSHMR
  • 741
  • 1
  • 9
  • 24
0
votes
0 answers

django-taggit error in Django-1.7 : 'tags' has an m2m relation with model

I've written a BlogEntry model that I've made in Django-1.7 When I run, /manage.py makemigration, I get the following error. CommandError: One or more models did not validate: blog.blogentry: 'tags' has an m2m relation with model
Anish Shah
  • 7,669
  • 8
  • 29
  • 40
-1
votes
1 answer

Encountering psycopg.OperationalError: connection is bad: Temporary failure in name resolution, when attempting to run migrations using GitHub Actions

Currently attempting to implement backend CI for a project using Django for the server and PostgreSQL for the database. I'm automating this using GitHub Actions to occur whenever a pull request is done, but when it tries to attempt migrations, it…
-1
votes
1 answer

I have problem with git and django migrate

I use git in django for my project and my database is postgres. When I make a change in the file and make migrations and then migrate, it is correct and the database is correct. But when I go back to the previous commit (git checkout command) and…
-1
votes
1 answer

Extending a base model in django

I want to create base model for my questions named Question and extend it by any other question types: class Question(models.Model): questionnaire = models.ForeignKey(to='Questionnaire', on_delete=models.CASCADE, related_name='questions') …
-1
votes
1 answer

Why I get this error when I trie to do the migrations on Django 3.2.6?

I was trying to update mi DB using the comand python manage.py makemigrations after of delete all the files of migrations in my Django project, because when I try to do the changes on my db doesnt apply This is my model class…
-1
votes
1 answer

django-safedelete 1.3.0 - Cannot migrate

I built an internal app that used django-safedelete. I was working fine for months, until i recently upgraded my distro, and tried to add a field to my model. I also upgraded my python modules, everything is up-to-date, and no errors during the…
-1
votes
3 answers

Django Migratons: What is the best default way to dump and load data in DB apart from using third party app?

I'm new to Django and interested in knowing in-depth about migrations so I don't want to use the third-party apps(ex. flyway..) I want to know how to dump hundreds of data in my Postgres DB without using 3rd party applications.
-1
votes
1 answer

Django DB Migration InconsistentMigrationHistory when running migrate

I am unable to migrate my django after running python ./manage.py migrate. This is what showmigrations is displaying customerweb [X] 0001_initial [X] 0002_user_industry [X] 0003_auto_20220209_1737 [X]…
stranger
  • 134
  • 1
  • 7
-1
votes
1 answer

django.db.migrations.exceptions.NodeNotFoundError: Migration app.0172_auto_20220603_1746 dependencie _auto_20220601_2313')

I deleted some migration files that were giving me the error. Then when I write "python3 manage.py showmigrations" I get the following error: root@chat-manager:/var/www/jinabot# python3 manage.py makemigrations Traceback (most recent call last): …
-1
votes
1 answer

dj-stripe referencing a non-existent migration

I have a django model where I have a OneToOneField to djstripe's Customer. When I run makemigrations a migration is created with the following dependency: dependencies = [ ('djstripe', '0011_alter_invoice_charge_alter_invoice_customer_and_more'),…
Bridge
  • 191
  • 9