Hello,
I have a project originally developed using Django 1.5 but upgraded up to 1.9.1. It uses a custom user model (from AbstractUser).
Yesterday I had to create a user and Django replied with an exception. After some googling, this exception was caused because last_login can now be None while the database schema says last_login is not null.
Django's "makemigrations" detects the change but it is run in the first migration. This migration cannot be applied because the table already exists so I faked it.
Then I made a standalone migration. Django says this migration IS applied but the database says it is not.
Of course I can apply the migration by hand using SQL (or so I hope) but I'd like to use migrations for this task. And so the question. Why doesn't it apply?
Thanks!!
Norberto
===== console output =====
(prueba)ubuntu@consulta:~/prueba⟫ ./manage.py migrate accounts
Operations to perform:
Apply all migrations: accounts
Running migrations:
Rendering model states... DONE
Applying accounts.0002_consultauser_last_login_null... OK
===== postgresql output =====
prueba=> \d accounts_consultauser
Table "public.accounts_consultauser"
Column | Type | Modifiers
--------------+--------------------------+--------------------------------------------------------------------
id | integer | not null default nextval('accounts_consultauser_id_seq'::regclass)
password | character varying(128) | not null
last_login | timestamp with time zone | not null
.
.
.
==== migration code ====
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='consultauser',
name='last_login',
field=models.DateTimeField(null=True, verbose_name='last login', blank=True),
),
]