From 109459a4d8a1c9ddc0c2bf4f69daf66ff8b5be49 Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Thu, 5 Dec 2019 10:10:11 -0500 Subject: [PATCH 1/5] process_tracker_python-157 Config file being reset on import :bug: Issue with logic when config_location provided Logical fault caused the config file in config_location to be overwritten as if it didn't exist. --- process_tracker/models/actor.py | 4 ++-- process_tracker/models/capacity.py | 6 ++--- process_tracker/models/contact.py | 4 ++-- process_tracker/models/extract.py | 26 ++++++++++---------- process_tracker/models/model_base.py | 12 ++++++++++ process_tracker/models/process.py | 34 +++++++++++++-------------- process_tracker/models/schedule.py | 4 ++-- process_tracker/models/source.py | 28 +++++++++++----------- process_tracker/models/system.py | 4 ++-- process_tracker/models/tool.py | 4 ++-- process_tracker/utilities/settings.py | 7 ++---- 11 files changed, 71 insertions(+), 62 deletions(-) diff --git a/process_tracker/models/actor.py b/process_tracker/models/actor.py index dd2c8de..6b55f2a 100755 --- a/process_tracker/models/actor.py +++ b/process_tracker/models/actor.py @@ -2,10 +2,10 @@ # Models for Actor entities from sqlalchemy import Column, Integer, Sequence, String -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class Actor(Base): +class Actor(Base, BaseColumn): __tablename__ = "actor_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/capacity.py b/process_tracker/models/capacity.py index c88769b..bb8ca03 100644 --- a/process_tracker/models/capacity.py +++ b/process_tracker/models/capacity.py @@ -5,10 +5,10 @@ from sqlalchemy import Column, ForeignKey, Integer, Sequence, String from sqlalchemy.orm import relationship -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class Cluster(Base): +class Cluster(Base, BaseColumn): __tablename__ = "cluster_tracking_lkup" __table_args__ = {"schema": "process_tracker"} @@ -34,7 +34,7 @@ def __repr__(self): return "" % self.cluster_name -class ClusterProcess(Base): +class ClusterProcess(Base, BaseColumn): __tablename__ = "cluster_process" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/contact.py b/process_tracker/models/contact.py index 0babe4f..0b4f317 100644 --- a/process_tracker/models/contact.py +++ b/process_tracker/models/contact.py @@ -2,10 +2,10 @@ # Models for Contact entities from sqlalchemy import Column, Integer, Sequence, String -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class Contact(Base): +class Contact(Base, BaseColumn): __tablename__ = "contact_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/extract.py b/process_tracker/models/extract.py index 47a53c0..3c93e4c 100755 --- a/process_tracker/models/extract.py +++ b/process_tracker/models/extract.py @@ -16,10 +16,10 @@ ) from sqlalchemy.orm import relationship -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class ExtractStatus(Base): +class ExtractStatus(Base, BaseColumn): __tablename__ = "extract_status_lkup" __table_args__ = {"schema": "process_tracker"} @@ -42,7 +42,7 @@ def __repr__(self): ) -class ExtractCompressionType(Base): +class ExtractCompressionType(Base, BaseColumn): __tablename__ = "extract_compression_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -63,7 +63,7 @@ def __repr__(self): return "" % (self.extract_compression_type) -class ExtractFileType(Base): +class ExtractFileType(Base, BaseColumn): __tablename__ = "extract_filetype_lkup" __table_args__ = {"schema": "process_tracker"} @@ -88,7 +88,7 @@ def __repr__(self): ) -class Extract(Base): +class Extract(Base, BaseColumn): __tablename__ = "extract_tracking" __table_args__ = {"schema": "process_tracker"} @@ -164,7 +164,7 @@ def full_filepath(self): return str(Path(self.locations.location_path).joinpath(self.extract_filename)) -class ExtractDatasetType(Base): +class ExtractDatasetType(Base, BaseColumn): __tablename__ = "extract_dataset_type" __table_args__ = {"schema": "process_tracker"} @@ -194,7 +194,7 @@ def __repr__(self): ) -class ExtractDependency(Base): +class ExtractDependency(Base, BaseColumn): __tablename__ = "extract_dependency" __table_args__ = {"schema": "process_tracker"} @@ -223,7 +223,7 @@ def __repr__(self): ) -class ExtractProcess(Base): +class ExtractProcess(Base, BaseColumn): __tablename__ = "extract_process_tracking" __table_args__ = {"schema": "process_tracker"} @@ -263,7 +263,7 @@ def __repr__(self): ) -class ExtractSource(Base): +class ExtractSource(Base, BaseColumn): __tablename__ = "extract_source" __table_args__ = {"schema": "process_tracker"} @@ -294,7 +294,7 @@ def __repr__(self): ) -class ExtractSourceObject(Base): +class ExtractSourceObject(Base, BaseColumn): __tablename__ = "extract_source_object" __table_args__ = {"schema": "process_tracker"} @@ -325,7 +325,7 @@ def __repr__(self): ) -class FileSizeType(Base): +class FileSizeType(Base, BaseColumn): __tablename__ = "filesize_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -349,7 +349,7 @@ def __repr__(self): ) -class LocationType(Base): +class LocationType(Base, BaseColumn): __tablename__ = "location_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -374,7 +374,7 @@ def __repr__(self): ) -class Location(Base): +class Location(Base, BaseColumn): __tablename__ = "location_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/model_base.py b/process_tracker/models/model_base.py index e39dfa8..f740eaf 100755 --- a/process_tracker/models/model_base.py +++ b/process_tracker/models/model_base.py @@ -1,8 +1,20 @@ # Base Model class for other data models. +from datetime import datetime from dateutil import parser from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy import Column, Integer, DateTime Base = declarative_base() default_date = parser.parse("1900-01-01 00:00:00") +current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + + +class BaseColumn(object): + created_date_time = Column(DateTime, nullable=False, default=current_time) + created_by = Column(DateTime, nullable=False, default=0) + update_date_time = Column( + DateTime, nullable=False, default=current_time, onupdate=current_time + ) + updated_by = Column(DateTime, nullable=False, default=0) diff --git a/process_tracker/models/process.py b/process_tracker/models/process.py index 6f627ac..3aa7a56 100755 --- a/process_tracker/models/process.py +++ b/process_tracker/models/process.py @@ -15,10 +15,10 @@ ) from sqlalchemy.orm import relationship -from process_tracker.models.model_base import default_date, Base +from process_tracker.models.model_base import default_date, Base, BaseColumn -class ErrorType(Base): +class ErrorType(Base, BaseColumn): __tablename__ = "error_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -38,7 +38,7 @@ def __repr__(self): return "" % self.error_type_name -class ErrorTracking(Base): +class ErrorTracking(Base, BaseColumn): __tablename__ = "error_tracking" __table_args__ = {"schema": "process_tracker"} @@ -78,7 +78,7 @@ def __repr__(self): ) -class ProcessStatus(Base): +class ProcessStatus(Base, BaseColumn): __tablename__ = "process_status_lkup" __table_args__ = {"schema": "process_tracker"} @@ -101,7 +101,7 @@ def __repr__(self): ) -class ProcessType(Base): +class ProcessType(Base, BaseColumn): __tablename__ = "process_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -124,7 +124,7 @@ def __repr__(self): ) -class Process(Base): +class Process(Base, BaseColumn): __tablename__ = "process" __table_args__ = {"schema": "process_tracker"} @@ -179,7 +179,7 @@ def __repr__(self): ) -class ProcessContact(Base): +class ProcessContact(Base, BaseColumn): __tablename__ = "process_contact" __table_args__ = {"schema": "process_tracker"} @@ -210,7 +210,7 @@ def __repr__(self): ) -class ProcessDatasetType(Base): +class ProcessDatasetType(Base, BaseColumn): __tablename__ = "process_dataset_type" __table_args__ = {"schema": "process_tracker"} @@ -241,7 +241,7 @@ def __repr__(self): ) -class ProcessFilter(Base): +class ProcessFilter(Base, BaseColumn): __tablename__ = "process_filter" __table_args__ = {"schema": "process_tracker"} @@ -283,7 +283,7 @@ def __repr__(self): ) -class ProcessSource(Base): +class ProcessSource(Base, BaseColumn): __tablename__ = "process_source" __table_args__ = {"schema": "process_tracker"} @@ -312,7 +312,7 @@ def __repr__(self): ) -class ProcessSourceObject(Base): +class ProcessSourceObject(Base, BaseColumn): __tablename__ = "process_source_object" __table_args__ = {"schema": "process_tracker"} @@ -339,7 +339,7 @@ def __repr__(self): ) -class ProcessSourceObjectAttribute(Base): +class ProcessSourceObjectAttribute(Base, BaseColumn): __tablename__ = "process_source_object_attribute" __table_args__ = {"schema": "process_tracker"} @@ -370,7 +370,7 @@ def __repr__(self): ) -class ProcessTarget(Base): +class ProcessTarget(Base, BaseColumn): __tablename__ = "process_target" __table_args__ = {"schema": "process_tracker"} @@ -397,7 +397,7 @@ def __repr__(self): ) -class ProcessTargetObject(Base): +class ProcessTargetObject(Base, BaseColumn): __tablename__ = "process_target_object" __table_args__ = {"schema": "process_tracker"} @@ -425,7 +425,7 @@ def __repr__(self): ) -class ProcessTargetObjectAttribute(Base): +class ProcessTargetObjectAttribute(Base, BaseColumn): __tablename__ = "process_target_object_attribute" __table_args__ = {"schema": "process_tracker"} @@ -456,7 +456,7 @@ def __repr__(self): ) -class ProcessDependency(Base): +class ProcessDependency(Base, BaseColumn): __tablename__ = "process_dependency" __table_args__ = {"schema": "process_tracker"} @@ -485,7 +485,7 @@ def __repr__(self): ) -class ProcessTracking(Base): +class ProcessTracking(Base, BaseColumn): __tablename__ = "process_tracking" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/schedule.py b/process_tracker/models/schedule.py index 8b54b04..2d34e22 100644 --- a/process_tracker/models/schedule.py +++ b/process_tracker/models/schedule.py @@ -4,10 +4,10 @@ from sqlalchemy import Column, Integer, Sequence, String -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class ScheduleFrequency(Base): +class ScheduleFrequency(Base, BaseColumn): __tablename__ = "schedule_frequency_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/source.py b/process_tracker/models/source.py index a97b69c..cab0b06 100755 --- a/process_tracker/models/source.py +++ b/process_tracker/models/source.py @@ -13,10 +13,10 @@ ) from sqlalchemy.orm import relationship -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class CharacterSet(Base): +class CharacterSet(Base, BaseColumn): __tablename__ = "character_set_lkup" __table_args__ = {"schema": "process_tracker"} @@ -37,7 +37,7 @@ def __repr__(self): ) -class DataType(Base): +class DataType(Base, BaseColumn): __tablename__ = "data_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -55,7 +55,7 @@ def __repr__(self): return "" % (self.data_type_id, self.data_type) -class DatasetType(Base): +class DatasetType(Base, BaseColumn): __tablename__ = "dataset_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -80,7 +80,7 @@ def __repr__(self): return "" % self.dataset_type -class FilterType(Base): +class FilterType(Base, BaseColumn): __tablename__ = "filter_type_lkup" __table_args__ = {"schema": "process_tracker"} @@ -102,7 +102,7 @@ def __repr__(self): ) -class Source(Base): +class Source(Base, BaseColumn): __tablename__ = "source_lkup" __table_args__ = {"schema": "process_tracker"} @@ -131,7 +131,7 @@ def __repr__(self): return "" % self.source_name -class SourceContact(Base): +class SourceContact(Base, BaseColumn): __tablename__ = "source_contact" __table_args__ = {"schema": "process_tracker"} @@ -154,7 +154,7 @@ class SourceContact(Base): contacts = relationship("Contact") -class SourceDatasetType(Base): +class SourceDatasetType(Base, BaseColumn): __tablename__ = "source_dataset_type" __table_args__ = {"schema": "process_tracker"} @@ -185,7 +185,7 @@ def __repr__(self): ) -class SourceLocation(Base): +class SourceLocation(Base, BaseColumn): __tablename__ = "source_location" __table_args__ = {"schema": "process_tracker"} @@ -216,7 +216,7 @@ def __repr__(self): ) -class SourceObject(Base): +class SourceObject(Base, BaseColumn): __tablename__ = "source_object_lkup" __table_args__ = {"schema": "process_tracker"} @@ -262,7 +262,7 @@ def __repr__(self): ) -class SourceObjectLocation(Base): +class SourceObjectLocation(Base, BaseColumn): __tablename__ = "source_object_location" __table_args__ = {"schema": "process_tracker"} @@ -291,7 +291,7 @@ def __repr__(self): ) -class SourceObjectAttribute(Base): +class SourceObjectAttribute(Base, BaseColumn): __tablename__ = "source_object_attribute_lkup" __table_args__ = {"schema": "process_tracker"} @@ -339,7 +339,7 @@ def __repr__(self): ) -class SourceObjectDatasetType(Base): +class SourceObjectDatasetType(Base, BaseColumn): __tablename__ = "source_object_dataset_type" __table_args__ = {"schema": "process_tracker"} @@ -370,7 +370,7 @@ def __repr__(self): ) -class SourceType(Base): +class SourceType(Base, BaseColumn): __tablename__ = "source_type_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/system.py b/process_tracker/models/system.py index b8d90b8..bca6b2a 100644 --- a/process_tracker/models/system.py +++ b/process_tracker/models/system.py @@ -3,10 +3,10 @@ from sqlalchemy import Column, Integer, Sequence, String -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class System(Base): +class System(Base, BaseColumn): __tablename__ = "system_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/models/tool.py b/process_tracker/models/tool.py index 42c226f..1cc643c 100755 --- a/process_tracker/models/tool.py +++ b/process_tracker/models/tool.py @@ -3,10 +3,10 @@ from sqlalchemy import Column, Integer, Sequence, String -from process_tracker.models.model_base import Base +from process_tracker.models.model_base import Base, BaseColumn -class Tool(Base): +class Tool(Base, BaseColumn): __tablename__ = "tool_lkup" __table_args__ = {"schema": "process_tracker"} diff --git a/process_tracker/utilities/settings.py b/process_tracker/utilities/settings.py index c83a2a0..be5c14c 100644 --- a/process_tracker/utilities/settings.py +++ b/process_tracker/utilities/settings.py @@ -40,10 +40,7 @@ def __init__(self, config_location=None): else: self.config_path = config_location - if ( - "process_tracker_config.ini" not in self.config_path - and ".ini" not in self.config_path - ): + if ".ini" not in self.config_path: self.logger.debug( "process_tracker_config.ini not present. Appending to %s" % self.config_path @@ -59,7 +56,7 @@ def __init__(self, config_location=None): self.logger.debug("Config file is now %s" % self.config_file) else: self.logger.debug( - "process_tracker_config.ini present. Setting config_path to config_file." + "process_tracker config file present in path. Setting config_path to config_file." ) self.config_file = self.config_path From 080ed97f0c1a32b8b823026b7aeb9e0d7d1424d2 Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Thu, 5 Dec 2019 10:17:25 -0500 Subject: [PATCH 2/5] Reverting changes --- process_tracker/utilities/settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/process_tracker/utilities/settings.py b/process_tracker/utilities/settings.py index be5c14c..c83a2a0 100644 --- a/process_tracker/utilities/settings.py +++ b/process_tracker/utilities/settings.py @@ -40,7 +40,10 @@ def __init__(self, config_location=None): else: self.config_path = config_location - if ".ini" not in self.config_path: + if ( + "process_tracker_config.ini" not in self.config_path + and ".ini" not in self.config_path + ): self.logger.debug( "process_tracker_config.ini not present. Appending to %s" % self.config_path @@ -56,7 +59,7 @@ def __init__(self, config_location=None): self.logger.debug("Config file is now %s" % self.config_file) else: self.logger.debug( - "process_tracker config file present in path. Setting config_path to config_file." + "process_tracker_config.ini present. Setting config_path to config_file." ) self.config_file = self.config_path From 842378cfe23afebec4d3cdcbe412072100ca6712 Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Wed, 18 Dec 2019 12:23:34 -0500 Subject: [PATCH 3/5] process_tracker_python-142 Add audit fields to all tables :sparkles: All tables now have basic audit fields enabled Audit fields have been added to all tables. The fields are: created_date_time update_date_time created_by updated_by Closes #142 --- dbscripts/postgresql_process_tracker.sql | 103 +++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/dbscripts/postgresql_process_tracker.sql b/dbscripts/postgresql_process_tracker.sql index 43bdd27..75ea851 100644 --- a/dbscripts/postgresql_process_tracker.sql +++ b/dbscripts/postgresql_process_tracker.sql @@ -921,3 +921,106 @@ create unique index filesize_type_lkup_filesize_type_name_uindex create unique index filesize_type_lkup_udx03 on filesize_type_lkup (filesize_type_code, filesize_type_name); + +CREATE OR REPLACE FUNCTION update_date_time_trigger() + RETURNS TRIGGER AS $$ + BEGIN + NEW."update_date_time" = NOW(); + RETURN NEW; + END; +$$ language 'plpgsql'; + +CREATE TRIGGER actor_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.actor_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER character_set_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.character_set_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER cluster_process_update_date_time_trg BEFORE UPDATE + ON process_tracker.cluster_process FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER cluster_tracking_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.cluster_tracking_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER contact_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.contact_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER data_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.data_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER dataset_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.dataset_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER error_tracking_update_date_time_trg BEFORE UPDATE + ON process_tracker.error_tracking FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER error_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.error_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_compression_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_compression_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_dataset_type_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_dataset_type FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_dependency_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_dependency FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_filetype_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_filetype_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_process_tracking_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_process_tracking FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_source_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_source FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_source_object_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_source_object FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_status_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_status_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER extract_tracking_update_date_time_trg BEFORE UPDATE + ON process_tracker.extract_tracking FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER filesize_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.filesize_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER filter_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.filter_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER location_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.location_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_update_date_time_trg BEFORE UPDATE + ON process_tracker.process FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_contact_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_contact FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_dataset_type_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_dataset_type FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_dependency_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_dependency FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_filter_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_filter FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_source_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_source FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_source_object_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_source_object FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_source_object_attribute_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_source_object_attribute FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_status_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_status_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_target_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_target FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_target_object_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_target_object FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_target_object_attribute_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_target_object_attribute FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_tracking_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_tracking FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER process_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.process_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER schedule_frequency_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.schedule_frequency_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_contact_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_contact FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_dataset_type_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_dataset_type FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_location_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_location FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_object_attribute_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_object_attribute_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_object_dataset_type_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_object_dataset_type FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_object_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_object_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_object_location_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_object_location FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER source_type_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.source_type_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER system_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.system_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); +CREATE TRIGGER tool_lkup_update_date_time_trg BEFORE UPDATE + ON process_tracker.tool_lkup FOR EACH ROW EXECUTE PROCEDURE update_date_time_trigger(); From ff353477929c055893c480e25b430b191e835a14 Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Wed, 18 Dec 2019 12:55:02 -0500 Subject: [PATCH 4/5] process_tracker_python-142 Add audit :sparkles: Added ability to break out record counts by processing type (inserts, updates) Instead of just having an overall total record count for process runs, support is added for breaking out the total count by inserts and updates for a given run. Totals are still available, but this allows for finer understanding of what actually was done during the process run. Closes #143 --- dbscripts/mysql_process_tracker.sql | 194 ++++++++++++++- dbscripts/postgresql_process_tracker.sql | 288 +++++++++++++++++++---- 2 files changed, 433 insertions(+), 49 deletions(-) diff --git a/dbscripts/mysql_process_tracker.sql b/dbscripts/mysql_process_tracker.sql index 2563778..8ed0896 100644 --- a/dbscripts/mysql_process_tracker.sql +++ b/dbscripts/mysql_process_tracker.sql @@ -5,6 +5,10 @@ create table process_tracker.character_set_lkup character_set_id int auto_increment primary key, character_set_name int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint character_set_lkup_character_set_name_uindex unique (character_set_name) ); @@ -14,6 +18,10 @@ create table process_tracker.source_type_lkup source_type_id int auto_increment primary key, source_type_name varchar(75) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_type_lkup_source_type_name_uindex unique (source_type_name) ); @@ -23,6 +31,10 @@ create table schedule_frequency_lkup schedule_frequency_id int auto_increment primary key, schedule_frequency_name varchar(25) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint schedule_frequency_lkup_schedule_frequency_name_uindex unique (schedule_frequency_name) ); @@ -32,6 +44,10 @@ create table data_type_lkup data_type_id int auto_increment primary key, data_type varchar(75) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint data_type_lkup_data_type_uindex unique (data_type) ); @@ -42,6 +58,10 @@ create table contact_lkup primary key, contact_name varchar(250) not null, contact_email varchar(750) null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint contact_lkup_contact_email_uindex unique (contact_email), constraint contact_lkup_contact_name_uindex @@ -52,6 +72,10 @@ create table dataset_type_lkup ( dataset_type_id int auto_increment, dataset_type varchar(250) null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint dataset_type_lkup_pk primary key (dataset_type_id) ) @@ -67,6 +91,10 @@ create table actor_lkup actor_id int auto_increment primary key, actor_name varchar(250) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint actor_name unique (actor_name) ); @@ -79,6 +107,10 @@ create table extract_filetype_lkup delimiter_char char null, quote_char char null, escape_char char null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint extract_filetype_lkup_extract_filetype_uindex unique (extract_filetype) ); @@ -88,6 +120,10 @@ create table extract_compression_type_lkup extract_compression_type_id int auto_increment primary key, extract_compression_type varchar(25) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint extract_compression_type_extract_compression_type_uindex unique (extract_compression_type) ); @@ -97,6 +133,10 @@ create table error_type_lkup error_type_id int auto_increment primary key, error_type_name varchar(250) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint error_type_name unique (error_type_name) ); @@ -106,6 +146,10 @@ create table extract_status_lkup extract_status_id int auto_increment primary key, extract_status_name varchar(75) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint extract_status_name unique (extract_status_name) ); @@ -115,6 +159,10 @@ create table location_type_lkup location_type_id int auto_increment primary key, location_type_name varchar(25) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint location_type_name unique (location_type_name) ); @@ -128,6 +176,10 @@ create table location_lkup location_type_id int null, location_file_count int null, location_bucket_name varchar(750) null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint location_name unique (location_name), constraint location_path @@ -142,6 +194,10 @@ create table process_tracker.filesize_type_lkup primary key, filesize_type_name varchar(75) not null, filesize_type_code char(2) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint filesize_type_lkup_filesize_type_code_uindex unique (filesize_type_code), constraint filesize_type_lkup_filesize_type_name_uindex @@ -168,6 +224,10 @@ create table extract_tracking extract_filetype_id int null, extract_filesize numeric null, extract_filesize_type_id int null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint extract_filename unique (extract_filename), constraint extract_tracking_fk03 @@ -193,6 +253,10 @@ create table process_tracker.extract_dependency ( parent_extract_id int not null, child_extract_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (parent_extract_id, child_extract_id), constraint extract_dependency_fk01 foreign key (parent_extract_id) references extract_tracking (extract_id), @@ -206,6 +270,10 @@ create table process_status_lkup process_status_id int auto_increment primary key, process_status_name varchar(75) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_status_name unique (process_status_name) ); @@ -214,7 +282,11 @@ create table process_type_lkup ( process_type_id int auto_increment primary key, - process_type_name varchar(250) not null + process_type_name varchar(250) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, ); create table process_tracker.source_lkup @@ -224,6 +296,10 @@ create table process_tracker.source_lkup source_name varchar(250) not null, source_type_id int default 1 not null , character_set_id int null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_name unique (source_name), constraint source_lkup_fk01 @@ -240,6 +316,10 @@ create table system_lkup primary key, system_key varchar(250) not null, system_value varchar(250) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint system_key unique (system_key) ); @@ -249,6 +329,10 @@ create table tool_lkup tool_id int auto_increment primary key, tool_name varchar(250) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint tool_name unique (tool_name) ); @@ -265,6 +349,10 @@ create table process schedule_frequency_id int default 0 not null, last_completed_run_date_time datetime not null, last_errored_run_date_time datetime not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_name unique (process_name), constraint process_fk03 @@ -285,6 +373,10 @@ create table process_dependency ( parent_process_id int not null, child_process_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (parent_process_id, child_process_id), constraint process_dependency_ibfk_1 foreign key (parent_process_id) references process (process_id), @@ -299,6 +391,10 @@ create table process_source ( source_id int not null, process_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (source_id, process_id), constraint process_source_ibfk_1 foreign key (source_id) references source_lkup (source_id), @@ -313,6 +409,10 @@ create table process_target ( target_source_id int not null, process_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (target_source_id, process_id), constraint process_target_ibfk_1 foreign key (target_source_id) references source_lkup (source_id), @@ -340,6 +440,10 @@ create table process_tracking process_run_name varchar(250) null, process_run_insert_count int default 0 not null, process_run_update_count int default 0 not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_tracking_process_run_name_uindex unique (process_run_name), constraint process_tracking_ibfk_1 @@ -360,6 +464,10 @@ create table error_tracking error_description varchar(750) null, error_occurrence_date_time datetime not null, process_tracking_id int null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint error_tracking_ibfk_1 foreign key (error_type_id) references error_type_lkup (error_type_id), constraint error_tracking_ibfk_2 @@ -378,6 +486,10 @@ create table extract_process_tracking process_tracking_id int not null, extract_process_status_id int null, extract_process_event_date_time datetime(6) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (extract_tracking_id, process_tracking_id), constraint extract_process_tracking_ibfk_1 foreign key (extract_tracking_id) references extract_tracking (extract_id), @@ -413,6 +525,10 @@ create table process_tracker.cluster_tracking_lkup cluster_max_processing_unit varchar(3) null, cluster_current_memory_usage int null, cluster_current_process_usage int null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint cluster_tracking_cluster_name_uindex unique (cluster_name) ) @@ -422,6 +538,10 @@ create table process_tracker.cluster_process ( cluster_id int not null, process_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (cluster_id, process_id), constraint cluster_process_fk01 foreign key (cluster_id) references process_tracker.cluster_tracking_lkup (cluster_id), @@ -437,6 +557,10 @@ create table process_tracker.source_object_lkup source_id int not null, source_object_name varchar(250) null, character_set_id int null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_object_lkup_udx01 unique (source_id, source_object_name), constraint source_object_lkup_fk02 @@ -449,6 +573,10 @@ create table process_tracker.process_target_object ( process_id int not null, target_object_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_target_object_pk primary key (process_id, target_object_id), constraint process_target_object_fk01 @@ -461,6 +589,10 @@ create table process_tracker.process_source_object ( process_id int not null, source_object_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_source_object_pk primary key (process_id, source_object_id), constraint process_source_object_fk01 @@ -473,6 +605,10 @@ create table source_dataset_type ( source_id int not null, dataset_type_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_dataset_type_pk primary key (source_id, dataset_type_id), constraint source_dataset_type_fk01 @@ -486,6 +622,10 @@ create table source_object_dataset_type ( source_object_id int not null, dataset_type_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_object_dataset_type_pk primary key (source_object_id, dataset_type_id), constraint source_object_dataset_type_fk01 @@ -499,6 +639,10 @@ create table extract_dataset_type ( extract_id int not null, dataset_type_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint extract_dataset_type_pk primary key (extract_id, dataset_type_id), constraint extract_dataset_type_fk01 @@ -512,6 +656,10 @@ create table process_dataset_type ( process_id int not null, dataset_type_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_dataset_type_pk primary key (process_id, dataset_type_id), constraint process_dataset_type_fk01 @@ -525,6 +673,10 @@ create table source_contact ( source_id int not null, contact_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (source_id, contact_id), constraint source_contact_fk01 foreign key (source_id) references source_lkup (source_id), @@ -536,6 +688,10 @@ create table process_contact ( process_id int not null, contact_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (process_id, contact_id), constraint process_contact_fk01 foreign key (process_id) references process (process_id), @@ -559,6 +715,10 @@ create table source_object_attribute_lkup is_key boolean default FALSE not null, is_filter boolean default FALSE not null, is_partition boolean default FALSE not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint source_object_attribute_lkup_udx01 unique (source_object_id, source_object_attribute_name), constraint source_object_attribute_lkup_fk01 @@ -573,6 +733,10 @@ create table process_source_object_attribute source_object_attribute_id int not null, source_object_attribute_alias varchar(250) null, source_object_attribute_expression varchar(250) null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (process_id, source_object_attribute_id), constraint process_source_object_attribute_fk01 foreign key (process_id) references process (process_id), @@ -586,6 +750,10 @@ create table if not exists process_target_object_attribute target_object_attribute_id int not null, target_object_attribute_alias varchar(250) null, target_object_attribute_expression varchar(250) null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (process_id, target_object_attribute_id), constraint process_target_object_attribute_fk01 foreign key (process_id) references process (process_id), @@ -599,6 +767,10 @@ create table filter_type_lkup primary key, filter_type_code varchar(3) not null, filter_type_name varchar(75) not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint filter_type_lkup_filter_type_code_uindex unique (filter_type_code), constraint filter_type_lkup_filter_type_name_uindex @@ -614,6 +786,10 @@ create table process_filter filter_type_id int not null, filter_value_string varchar(250) null, filter_value_numeric decimal null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, constraint process_filter_udx unique (process_id, source_object_attribute_id, filter_type_id), constraint process_filter_fk01 @@ -628,6 +804,10 @@ create table process_tracker.extract_source ( extract_id int not null, source_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (extract_id, source_id), constraint extract_source_fk01 foreign key (extract_id) references process_tracker.extract_tracking (extract_id), @@ -639,6 +819,10 @@ create table process_tracker.extract_source_object ( extract_id int not null, source_object_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (extract_id, source_object_id), constraint extract_source_object_fk01 foreign key (extract_id) references process_tracker.extract_tracking (extract_id), @@ -650,6 +834,10 @@ create table process_tracker.source_location ( source_id int not null, location_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (source_id, location_id), constraint source_location_fk01 foreign key (source_id) references process_tracker.source_lkup (source_id), @@ -661,6 +849,10 @@ create table process_tracker.source_object_location ( source_object_id int not null, location_id int not null, + created_date_time timestamp default CURRENT_TIMESTAMP not null, + created_by int default 0 not null, + update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, + updated_by int default 0 not null, primary key (source_object_id, location_id), constraint source_object_location_fk01 foreign key (source_object_id) references process_tracker.source_object_lkup (source_object_id), diff --git a/dbscripts/postgresql_process_tracker.sql b/dbscripts/postgresql_process_tracker.sql index 75ea851..c004e97 100644 --- a/dbscripts/postgresql_process_tracker.sql +++ b/dbscripts/postgresql_process_tracker.sql @@ -12,7 +12,11 @@ create table dataset_type_lkup dataset_type_id serial not null constraint dataset_type_lkup_pk primary key, - dataset_type varchar(250) + dataset_type varchar(250), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table dataset_type_lkup is 'High level of dataset type categories'; @@ -27,7 +31,11 @@ create table error_type_lkup error_type_id serial not null constraint error_type_lkup_pk primary key, - error_type_name varchar(250) not null + error_type_name varchar(250) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table error_type_lkup is 'Types of errors that are being tracked.'; @@ -47,7 +55,11 @@ create table error_tracking error_type_id integer not null, process_tracking_id integer not null, error_description varchar(750), - error_occurrence_date_time timestamp not null + error_occurrence_date_time timestamp not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table error_tracking is 'Tracking of process errors'; @@ -68,7 +80,11 @@ create table tool_lkup tool_id serial not null constraint tool_lkup_pk primary key, - tool_name varchar(250) not null + tool_name varchar(250) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table tool_lkup is 'List of tools that are used to run processes'; @@ -83,7 +99,11 @@ create table process_status_lkup process_status_id serial not null constraint process_status_lkup_pk primary key, - process_status_name varchar(75) not null + process_status_name varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_status_lkup is 'Process status states'; @@ -98,7 +118,11 @@ create table process_type_lkup process_type_id serial not null constraint process_type_lkup_pk primary key, - process_type_name varchar(250) not null + process_type_name varchar(250) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_type_lkup is 'Valid process types for processes'; @@ -115,7 +139,11 @@ create table actor_lkup actor_id serial not null constraint actor_lkup_pk primary key, - actor_name varchar(250) not null + actor_name varchar(250) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table actor_lkup is 'List of developers or applications that can run processes.'; @@ -130,7 +158,11 @@ create table extract_status_lkup extract_status_id serial not null constraint extract_status_lkup_pk primary key, - extract_status_name varchar(75) not null + extract_status_name varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table extract_status_lkup is 'List of valid extract processing statuses.'; @@ -145,7 +177,11 @@ create table location_type_lkup location_type_id serial not null constraint location_type_lkup_pk primary key, - location_type_name varchar(25) not null + location_type_name varchar(25) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table location_type_lkup is 'Listing of location types'; @@ -166,7 +202,11 @@ create table location_lkup constraint location_lkup_fk01 references location_type_lkup, location_file_count integer, - location_bucket_name varchar(750) + location_bucket_name varchar(750), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table location_lkup is 'Locations where files are located.'; @@ -185,7 +225,11 @@ create table system_lkup constraint system_lkup_pk primary key, system_key varchar(250) not null, - system_value varchar(250) not null + system_value varchar(250) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table system_lkup is 'ProcessTracker system information'; @@ -206,7 +250,11 @@ create table cluster_tracking_lkup cluster_max_processing integer, cluster_max_processing_unit varchar(3), cluster_current_memory_usage integer, - cluster_current_process_usage integer + cluster_current_process_usage integer, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table cluster_tracking_lkup is 'Capacity cluster tracking'; @@ -222,7 +270,11 @@ create table contact_lkup constraint contact_lkup_pk primary key, contact_name varchar(250) not null, - contact_email varchar(750) + contact_email varchar(750), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table contact_lkup owner to pt_admin; @@ -238,7 +290,11 @@ create table extract_compression_type_lkup extract_compression_type_id serial not null constraint extract_compression_type_lkup_pk primary key, - extract_compression_type varchar(25) not null + extract_compression_type varchar(25) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table extract_compression_type_lkup owner to pt_admin; @@ -255,7 +311,11 @@ create table extract_filetype_lkup extract_filetype varchar(75) not null, delimiter_char char, quote_char char, - escape_char char + escape_char char, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table extract_filetype_lkup owner to pt_admin; @@ -268,7 +328,11 @@ create table data_type_lkup data_type_id serial not null constraint data_type_lkup_pk primary key, - data_type varchar(75) not null + data_type varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table data_type_lkup owner to pt_admin; @@ -281,7 +345,11 @@ create table schedule_frequency_lkup schedule_frequency_id serial not null constraint schedule_frequency_lkup_pk primary key, - schedule_frequency_name varchar(25) not null + schedule_frequency_name varchar(25) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table schedule_frequency_lkup owner to pt_admin; @@ -304,7 +372,11 @@ create table process constraint process_fk04 references schedule_frequency_lkup, last_completed_run_date_time timestamp default '1900-01-01 00:00:00'::timestamp without time zone not null, - last_errored_run_date_time timestamp default '1900-01-01 00:00:00'::timestamp without time zone not null + last_errored_run_date_time timestamp default '1900-01-01 00:00:00'::timestamp without time zone not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process is 'Processes being tracked'; @@ -333,7 +405,11 @@ create table process_dependency constraint process_dependency_fk02 references process, constraint process_dependency_pk - primary key (child_process_id, parent_process_id) + primary key (child_process_id, parent_process_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_dependency is 'Dependency tracking between processes.'; @@ -367,7 +443,11 @@ create table process_tracking is_latest_run boolean default false, process_run_name varchar(250) null, process_run_insert_count int default 0 not null, - process_run_update_count int default 0 not null + process_run_update_count int default 0 not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_tracking is 'Tracking table of process runs.'; @@ -415,7 +495,11 @@ create table cluster_process constraint cluster_process_fk02 references process, constraint cluster_process_pk - primary key (cluster_id, process_id) + primary key (cluster_id, process_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table cluster_process is 'Relationship tracking between processes and performance clusters.'; @@ -431,7 +515,11 @@ create table process_dataset_type constraint process_dataset_type_fk02 references dataset_type_lkup, constraint process_dataset_type_pk - primary key (process_id, dataset_type_id) + primary key (process_id, dataset_type_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_dataset_type is 'Relationship between process and dataset type'; @@ -447,7 +535,11 @@ create table process_contact constraint process_contact_fk02 references contact_lkup, constraint process_contact_pk - primary key (process_id, contact_id) + primary key (process_id, contact_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table process_contact owner to pt_admin; @@ -461,7 +553,11 @@ create table filter_type_lkup constraint filter_type_lkup_pk primary key, filter_type_code varchar(3) not null, - filter_type_name varchar(75) not null + filter_type_name varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table filter_type_lkup owner to pt_admin; @@ -477,7 +573,11 @@ create table source_type_lkup source_type_id serial not null constraint source_type_lkup_pk primary key, - source_type_name varchar(75) not null + source_type_name varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table source_type_lkup owner to pt_admin; @@ -490,7 +590,11 @@ create table character_set_lkup character_set_id serial not null constraint character_set_lkup_pk primary key, - character_set_name varchar(75) not null + character_set_name varchar(75) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table character_set_lkup owner to pt_admin; @@ -506,7 +610,11 @@ create table source_lkup references source_type_lkup, character_set_id integer constraint source_lkup_fk02 - references character_set_lkup + references character_set_lkup, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table source_lkup is 'Source system where data originates.'; @@ -525,7 +633,11 @@ create table process_source constraint process_source_fk02 references process, constraint process_source_pk - primary key (source_id, process_id) + primary key (source_id, process_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_source is 'List of sources for given processes'; @@ -541,7 +653,11 @@ create table process_target constraint process_target_fk02 references process, constraint process_target_pk - primary key (target_source_id, process_id) + primary key (target_source_id, process_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_target is 'List of targets for given processes'; @@ -559,7 +675,11 @@ create table source_object_lkup source_object_name varchar(250), character_set_id integer constraint source_object_lkup_fk02 - references character_set_lkup + references character_set_lkup, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table source_object_lkup is 'Reference table for source/target objects.'; @@ -578,7 +698,11 @@ create table process_target_object constraint process_target_object_fk02 references source_object_lkup, constraint process_target_object_pk - primary key (process_id, target_object_id) + primary key (process_id, target_object_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_target_object is 'Relationship between processes and target objects'; @@ -594,7 +718,11 @@ create table process_source_object constraint process_source_object_fk02 references source_object_lkup, constraint process_source_object_pk - primary key (process_id, source_object_id) + primary key (process_id, source_object_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table process_source_object is 'Relationship between processes and source objects'; @@ -610,7 +738,11 @@ create table source_dataset_type constraint source_dataset_type_fk02 references dataset_type_lkup, constraint source_dataset_type_pk - primary key (source_id, dataset_type_id) + primary key (source_id, dataset_type_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table source_dataset_type is 'Relationship between source and dataset type'; @@ -626,7 +758,11 @@ create table source_object_dataset_type constraint source_object_dataset_type_fk02 references dataset_type_lkup, constraint source_object_dataset_type_pk - primary key (source_object_id, dataset_type_id) + primary key (source_object_id, dataset_type_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table source_object_dataset_type is 'Relationship between source object and dataset type'; @@ -642,7 +778,11 @@ create table source_contact constraint source_contact_fk02 references contact_lkup, constraint source_contact_pk - primary key (source_id, contact_id) + primary key (source_id, contact_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table source_contact owner to pt_admin; @@ -667,7 +807,11 @@ create table source_object_attribute_lkup default_value_number numeric, is_key boolean default false not null, is_filter boolean default false not null, - is_partition boolean default false not null + is_partition boolean default false not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table source_object_attribute_lkup owner to pt_admin; @@ -686,7 +830,11 @@ create table process_source_object_attribute source_object_attribute_alias varchar(250), source_object_attribute_expression varchar(250), constraint process_source_object_attribute_pk - primary key (process_id, source_object_attribute_id) + primary key (process_id, source_object_attribute_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table process_source_object_attribute owner to pt_admin; @@ -702,7 +850,11 @@ create table process_target_object_attribute target_object_attribute_alias varchar(250), target_object_attribute_expression varchar(250), constraint process_target_object_attribute_pk - primary key (process_id, target_object_attribute_id) + primary key (process_id, target_object_attribute_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table process_target_object_attribute owner to pt_admin; @@ -722,7 +874,11 @@ create table process_filter constraint process_filter_fk03 references filter_type_lkup, filter_value_string varchar(250), - filter_value_numeric numeric + filter_value_numeric numeric, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table process_filter owner to pt_admin; @@ -739,7 +895,11 @@ create table source_location constraint source_location_fk02 references location_lkup, constraint source_location_pk - primary key (source_id, location_id) + primary key (source_id, location_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table source_location owner to pt_admin; @@ -753,7 +913,11 @@ create table source_object_location constraint source_object_location_fk02 references location_lkup, constraint source_object_location_pk - primary key (source_object_id, location_id) + primary key (source_object_id, location_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table source_object_location owner to pt_admin; @@ -767,7 +931,11 @@ create table filesize_type_lkup constraint filesize_type_lkup_pk primary key, filesize_type_name varchar(75) not null, - filesize_type_code char(2) not null + filesize_type_code char(2) not null, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table filesize_type_lkup owner to pt_admin; @@ -803,7 +971,11 @@ create table extract_tracking extract_filesize numeric, extract_filesize_type_id integer constraint extract_tracking_fk06 - references filesize_type_lkup + references filesize_type_lkup, + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table extract_tracking is 'Tracking table for all extract/staging data files.'; @@ -845,7 +1017,11 @@ create table extract_process_tracking constraint extract_process_tracking_fk03 references extract_status_lkup, constraint extract_process_tracking_pk - primary key (process_tracking_id, extract_tracking_id) + primary key (process_tracking_id, extract_tracking_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table extract_process_tracking is 'Showing which processes have impacted which extracts'; @@ -861,7 +1037,11 @@ create table extract_dependency constraint extract_dependency_fk02 references extract_tracking, constraint extract_dependency_pk - primary key (parent_extract_id, child_extract_id) + primary key (parent_extract_id, child_extract_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table extract_dependency is 'Table tracking interdependencies between extract files.'; @@ -877,7 +1057,11 @@ create table extract_dataset_type constraint extract_dataset_type_fk02 references dataset_type_lkup, constraint extract_dataset_type_pk - primary key (extract_id, dataset_type_id) + primary key (extract_id, dataset_type_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); comment on table extract_dataset_type is 'Relationship between extract file and dataset type'; @@ -893,7 +1077,11 @@ create table extract_source constraint extract_source_fk01 references source_lkup, constraint extract_source_pk - primary key (extract_id, source_id) + primary key (extract_id, source_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table extract_source owner to pt_admin; @@ -907,7 +1095,11 @@ create table extract_source_object constraint extract_source_object_fk02 references source_object_lkup, constraint extract_source_object_pk - primary key (extract_id, source_object_id) + primary key (extract_id, source_object_id), + created_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + created_by integer default 0 not null, + update_date_time timestamp with time zone default CURRENT_TIMESTAMP not null, + updated_by integer default 0 not null ); alter table extract_source_object owner to pt_admin; From c8a08fe9caa74402f210ff34cd54622aed1da8ee Mon Sep 17 00:00:00 2001 From: Alex Meadows Date: Wed, 18 Dec 2019 12:57:41 -0500 Subject: [PATCH 5/5] process_tracker_python-142 Add audit fields to all tables :sparkles: All tables now have basic audit fields enabled Audit fields have been added to all tables. The fields are: created_date_time update_date_time created_by updated_by Closes #142 --- dbscripts/mysql_process_tracker.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbscripts/mysql_process_tracker.sql b/dbscripts/mysql_process_tracker.sql index 8ed0896..d353f11 100644 --- a/dbscripts/mysql_process_tracker.sql +++ b/dbscripts/mysql_process_tracker.sql @@ -286,7 +286,7 @@ create table process_type_lkup created_date_time timestamp default CURRENT_TIMESTAMP not null, created_by int default 0 not null, update_date_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP not null, - updated_by int default 0 not null, + updated_by int default 0 not null ); create table process_tracker.source_lkup