How do I move my development data tables to production server?

18 views
Skip to first unread message

Tom Tanner

unread,
Apr 23, 2018, 3:50:12 PM4/23/18
to Django users
Hey all, I have a bunch of tables on my local Django project. I set up the project on my production server and ran `manage.py migrate`. That set up the tables, but now I want to move the rows from my local tables to the ones on the production server. Both local and production server use Postgres. Is there a Django way to move the table data to production?

Mike Dewhirst

unread,
Apr 23, 2018, 6:42:56 PM4/23/18
to django...@googlegroups.com
Not unless someone has written one and made it available. I haven't
googled that so I don't know.

My approach would be to dump and reload if you want identical databases
in dev and prd. You are looking for pgdump to make a dump file and to
load at the other end you probably want dropdb, createdb and psql.

It is worthwhile writing a couple of scripts to manage that.

Mike


> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f65cd8eb-6399-4ee7-8830-84b19ea9b689%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f65cd8eb-6399-4ee7-8830-84b19ea9b689%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Mike Dewhirst

unread,
Apr 23, 2018, 8:59:15 PM4/23/18
to Django users
On 24/04/2018 8:57 AM, Anthony Flury wrote:
> You can use manage.py dumpdata and manage.py loaddata
>
> And you can do this per app - or even per table.

Thank you Anthony

I had totally forgotten that. In fact I actually script dumpdata for
dumping test data (ie fixtures) but loaddata never worked for me. So
much so that I was easily able to expunge it from my overloaded
brainspace :)

Cheers

Mike

>
> The challenge is if your production server already has data in it, and
> uses Auto Incrementing Ids, then the ids from the development wont be
> valid in the production server.
>
> You also have the challenge that your data-base might not allow you to
> Insert values into a field which is meant to be based on an
> incrementing sequence.
>
> --
> Tony
Reply all
Reply to author
Forward
0 new messages