model legacy { version "0.9" description "Inherited schema with inconsistent names and missing keys." } naming { entity { case snake } table { case snake } column { case snake } } lint { reserved-word warn } classification pii { level "none" level "indirect" level "direct" inherit } entity "CUSTOMER MASTER" { description "Customer master data, as inherited." attribute CUST_ID : bigint not null attribute CUST_NAME : text(60) attribute "ship to" : text(200) key primary pk_cust (CUST_ID) } entity "Order Items" { description "Order lines; never had a primary key." attribute OrderID : bigint not null classify pii "none" attribute ItemNo : integer not null attribute Qty : integer attribute from : date } entity audit_log { description "Append-only log; related to nothing." attribute id : bigint not null attribute happened_at : timestamp not null attribute message : text key primary pk_audit_log (id) } entity tbl_Orders { attribute OrderID : bigint not null classify pii "direct" attribute CustomerID : integer not null attribute CreatedBy : bigint attribute OrderDate : date key primary pk_tbl_orders (OrderID) } entity user { attribute id : bigint not null attribute login : text(50) not null key primary pk_user (id) } relationship items_order { parent tbl_Orders child "Order Items" columns (OrderID -> OrderID) cardinality one to many } relationship orders_customer { description "Customer id types differ between the tables." parent "CUSTOMER MASTER" child tbl_Orders columns (CustomerID -> CUST_ID) cardinality zero_or_one to many } relationship orders_user { parent user child tbl_Orders columns (CreatedBy -> id) cardinality zero_or_one to many } area "Legacy Core" { entity "CUSTOMER MASTER" entity "Order Items" entity tbl_Orders entity user } target pg : postgresql { schema legacy { table "CUSTOMER MASTER" { entity "CUSTOMER MASTER" column CUST_ID bigint not null attribute CUST_ID column CUST_NAME varchar(60) attribute CUST_NAME column "ship to" varchar(200) attribute "ship to" primary key pk_cust (CUST_ID) } table "Order Items" { entity "Order Items" column OrderID bigint not null attribute OrderID column ItemNo integer not null attribute ItemNo column Qty integer attribute Qty column from date attribute from foreign key fk_items_order (OrderID) references tbl_Orders (OrderID) relationship items_order } table audit_log { entity audit_log column id bigint not null identity always attribute id column happened_at timestamp not null attribute happened_at column message text attribute message primary key pk_audit_log (id) } table tbl_Orders { entity tbl_Orders column OrderID bigint not null attribute OrderID column CustomerID integer not null attribute CustomerID column CreatedBy bigint attribute CreatedBy column OrderDate date attribute OrderDate primary key pk_tbl_orders (OrderID) foreign key fk_orders_customer (CustomerID) references "CUSTOMER MASTER" (CUST_ID) relationship orders_customer foreign key fk_orders_user (CreatedBy) references user (id) relationship orders_user index ix_orders_user (CreatedBy) } table user { entity user column id bigint not null identity always attribute id column login varchar(50) not null attribute login primary key pk_user (id) } } }