Difference between revisions of "Database structure"
From iDempiere en
CarlosRuiz (talk | contribs) (IDEMPIERE-6592) |
|||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 4: | Line 4: | ||
* [http://hsharp.software/idempiere-db/ this SchemaSpy analysis of an iDempiere database] generated on 2017-12-21. <small>([https://github.com/hsharpsoftware/idempiere-db The generated database structure source code is on GitHub.])</small> | * [http://hsharp.software/idempiere-db/ this SchemaSpy analysis of an iDempiere database] generated on 2017-12-21. <small>([https://github.com/hsharpsoftware/idempiere-db The generated database structure source code is on GitHub.])</small> | ||
| − | |||
| + | This is made by schemaspy,you can made it by yourself,but it has some different, it is group by idempiere domain knowledge. See [[Tables by Module]] | ||
| + | |||
| + | You can fill the comments on postgresql database executing the following code: | ||
| + | <syntaxhighlight lang="SQL"> | ||
| + | DO $$ | ||
| + | DECLARE | ||
| + | rec RECORD; | ||
| + | cmd varchar; | ||
| + | BEGIN | ||
| + | FOR rec IN | ||
| + | SELECT t.TableName, | ||
| + | CASE WHEN t.IsView='Y' THEN 'VIEW' ELSE 'TABLE' END AS ObjectType, | ||
| + | COALESCE(t.Description,t.Name) AS Description | ||
| + | FROM AD_Table t | ||
| + | WHERE t.IsActive='Y' | ||
| + | ORDER BY 1 | ||
| + | LOOP | ||
| + | cmd := 'COMMENT ON ' || rec.ObjectType || ' ' || rec.TableName || ' IS ''' || | ||
| + | REPLACE(rec.Description,'''', '''''') || ''''; | ||
| + | RAISE NOTICE '%', cmd; | ||
| + | EXECUTE cmd; | ||
| + | END LOOP; | ||
| + | FOR rec IN | ||
| + | SELECT t.TableName, | ||
| + | c.ColumnName, | ||
| + | COALESCE(c.Description,c.Name) AS Description | ||
| + | FROM AD_Table t JOIN AD_Column c ON (c.AD_Table_ID=t.AD_Table_ID) | ||
| + | WHERE t.IsActive='Y' AND c.IsActive='Y' AND c.ColumnSQL IS NULL | ||
| + | ORDER BY 1,2 | ||
| + | LOOP | ||
| + | cmd := 'COMMENT ON COLUMN '|| rec.TableName || '.' || rec.ColumnName || ' IS ''' || | ||
| + | REPLACE(rec.Description,'''', '''''') || ''''; | ||
| + | RAISE NOTICE '%', cmd; | ||
| + | EXECUTE cmd; | ||
| + | END LOOP; | ||
| + | END $$; | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | if SQL Error [42809]: ERROR: "t_spool" is not a view , set it is table. NOTE: this was solved with [https://idempiere.atlassian.net/browse/IDEMPIERE-6592 IDEMPIERE-6592] | ||
| + | |||
| + | <syntaxhighlight lang="sql"> | ||
| + | update ad_table set IsView ='N' where tablename ='T_Spool' | ||
| + | </syntaxhighlight>command<syntaxhighlight lang="bash"> | ||
| + | java -jar schemaspy-6.2.4.jar -t pgsql -dp postgresql-42.7.6.jar -db idempiere -host localhost -port 5432 -u adempiere -p adempiere -s adempiere -noimplied -o D://output | ||
| + | </syntaxhighlight>[https://github.com/schemaspy/schemaspy?tab=readme-ov-file schemaspy github] | ||
| + | |||
| + | [https://schemaspygui.sourceforge.net/index.html#installation schemaspy GUI] | ||
| + | [[File:Image.png|thumb]] | ||
| + | [[File:Schema gui step2.png|thumb]] | ||
[[Category:Development]] | [[Category:Development]] | ||
Latest revision as of 11:49, 27 June 2025
See the database structure in
- this SchemaSpy analysis of an iDempiere database generated on 2023-12-24
- this SchemaSpy analysis of an iDempiere database generated on 2019-07-09
- this SchemaSpy analysis of an iDempiere database generated on 2017-12-21. (The generated database structure source code is on GitHub.)
This is made by schemaspy,you can made it by yourself,but it has some different, it is group by idempiere domain knowledge. See Tables by Module
You can fill the comments on postgresql database executing the following code:
DO $$
DECLARE
rec RECORD;
cmd varchar;
BEGIN
FOR rec IN
SELECT t.TableName,
CASE WHEN t.IsView='Y' THEN 'VIEW' ELSE 'TABLE' END AS ObjectType,
COALESCE(t.Description,t.Name) AS Description
FROM AD_Table t
WHERE t.IsActive='Y'
ORDER BY 1
LOOP
cmd := 'COMMENT ON ' || rec.ObjectType || ' ' || rec.TableName || ' IS ''' ||
REPLACE(rec.Description,'''', '''''') || '''';
RAISE NOTICE '%', cmd;
EXECUTE cmd;
END LOOP;
FOR rec IN
SELECT t.TableName,
c.ColumnName,
COALESCE(c.Description,c.Name) AS Description
FROM AD_Table t JOIN AD_Column c ON (c.AD_Table_ID=t.AD_Table_ID)
WHERE t.IsActive='Y' AND c.IsActive='Y' AND c.ColumnSQL IS NULL
ORDER BY 1,2
LOOP
cmd := 'COMMENT ON COLUMN '|| rec.TableName || '.' || rec.ColumnName || ' IS ''' ||
REPLACE(rec.Description,'''', '''''') || '''';
RAISE NOTICE '%', cmd;
EXECUTE cmd;
END LOOP;
END $$;
if SQL Error [42809]: ERROR: "t_spool" is not a view , set it is table. NOTE: this was solved with IDEMPIERE-6592
update ad_table set IsView ='N' where tablename ='T_Spool'
command
java -jar schemaspy-6.2.4.jar -t pgsql -dp postgresql-42.7.6.jar -db idempiere -host localhost -port 5432 -u adempiere -p adempiere -s adempiere -noimplied -o D://output
