From 3aeb00d82a94b825f8dd6093286561be0cde8e51 Mon Sep 17 00:00:00 2001 From: Jack Stdin Date: Wed, 13 Jan 2016 00:22:13 +0300 Subject: [PATCH] Fix integrity error, add unique index and remove aoid from PK --- aore/dbutils/dbhandler.py | 2 +- aore/templates/postgre/pre_create.sql | 3 ++- manage.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aore/dbutils/dbhandler.py b/aore/dbutils/dbhandler.py index ce680a6..72118f3 100644 --- a/aore/dbutils/dbhandler.py +++ b/aore/dbutils/dbhandler.py @@ -27,7 +27,7 @@ class DbHandler: self.db.transaction_commit() except: self.db.transaction_rollback() - logging.error("Error updating sql. Reason : {}".format(format_exc())) + raise BaseException("Error updating sql. Reason : {}".format(format_exc())) logging.warning("Inserted {} queries FROM {}".format(chunk_size, csv_file_name)) diff --git a/aore/templates/postgre/pre_create.sql b/aore/templates/postgre/pre_create.sql index 5b72afd..51ba195 100644 --- a/aore/templates/postgre/pre_create.sql +++ b/aore/templates/postgre/pre_create.sql @@ -9,7 +9,8 @@ CREATE TABLE "public"."ADDROBJ" ( "parentguid" UUID, "actstatus" BIT(1), "currstatus" INT2, - PRIMARY KEY ("id", "aoid") + CONSTRAINT "aoid" UNIQUE ("aoid"), + CONSTRAINT "id" PRIMARY KEY ("id") ) WITH (OIDS =FALSE ); diff --git a/manage.py b/manage.py index 81b9e74..5b1a494 100644 --- a/manage.py +++ b/manage.py @@ -26,7 +26,7 @@ def main(): help="Create/update DB from source. Value: \"http\" or absolute path to folder") options, arguments = p.parse_args() - if options.database and options.source: + if options.database: # create new database if options.database == "create": create_base(options.source)