qwazer / scheme2ddl

Command line util for export oracle schema to set of ddl scripts
82 stars 47 forks source link

CREATE (UNIQUE) INDEX statement in table files are not sorted #44

Closed yvesf closed 6 years ago

yvesf commented 8 years ago

Between two exports the ordering of the index statements on a table can vary. This creates annoying diffs if you use git on these files. I think it would be beneficial to explicitly sort the the dependent objects by name or so.

dvsidamore commented 6 years ago

I have same problem. Does anybody solved it?

image

qwazer commented 6 years ago

@dvsidamore I'll try to fix in near future (probably, on weekend). Thanks for reminding.

qwazer commented 6 years ago

The root cause: DBMS_METADATA.GET_DEPENDENT_DDL return CREATE (UNIQUE|BITMAP)? INDEX statements sorted by creation date. I decided to parse DBMS_METADATA.GET_DEPENDENT_DDL on separateCREATE (UNIQUE|BITMAP)? INDEX statements and sort these alphanumerically in DDLFormatter class.

So order for 3 indexes UNIQUE INDEX a, INDEX b , BITMAP INDEX c will be:

CREATE BITMAP INDEX c...
CREATE INDEX b ..
CREATE UNIQUE INDEX a..

Fixed in PR #53 New parameter of DDLFormatter sortCreateIndexStatements with default value true added.

qwazer commented 6 years ago

fixed in v2.4.2

qwazer commented 6 years ago

After implementing this, I found, that possibly it should be implemented in other way as proposed in https://github.com/qwazer/scheme2ddl/issues/20#issuecomment-83579410

dvsidamore commented 6 years ago

thanks a lot!