From 81528fcda765f58220fefb383e04f746ef7dc45d Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 27 Jul 2017 16:11:03 +0200 Subject: [PATCH] Bugfixing --- db/create-poweradmin-db-postgresql.sql | 5 ++--- pp_lib/import_pdnsdata.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/db/create-poweradmin-db-postgresql.sql b/db/create-poweradmin-db-postgresql.sql index 78264ae..422c3f5 100644 --- a/db/create-poweradmin-db-postgresql.sql +++ b/db/create-poweradmin-db-postgresql.sql @@ -165,10 +165,9 @@ CREATE TABLE zones ( domain_id integer default 0, owner integer default 0, comment text, - zone_templ_id integer NOT NULL, + zone_templ_id integer NOT NULL default 0, FOREIGN KEY(domain_id) REFERENCES domains(id), - FOREIGN KEY(owner) REFERENCES users(id), - FOREIGN KEY(zone_templ_id) REFERENCES zone_templ(id) + FOREIGN KEY(owner) REFERENCES users(id) ); CREATE INDEX zone_domain_owner ON zones(domain_id, owner); diff --git a/pp_lib/import_pdnsdata.py b/pp_lib/import_pdnsdata.py index db6f0ac..c9ae462 100644 --- a/pp_lib/import_pdnsdata.py +++ b/pp_lib/import_pdnsdata.py @@ -30,7 +30,7 @@ from .common import pp, to_bool from .cfg_app import PpCfgAppError, PpConfigApplication -__version__ = '0.7.4' +__version__ = '0.7.5' LOG = logging.getLogger(__name__) # ============================================================================= @@ -495,7 +495,6 @@ class ImportPdnsdataApp(PpConfigApplication): 'supermasters', 'tsigkeys', 'domains', ] if self.tgt_db_is_poweradmin: - tables.insert(0, 'perm_templ_items') tables.insert(0, 'zone_templ') tables.insert(0, 'zone_templ_records') tables.insert(0, 'zones') @@ -505,7 +504,6 @@ class ImportPdnsdataApp(PpConfigApplication): 'domains_id_seq', 'records_id_seq', 'tsigkeys_id_seq', ] if self.tgt_db_is_poweradmin: - sequences.append('perm_templ_items_id_seq') sequences.append('zone_templ_id_seq') LOG.info("Truncating all tables in target database ...") @@ -522,6 +520,14 @@ class ImportPdnsdataApp(PpConfigApplication): tgt_cursor.execute(sql) if self.tgt_db_is_poweradmin: + + LOG.debug("Truncating table 'perm_templ_items' ...") + sql = "DELETE FROM perm_templ_items WHERE templ_id != 1" + if self.verbose > 1: + LOG.debug("SQL: {}".format(sql)) + if not self.simulate: + tgt_cursor.execute(sql) + LOG.debug("Truncating table 'users' ...") sql = 'DELETE FROM users WHERE id > 1' if self.verbose > 1: -- 2.39.5