Commit 40c3d3bf authored by Micaël Bergeron's avatar Micaël Bergeron

make missing fields a warning

parent c4705ef5
......@@ -60,6 +60,7 @@ class SchemaError(Error):
"""Base exception for schema errors."""
@aggregate
class InapplicableChangeError(SchemaError):
"""Raise for inapplicable schema changes."""
......@@ -96,7 +97,7 @@ class ExceptionAggregator:
aggregate_type = self.etype.Aggregate
if len(self.failures):
exceptions = map(lambda f: f[0], self.failures)
exceptions = [f[0] for f in self.failures]
raise aggregate_type(exceptions)
......@@ -106,10 +107,10 @@ def with_error_exit_code(main):
try:
main(*args, **kwargs)
except Error as err:
logging.error(err)
logging.error(str(err))
exit(err.exit_code())
except Exception as e:
logging.error(e)
logging.error(str(e))
raise e
return f
......@@ -6,7 +6,7 @@ import psycopg2.extras
from typing import Sequence, Callable, Set
from enum import Enum
from collections import OrderedDict, namedtuple
from elt.error import ExceptionAggregator, InapplicableChangeError
from elt.error import ExceptionAggregator, SchemaError, InapplicableChangeError
class DBType(str, Enum):
......@@ -95,6 +95,12 @@ class Schema:
return {SchemaDiff.COLUMN_OK}
def __getitem__(self, column_key):
try:
return self.columns[column_key]
except KeyError as e:
raise SchemaError("{}.{} is missing.".format(*column_key))
def db_schema(db_conn, schema_name) -> Schema:
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment