mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
schema: Add utils
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c50c614f13
commit
fb907b0493
1 changed files with 12 additions and 0 deletions
12
tools/python/jwutils/db/schema/utils.py
Normal file
12
tools/python/jwutils/db/schema/utils.py
Normal file
|
|
@ -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}')
|
||||||
Loading…
Add table
Add a link
Reference in a new issue