While it's good to clear out the old table while loading it in, you might want to consider something along the lines of: drop table if exists peeringdb_facility_temp ; create table peeringdb_facility_temp like peeringdb_facility ; insert into peeringdb_facility_temp ... ; rename table peeringdb_facility to peeringdb_facility_old, peeringdb_facility_temp to peeringdb_facility ; drop table peeringdb_facility_old ; (repeat for each table - ideally in a loop with dynamically specified table names instead of hardcoded ones... ) This way you don't end up with a gap where the table doesn't exist while you're re-creating it. -Steve
On Apr 13, 2016, at 5:29 PM, Martin J. Levy <mahtin@mahtin.com> wrote:
All,
Occasionally I get errors from doing a sync command.
django.core.exceptions.ValidationError: {'name': [u'Organization with this Name already exists.']}
I've gone back-n-forth on trying to fix this; however I realized I should share this sql script that I run prior to "sync" in order to fix this. Once you run "sync" you have a clean copy of PeeringDB.
This can be found at https://github.com/peeringdb/peeringdb-py/pull/7
Enjoy,
Martin
----------- $ cat drop-tables-peeringdb.sql DROP TABLE IF EXISTS peeringdb_facility; DROP TABLE IF EXISTS peeringdb_ix; DROP TABLE IF EXISTS peeringdb_ix_facility; DROP TABLE IF EXISTS peeringdb_ixlan; DROP TABLE IF EXISTS peeringdb_ixlan_prefix; DROP TABLE IF EXISTS peeringdb_network; DROP TABLE IF EXISTS peeringdb_network_contact; DROP TABLE IF EXISTS peeringdb_network_facility; DROP TABLE IF EXISTS peeringdb_network_ixlan; DROP TABLE IF EXISTS peeringdb_organization; DROP TABLE IF EXISTS auth_group; DROP TABLE IF EXISTS auth_group_permissions; DROP TABLE IF EXISTS auth_permission; DROP TABLE IF EXISTS auth_user; DROP TABLE IF EXISTS auth_user_groups; DROP TABLE IF EXISTS auth_user_user_permissions; DROP TABLE IF EXISTS django_admin_log; DROP TABLE IF EXISTS django_content_type; DROP TABLE IF EXISTS django_migrations; DROP TABLE IF EXISTS django_session; $ _______________________________________________ Pdb-tech mailing list Pdb-tech@lists.peeringdb.com http://lists.peeringdb.com/cgi-bin/mailman/listinfo/pdb-tech