#25832: Migrating a django-cms.PlaceholderField fails when using Postgres
-------------------------------------+-------------------------------------
     Reporter:  jribbens             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     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 charettes):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Hi @jribbens,

 The `ProgrammingError` you're getting should be fixed in Django 1.9
 (#25002) as long as your `description` text field contain only data that
 can be casted to an integer.

 If it's not the case, which is very likely given it's a free text field,
 you either have to drop the original column and create a new one just like
 you described or do the following:

 1. Create a migration that adds the `PlaceholderField` to your model
 (which is just a disguised nullable foreign key to `cms.Placeholder`).
 2. Create a [https://docs.djangoproject.com/en/1.8/topics/migrations
 /#data-migrations data migration] that populates the newly added
 `PlaceholderField` based on the original `description` text field.
 3. Create a migration that removes the original `description` text field
 and rename the newly added `PlaceholderField` field if required.

 Hope it helps.

--
Ticket URL: <https://code.djangoproject.com/ticket/25832#comment:1>
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.a463be47f4715406fd228399d66a7b11%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to