Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2023-10-19 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  vrocha
 Type:  Bug  |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by vrocha):

 * owner:  (none) => vrocha
 * status:  new => assigned


Comment:

 I am at DjangoCon US sprints trying to get to the bottom of this

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018b48d69c5e-e635da25-7a8c-4715-989e-53b99217afa7-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2023-09-27 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Fabian Pottbäcker):

 I just ran into a similar Issue when reverting migrations on Postgres,
 specifically I have the following condensed and abstracted migration
 history:

 1. Setup:
   1. Create model Author
   2. Create model Book (`author = ForeignKey(Author)`)
 2. Introduce PenNames
   1. Create model PenName
   2. Alter `Book.author` to allow null
   3. Add `author_new = ForgeignKey(PenName, null=True)` to book
   4. RunPython to create PenNames for all authors and set `author_new`
 accordingly (including a corresponding reverse operation)
   5. Drop `Book.author`
   6. Alter `Book.author_new` to prohibit null
   7. Rename `Book.author_new` to `Book.author`
 3. Remove PenNames (for whatever reason)
   1. Some Operation to repopulate `Book.author`
   2. Drop column `Book.author`

 After successfully applying these migrations, reverting to State 1 will
 error when undoing step 2.5, since the index `book_author_id...` was
 already created when undoing step 3.2, but it would be called
 `book_author_new_id...` when applying these migrations forwards.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ad67b7369-fb17d4cd-7332-4232-bde0-511f7b1a53b8-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2023-07-31 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Roberto Maurizzi):

 Just hit the same problem after renaming a Model and creating a new one
 with the old name (to conform to how several other models in that
 application ended up being named).

 I was able to fix it by:
  - changing the new Model creation in the migration to specify
 `spatial_index=False` (it was a GIS field, I guess for regular ones you
 need to use `db_index=False`)
  - running makemigrations again: since I never changed the models, it
 detected the missing indexes and created another migration that added them
 to the db

 This worked both for migrating the production database (was working
 earlier too) and when running tests.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070189af7e576f-6ceed60e-8e3f-43c2-8d37-6e193f0fef84-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2023-06-12 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Steven Mapes):

 So I ended up created a duplicate of this ticket for issue #34647 but
 thanks to clavay's suggestion I managed to also get a work around by
 running {{{makemigrations}}}then editing the {{{CreateModel}}} and
 changing the name and db_table entries for all tables that were created (I
 use custom table names as the app name prefix breaks the DB naming
 convention policy that's in place for the project.

 I then added {{{migrations.RenameModel}}} statements for each of the
 models I needed to rename back, four of them, then finally had to run a
 {{{migrations.RunSQL}}} to perform the actual rename of the underlying
 databases tables.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188aede1139-59f08f5a-69f5-41ac-8589-421504103e98-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2023-06-11 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Bhuvnesh):

 * cc: Bhuvnesh (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188aab50f9f-a9dafacc-8982-4b4f-a14c-42c3a1ff6027-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2022-12-12 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by JohnLZeller):

 Also ran into this same issue the way the OP wrote it

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070185091a1b05-75a41baa-c277-4e15-84ae-0646a2e504b5-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2022-12-08 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Mikko Ahonen):

 Run into this as well, using django 3.1 and Postgres. Similar case as for
 scholtalbers.

 I wanted to switch to using a library that wanted to add field to model
 which was conflicting with the existing name, used for similar purpose
 (parent).

 I renamed the field (to old_parent), ran migration, created migration,
 added the library (which added the parent field), created migration, run
 migration.

 Locally migrations worked because I was using SQLite, but when installing
 on staging it failed because of conflicting index name.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184f4447718-6f4b218c-873f-41b2-81c5-fe962b5dd944-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2022-11-02 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by scholtalbers):

 Encountered this (django 3.2) when trying to add a field with the same
 name of a field I renamed in a few migrations before. The original index
 is still existing. It should have been renamed as part of the AlterField
 migration.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018437e17f8e-a0426515-d170-447b-8d5f-eb77373f52a7-00%40eu-central-1.amazonses.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2022-02-03 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Jef D):

 Just opened this issue: https://code.djangoproject.com/ticket/33488#ticket
 which was apparently a duplicate of this one. I did a rename and quickly
 after I reused the old name of the field which made this very visible.
 However, I can imagine that it is a difficult error to find when it
 happens with longer periods in between. The longer a project lasts, the
 more likely it is that one will run into this kind of issues.

 Unfortunately, the issue doesn't seem to have a high priority given that
 it has been 7 years since it was opened. For now I will sandwich the
 rename migration with unsetting and setting the index in two additional
 migrations.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.6a07f3253ca6ae56c99e1aff33d0db3c%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2021-12-07 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Daniel Hahler):

 * cc: Daniel Hahler (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.85748499c2e3c3700ca9b8b9e3b9912a%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2021-09-26 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Steve Recio):

 Just ran into this issue when attempting to rename and rebuild a table.
 Renaming the table doesn't change any of the indexes or constraints so I
 can't rebuild another table with the same ManyToMany relationship. I tried
 creating a through table and renaming the foreign keys but that doesn't
 seem to do it either as the "UNIQUE TOGETHER" index name itself never
 changes.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.af979d05a56175b69f6d0eb9012cfb6d%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-10-04 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Old description:



New description:

 This one's a bit of an edge case, but I ran into it trying to refactor
 some models on my moderately large work project.

 Let's say I have a Django 1.7 app called `sample`:
 1. Create a model `Bar`.
 2. Create a model `Foo` with `bar = models.ForeignKey(Bar, blank=True,
 null=True)`
 3. `makemigrations` (migration `0001`)
 4. Rename `Foo` to `OldFoo`.
 5. `makemigrations`, say yes to the rename prompt (migration `0002`)
 6. Create new model `Foo`, which also has `bar = models.ForeignKey(Bar,
 blank=True, null=True)`
 7. `makemigrations` (migration `0003`)
 8. `migrate`

 When `migrate` hits `0003`, it throws this error:
 {{{django.db.utils.OperationalError: index sample_foo_4350f7d0 already
 exists}}}

 You may notice that `sqlmigrate sample 0001` and `sqlmigrate sample 0003`
 have the same line in both of them:
 {{{CREATE INDEX sample_foo_4350f7d0 ON "sample_foo" ("bar_id");}}}


 In my production case, I actually had no problems on servers, because
 South had created the index with a different name.  When I renamed the
 models and added a field, the new index did not collide with the old one.
 However, our test suite started failing, because it would run the
 migrations from the ground up, exposing the above bug.

 I haven't decided on a workaround yet, but I thought I'd bring this to
 your attention.  I might have to inject a migration that renames the index
 created in `0001`, or something to that effect.

 The attached test case has a project `dj17test` in the state after having
 performed all of the above steps.

--

Comment (by Thomas Riccardi):

 Restore ticket description

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.eed1a3015da1ecb186ba4c0f1760baa4%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-10-04 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Old description:

> This one's a bit of an edge case, but I ran into it trying to refactor
> some models on my moderately large work project.
>
> Let's say I have a Django 1.7 app called `sample`:
> 1. Create a model `Bar`.
> 2. Create a model `Foo` with `bar = models.ForeignKey(Bar, blank=True,
> null=True)`
> 3. `makemigrations` (migration `0001`)
> 4. Rename `Foo` to `OldFoo`.
> 5. `makemigrations`, say yes to the rename prompt (migration `0002`)
> 6. Create new model `Foo`, which also has `bar = models.ForeignKey(Bar,
> blank=True, null=True)`
> 7. `makemigrations` (migration `0003`)
> 8. `migrate`
>
> When `migrate` hits `0003`, it throws this error:
> {{{django.db.utils.OperationalError: index sample_foo_4350f7d0 already
> exists}}}
>
> You may notice that `sqlmigrate sample 0001` and `sqlmigrate sample 0003`
> have the same line in both of them:
> {{{CREATE INDEX sample_foo_4350f7d0 ON "sample_foo" ("bar_id");}}}
>

> In my production case, I actually had no problems on servers, because
> South had created the index with a different name.  When I renamed the
> models and added a field, the new index did not collide with the old one.
> However, our test suite started failing, because it would run the
> migrations from the ground up, exposing the above bug.
>
> I haven't decided on a workaround yet, but I thought I'd bring this to
> your attention.  I might have to inject a migration that renames the
> index created in `0001`, or something to that effect.
>
> The attached test case has a project `dj17test` in the state after having
> performed all of the above steps.

New description:



--

Comment (by clavay):

 I tried this and it works :
 In the migration file I replace this :

 {{{
 migrations.AlterField(
 model_name='foo',
 name='variable',
 field=models.ForeignKey(null=True,
 on_delete=django.db.models.deletion.SET_NULL, to='app.Variable'),
 ),
 }}}



 with this :

 {{{
 migrations.RenameModel('Foo', 'FooNew'),
 migrations.AlterField(
 model_name='foonew',
 name='variable',
 field=models.ForeignKey(null=True,
 on_delete=django.db.models.deletion.SET_NULL, to='app.Variable'),
 ),
 migrations.RenameModel('FooNew', 'Foo'),

 }}}


 Is it a good solution ?

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.48b4ccb47b8941603db032583508a435%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-09-17 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Friedrich Delgado):

 * cc: Friedrich Delgado (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.2defc6ab1455a9375a88c3dba3eb7347%40djangoproject.com.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-06-07 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Sardorbek Imomaliev):

 * cc: Sardorbek Imomaliev (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.a2904704ef9319132489f45c2b343e8d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-05-21 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Thomas Riccardi):

 To get the proper new index name:
 {{{#!python
 from django.db import connection
 schema_editor = connection.schema_editor()

 def get_index_name(field):
 return schema_editor._create_index_name(field.model._meta.db_table,
 [field.attname])

 get_index_name(ModelFoo.field_bar.field)
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.5363745edb0a5fe08b83ab4e6c6429b0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-05-21 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Thomas Riccardi):

 Some analysis (with postgresql backend):
 - when creating a new field with index (such as a ForeignKey), django
 creates the column and the index
 - when deleting a field, django only deletes the column: it lets
 postgresql delete all related index automatically
 - when renaming a field, django only renames the column: it lets
 postgresql update all index references (and probably more), *but does not*
 rename the index

 It seems django doesn't really track the index name, and it works great
 except for renames

 => when a new index has to be created for the old field name, the index
 name conflicts: this is this issue.


 This reliance on field reference automatic update by the db seems to
 create a similar issue with index_together/unique_together:
 field rename +  index_together/unique_together alternation to update the
 field name results in no SQL except the RENAME COLUMN: the index/unique
 names are *not* updated.


 The workaround from comment 17 (ticket:23577#comment:17) with a manual
 index rename may create issues when this ticket is fixed:
 at that point django will probably assume the index name is the one it
 generates if it had to create the index, and the comment uses a different
 one (the hash_suffix_part is different)
 => for more rubustness/future compatibility I suggest to use the "proper"
 index name: manually create migrations to delete then re-create the field,
 and use `./manage.py sqlmigrate` to get the created index name (it depends
 solely on table name and index fields name: see
 django/db/backends/base/schema.py:BaseDatabaseSchemaEditor._create_index_name)

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.59d5dca4e0a3e90d6d7e1e50879f312f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-05-20 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Thomas Riccardi):

 * cc: Thomas Riccardi (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.83397b7daaf142612bd52c7d3cc46d93%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2019-02-12 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Vadym Moshynskyi):

 * cc: Vadym Moshynskyi (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.a9a5973e5a65d5f08ff53b6c1ec4f300%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2018-04-03 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by jonathan-golorry):

 I just ran into this issue with `RenameField` on `ManyToMany` relations.
 The (automatically generated) through table changes name, but the id_seq
 for it doesn't.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.8e5091d6abba3267020ec72fa5989320%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2018-02-01 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Ryan Hiebert):

 * cc: Ryan Hiebert (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.4747f8842d21f3451745ce42860e7df6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2017-11-16 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by Tim Graham):

 I closed #28803 as a duplicate.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.bda1d0079b536d15e7fa6142c93a6789%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2017-10-03 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
-+
 Reporter:  Chris Woytowitz  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by mkoistinen):

 Until this is resolved, one can work-around this issue by doing something
 like:

 {{{
 migrations.RunSQL(
 'ALTER INDEX myapp_mymodel_myfield_othermodel_id_0f4cfc54
 rename TO myapp_mymodel_myfield_othermodel_legacy_id_0f4cfc54',
 'ALTER INDEX
 myapp_mymodel_myfield_othermodel_legacy_id_0f4cfc54 rename TO
 myapp_mymodel_myfield_othermodel_id_0f4cfc54',
 )
 }}}

 This sort of approach should work well for both FKs and M2Ms (example
 below), but it may make your migrations DB Backend specific =/

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.35556608a6bc1588676701e01ba80c21%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value

2016-09-20 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
+
 Reporter:  CrimsonZen  |Owner:
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  master
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+
Changes (by edmorley):

 * cc: emorley@… (added)


--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.5b952fb13f1bd7c236bcbb53e19bbc6c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23577: Rename operations should rename indexes, constraints, sequences and triggers named after their former value (was: RenameModel should rename indexes, constraints, sequences and tri

2016-05-26 Thread Django
#23577: Rename operations should rename indexes, constraints, sequences and
triggers named after their former value
+
 Reporter:  CrimsonZen  |Owner:
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  master
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+

Comment (by charettes):

 This should also be the case for `AlterField` operations on both sides
 (e.g. foreign key constraint names are generated from their referenced
 table and column names).

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.183e70a8cf207f9547498d816b872cc8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.