diff --git a/tools/python/jwutils/db/schema/utils.py b/tools/python/jwutils/db/schema/utils.py new file mode 100644 index 0000000..65b3e89 --- /dev/null +++ b/tools/python/jwutils/db/schema/utils.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from .Schema import Schema + +from jwutils.log import * + +def check_schema(schema: Schema): # export + slog(NOTICE, f'There are {len(schema)} tables in the database') + for cfk in schema.foreign_key_constraints: + for fk in cfk: + if fk.child_column.data_type != fk.parent_column.data_type: + raise Exception(f'Type mismatch in foreign key {fk}: {fk.child_column.data_type} != {fk.parent_column.data_type}')