Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:58:12+00:00 2026-05-28T05:58:12+00:00

I want to move the field honk and it’s data from one model to

  • 0

I want to move the field honk and it’s data from one model to another using South:

class Foo(models.Model):
    foofield = models.CharField()
    honk = models.PositiveIntegerField()

class Bar(models.Model):
    barfield = models.CharField()

I’ve done this before, using 3 separate migrations:

  1. A schema migration, adding honk to Bar
  2. A data migration, copying all Foo.honk data to Bar.honk
  3. Another schema migration, dropping honk from Foo

Can I do these three steps in a single migration?

I’ve already learnt that there isn’t much of a difference between schema and data migrations in South, so I figured perhaps something like this might work (which is the three migrations above just munged into one):

class Migration(DataMigration):
    def forwards(self, orm):
        # add column
        db.add_column('myapp_bar', 'honk', self.gf('django.db.models.fields.PositiveIntegerField')(default='0'), keep_default=False)

        # copy data
        for foo in Foo.objects.all():
            # find the right bar here and then ...
            bar.honk = foo.honk
            bar.save()

        # remove old column
        db.delete_column('myapp_foo', 'honk')

Will this work or will it fail because my (South frozen) orm doesn’t know about Bar.honk yet? Or am I doing it wrong and there’s a nicer way to do this sort of thing in a single migration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:58:12+00:00Added an answer on May 28, 2026 at 5:58 am

    Since this question earned me a Tumbleweed badge, I’ve dug in and tried it myself. Here’s what I’ve found out.

    No you can’t merge these migrations

    Because the ORM freeze only contains the schema you are migrating to. So in the above example, foo.honk wouldn’t be accessible during the data migration (the for loop), because it is deleted during the schema migration, so it isn’t in the frozen ORM. Additionally you’ll get DatabaseError exceptions if you try to access data because the columns in the database don’t yet match the ones of the model (i.e. if you try to access anything before a db.add_column).

    Looks like there’s no simple shortcut and doing something like this does take the 3 migrations mentioned above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have fields in one class and I want to move them to another
We want to move data from Oracle to SQL Server, and make it available
I want to move a part, i.e. one subdirectory of an existing, private mercurial
I want to move some file to other place, using Java SE 1.6 So,
I want to move all files and folders inside a folder to another folder.
Basically I want to move files to another server on creation preserving the directory
I have an application and I want to move some of the tables from
Before all of my messages were in one maildir. Now I want move all
I'm trying to move toward using the View/Model/View-Model or Presentation Model pattern in a
Upon page load I want to move the cursor to a particular field. No

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.