#27871: Django keeps making the same migration over and over again
-------------------------------------+-------------------------------------
     Reporter:  Kyle Agronick        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.10
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Kyle Agronick):

 * type:  Uncategorized => Bug


Old description:

> This is what the migration looks like:
>

> {{{
> class Migration(migrations.Migration):
>
>     dependencies = [
>         ('jobs', '0003_auto_20170222_1154'),
>     ]
>
>     operations = [
>         migrations.AlterField(
>             model_name='joblog',
>             name='job',
> field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
> related_name='logs', to='jobs.Job'),
>         ),
>     ]
>
> }}}
>

> Running ./mange.py migrate makes no difference. I recently moved the
> codebase to Python 3.
>
> Below is the create table syntax for the relevant tables:
>

> {{{
> CREATE TABLE `jobs_jobparameter` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `name` varchar(100) NOT NULL,
>   `value` longtext NOT NULL,
>   `job_group_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   UNIQUE KEY `jobs_jobparameter_job_group_id_bbb541f6_uniq`
> (`job_group_id`,`name`),
>   KEY `jobs_jobparameter_name_84b3d6ba_uniq` (`name`),
>   CONSTRAINT
> `jobs_jobparameter_job_group_id_7205c657_fk_jobs_jobgroup_id` FOREIGN KEY
> (`job_group_id`) REFERENCES `jobs_jobgroup` (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=45338 DEFAULT CHARSET=utf8
>
> CREATE TABLE `jobs_joblog` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `command` longtext NOT NULL,
>   `command_output` longtext NOT NULL,
>   `result` tinyint(1) NOT NULL,
>   `job_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `jobs_joblog_job_id_734186c1ec7977e9_fk_jobs_job_id` (`job_id`),
>   CONSTRAINT `jobs_joblog_job_id_ae8f8e96_fk_jobs_job_id` FOREIGN KEY
> (`job_id`) REFERENCES `jobs_job` (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=7749677 DEFAULT CHARSET=latin1
>
> CREATE TABLE `jobs_jobgroup` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `job_type` varchar(100) NOT NULL,
>   `created_by_id` int(11) NOT NULL,
>   `created_date` datetime NOT NULL,
>   `queued_date` datetime DEFAULT NULL,
>   PRIMARY KEY (`id`),
>   KEY `jobs_jobgroup_created_by_id_769ccba8b90c80f8_fk_auth_user_id`
> (`created_by_id`),
>   KEY `jobs_jobgroup_job_type_c2db1010_uniq` (`job_type`),
>   KEY `jobs_jobgroup_created_date_852898d7_uniq` (`created_date`),
>   KEY `jobs_jobgroup_queued_date_c38be898_uniq` (`queued_date`),
>   CONSTRAINT
> `jobs_jobgroup_created_by_id_769ccba8b90c80f8_fk_auth_user_id` FOREIGN
> KEY (`created_by_id`) REFERENCES `auth_user` (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=15290 DEFAULT CHARSET=latin1
>
> CREATE TABLE `jobs_job` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `state` varchar(1) NOT NULL,
>   `start_date` datetime DEFAULT NULL,
>   `end_date` datetime DEFAULT NULL,
>   `job_group_id` int(11) NOT NULL,
>   `store` varchar(40) NOT NULL,
>   `payload` longtext NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `jobs_job_be96d149` (`job_group_id`),
>   KEY `jobs_job_store_6681c0e7_uniq` (`store`),
>   KEY `jobs_job_start_date_b8aefdc3_uniq` (`start_date`),
>   KEY `jobs_job_state_6ec9b5f7_uniq` (`state`),
>   CONSTRAINT `jobs_job_job_group_id_93d2fccf_fk_jobs_jobgroup_id` FOREIGN
> KEY (`job_group_id`) REFERENCES `jobs_jobgroup` (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=3316872 DEFAULT CHARSET=latin1
> }}}

New description:

 This is what the migration looks like:


 {{{
 class Migration(migrations.Migration):

     dependencies = [
         ('jobs', '0003_auto_20170222_1154'),
     ]

     operations = [
         migrations.AlterField(
             model_name='joblog',
             name='job',
 field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
 related_name='logs', to='jobs.Job'),
         ),
     ]

 }}}


 Running ./mange.py migrate makes no difference. I recently moved the
 codebase to Python 3.

 Below is the create table syntax for the relevant tables:


 {{{
 CREATE TABLE `jobs_jobparameter` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `name` varchar(100) NOT NULL,
   `value` longtext NOT NULL,
   `job_group_id` int(11) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `jobs_jobparameter_job_group_id_bbb541f6_uniq`
 (`job_group_id`,`name`),
   KEY `jobs_jobparameter_name_84b3d6ba_uniq` (`name`),
   CONSTRAINT `jobs_jobparameter_job_group_id_7205c657_fk_jobs_jobgroup_id`
 FOREIGN KEY (`job_group_id`) REFERENCES `jobs_jobgroup` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=45338 DEFAULT CHARSET=utf8

 CREATE TABLE `jobs_joblog` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `command` longtext NOT NULL,
   `command_output` longtext NOT NULL,
   `result` tinyint(1) NOT NULL,
   `job_id` int(11) NOT NULL,
   PRIMARY KEY (`id`),
   KEY `jobs_joblog_job_id_734186c1ec7977e9_fk_jobs_job_id` (`job_id`),
   CONSTRAINT `jobs_joblog_job_id_ae8f8e96_fk_jobs_job_id` FOREIGN KEY
 (`job_id`) REFERENCES `jobs_job` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=7749677 DEFAULT CHARSET=latin1

 CREATE TABLE `jobs_jobgroup` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `job_type` varchar(100) NOT NULL,
   `created_by_id` int(11) NOT NULL,
   `created_date` datetime NOT NULL,
   `queued_date` datetime DEFAULT NULL,
   PRIMARY KEY (`id`),
   KEY `jobs_jobgroup_created_by_id_769ccba8b90c80f8_fk_auth_user_id`
 (`created_by_id`),
   KEY `jobs_jobgroup_job_type_c2db1010_uniq` (`job_type`),
   KEY `jobs_jobgroup_created_date_852898d7_uniq` (`created_date`),
   KEY `jobs_jobgroup_queued_date_c38be898_uniq` (`queued_date`),
   CONSTRAINT
 `jobs_jobgroup_created_by_id_769ccba8b90c80f8_fk_auth_user_id` FOREIGN KEY
 (`created_by_id`) REFERENCES `auth_user` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=15290 DEFAULT CHARSET=latin1

 CREATE TABLE `jobs_job` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `state` varchar(1) NOT NULL,
   `start_date` datetime DEFAULT NULL,
   `end_date` datetime DEFAULT NULL,
   `job_group_id` int(11) NOT NULL,
   `store` varchar(40) NOT NULL,
   `payload` longtext NOT NULL,
   PRIMARY KEY (`id`),
   KEY `jobs_job_be96d149` (`job_group_id`),
   KEY `jobs_job_store_6681c0e7_uniq` (`store`),
   KEY `jobs_job_start_date_b8aefdc3_uniq` (`start_date`),
   KEY `jobs_job_state_6ec9b5f7_uniq` (`state`),
   CONSTRAINT `jobs_job_job_group_id_93d2fccf_fk_jobs_jobgroup_id` FOREIGN
 KEY (`job_group_id`) REFERENCES `jobs_jobgroup` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=3316872 DEFAULT CHARSET=latin1
 }}}

 The migrations are attached.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27871#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.3990caae04acf2834d49780c7e979012%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to