mt-ag / quasto

a project for checking guidelines and code quality for oracle databases
MIT License
9 stars 2 forks source link

export and import rules #10

Closed OliverLemm closed 5 months ago

OliverLemm commented 2 years ago

for easier export and importing rules the standalone plsql function fc_export_qa_rules has to be rewritten and integrated into an export_import_rules_pkg.

the primary key and the audit columns must be excluded inside the export/import file.

a merge statement based on the columns qaru_rule_number and qaru_client_name has to be used for export and import as unique identifier the sql statement should be seperated from the statement for easier reading.

it should be evaluated whether the metadata for the rules and the import/export logik should be divided

ThisGuenter commented 1 year ago

Currently using schemacrawler lint for qa of our datamodels, would appreciate if you could deliver a predefined rule set to ease evaluation of your tool

OliverLemm commented 1 year ago

thanks for advice, we will take a look into the schemacrawler Is this the link from the tool? https://www.schemacrawler.com/lint.html

ThisGuenter commented 1 year ago

Yes - for schemacrawler.tools.linter.LinterCatalogSql/schemacrawler.tools.linter.LinterTableSql we use SQL with LISTAGG

LP-Internal Von: Oliver @.> Gesendet: Mittwoch, 28. September 2022 10:40 An: mt-ag/quasto @.> Cc: Guenter Leimbeck @.>; Comment @.> Betreff: Re: [mt-ag/quasto] export and import rules (Issue #10)

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

thanks for advice, we will take a look into the schemacrawler Is this the link from the tool? https://www.schemacrawler.com/lint.html

- Reply to this email directly, view it on GitHubhttps://github.com/mt-ag/quasto/issues/10#issuecomment-1260578300, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEMXIBPJ3Y2SFHG2XCNIXLTWAP76HANCNFSM576CK7UA. You are receiving this because you commented.Message ID: @.**@.>>

OliverLemm commented 1 year ago

For next steps the schemacrawler is to be checked and the structure should be compared to JSON.

We need a possible JSON structure for the QA_RULES table.

SabrinaPrang commented 1 year ago

Comparing schemacrawler with Oracle integrated JSON functionality:

Schemacrawler:

Usability for QUASTO: -> both directions are possible: DB-table to JSON and JSON to DB-table -> Java is needed -> an additional language must be used (Javascript or Ruby for example) -> extra Software is needed

Oracle Integrated JSON:

Usability for QUASTO:

Questions:

OliverLemm commented 1 year ago

regarding the points @SabrinaPrang has listed we will use JSON without the schemacrawler as in/output format

Thanks for your support @ThisGuenter

SabrinaPrang commented 1 year ago

The first draft of the JSON-format: QUASTO_JSON_structure_first_draft.txt

SabrinaPrang commented 1 year ago

For the uploaded JSON-files an upload-table is planned. Here is the first draft of the upload table QA_IMPORT_FILES with all needed skripts for sequence, trigger, etc. qa_import_files_cons.txt qa_import_files_ind.txt qaim_iu_trg.txt qaim_seq.txt qa_import_files.txt

OliverLemm commented 1 year ago

Next steps. Write Export & Import mechanic for json format with given table structure. Export should be a clob.

A formated export File written directly into a file will be defined in another task

OliverLemm commented 1 year ago

create new package export_import_rules_pkg with

Document how to spool out the rules inside the package and the documentation page

Keep an eye on the correct format when importing and exporting the SQL

Adjust Jenkins jobs

PhilippDahlem commented 1 year ago

quasto_json_tempalte.txt New Version of the Export JSON that is generated by the Database. I wrote everything lowercase and added a missing column. Along with the removal of the "U" in "QUARU" to reduce confusion with the actual table columns. Also we couldnt implement the boolean Value Conversion form the is_active column easily so we went ahead and put the original values (0/1) in it. Now the Json depicts the table as far as possible.

OliverLemm commented 1 year ago

Package qa_export_import_rules_pkg created Functions and Procedures added for Export and Import Script for Writing exported CLOB to a file added /scripts/export_rules_to_file

The following issues still in

PhilippDahlem commented 1 year ago

Es gilbt folgende Optionen um den Clob beim Export des JSONs richtig in den File auszugeben:

  1. mit einem Substr von 32767 Zeichen Rückwarts nach den ersten Linebreak suchen, und an der Stelle dann das Offset setzen
  2. per print clob den Exportierten Clob im SQL Plus abhandeln statt per dmbs_output.put_line
  3. Jedes Zeile in ein JSON_ARRAY packen und dann per Array Eintrag eine Ausgabe machen und später wieder zusammen konkatenieren

Punkt 2 wird als erstes ausprobiert, da sauberer und simplerer Code-Logik.

PhilippDahlem commented 1 year ago

Json-Template: we came to the conclusion that removing the prefix "qaru" inside our json-template would be the more user friendly option. The Json will become more readable.

OliverLemm commented 1 year ago

we should create a qa_files table for import/exporting files columns

OliverLemm commented 1 year ago

Script example for importing a file with sqlcl https://gist.github.com/krisrice/8da5e6cbc07db5becde799742a3c72d2#file-blobs-helper-js-L25