Hello dear community
This is my first-time test with dbdocs, i am trying to document our long-time DB and thought about using the “db2dbml” utility.
When i run it immediately i receive an error saying that a field cannot be found.
this is the command:
(node:49145) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ Connecting to database... done.
✖ Generating DBML ...
› Error: Error: Can't find field "advertiser"."account_category_id" in table "account_custom_category_details"
Can someone please assist why is this happening or what am i doing wrong?
Thanks
Boaz
Thank you for reaching out to us.
I am Huy Phung from the dbdocs and dbdiagram team.
To investigate the issue you are facing, it would be nice if you could help us to run the below query inside your database console and share the result with us via our support email: dbdocs@holistics.io.
WITH comments AS (
SELECT DISTINCT ON (pc.relname, pn.nspname, pa.attname)
pc.relname AS table_name,
pn.nspname AS table_schema,
pa.attname AS column_name,
pd.description
FROM
pg_description pd
JOIN
pg_class pc ON pd.objoid = pc.oid
JOIN
pg_namespace pn ON pc.relnamespace = pn.oid
LEFT JOIN
pg_attribute pa ON pd.objoid = pa.attrelid AND pd.objsubid = pa.attnum
WHERE
pc.relkind = 'r'
AND pn.nspname NOT IN ('pg_catalog', 'information_schema')
)
SELECT
t.table_schema,
t.table_name,
c.column_name,
c.data_type,
c.character_maximum_length,
c.numeric_precision,
c.numeric_scale,
c.udt_schema,
c.udt_name,
c.identity_increment,
c.is_nullable,
c.column_default,
c.ordinal_position,
CASE
WHEN c.column_default IS NULL THEN NULL
WHEN c.column_default LIKE 'nextval(%' THEN 'increment'
WHEN c.column_default LIKE '''%' THEN 'string'
WHEN c.column_default = 'true' OR c.column_default = 'false' THEN 'boolean'
WHEN c.column_default ~ '^-?[0-9]+(.[0-9]+)?$' THEN 'number'
ELSE 'expression'
END AS default_type,
(SELECT description FROM comments WHERE table_name = t.table_name AND table_schema = t.table_schema AND column_name IS NULL LIMIT 1) AS table_comment,
(SELECT description FROM comments WHERE table_name = t.table_name AND table_schema = t.table_schema AND column_name = c.column_name LIMIT 1) AS column_comment
FROM
information_schema.columns c
JOIN
information_schema.tables t ON c.table_name = t.table_name AND c.table_schema = t.table_schema
WHERE
t.table_type = 'BASE TABLE'
AND t.table_schema NOT IN ('pg_catalog', 'information_schema')
ORDER BY
t.table_schema,
t.table_name,
c.ordinal_position
;