Elffuss BraidHub

kikocis/EDC public

main · 2.2 KiBRenderedRawPermalink
1# SQL-based `TransferProcessStore` - technical proposal
2
3**_Note that the SQL statements (DDL) are specific to and only tested with PostgreSQL. Using it with other RDBMS may
4work but might have unexpected side effects!_**
5
6## Table schema DDL
7
8please refer to [schema.sql](src/main/resources/transfer-process-schema.sql):
9
10## Translating the `TransferProcessStore` interface into SQL statements
11
12All SQL contants such as table names, column names, statement templates etc. are stored in an interface
13called `TransferProcessStoreStatements`. Column names are declared directly in that interface, as they likely won't
14change between different DB technologies, but all statements are then implemented in the `PostgreStatements` class.
15
16## Create a flexible query API to accommodate `QuerySpec`
17
18_For the first version, only the `limit` and `offset` arguments from the `QuerySpec` will be used._
19
20For subsequent versions it is recommended to re-use the `Clause` interface and its implementors, that were originally
21implemented for CosmosDB, and create an equivalent set of clauses for SQL. Thus, there would be a `Limit-`, `Offset-`
22, `Order-` and `WhereClause` for SQL.
23
24That way, dialect-dependent variants can be implemented should the need arise, because the actual SQL statement is
25encoded in those clauses, offering a fluent Java API.
26
27## Migrate from 0.5.1 to 0.6.0
28
29The schema has changed, the columns contained in `edc_data_request` have been moved to `edc_transfer_process` with this
30mapping:
31
32- `datarequest_id` -> `correlation_id`
33- `connector_address` -> `counter_party_address`
34- `protocol` -> `protocol`
35- `asset_id` -> `asset_id`
36- `contract_id` -> `contract_id`
37- `data_destination` -> `data_destination`
38
39These columns need to be added to `edc_transfer_process`:
40
41```sql
42correlation_id VARCHAR,
43counter_party_address VARCHAR,
44protocol VARCHAR,
45asset_id VARCHAR,
46contract_id VARCHAR,
47data_destination JSON,
48```
49
50then they should be filled with the corresponding value in the `edc_data_request` table, they can be joined by:
51```edc_data_request.transfer_process_id = edc_transfer_process.transferprocess_id```
52
53after that and after upgrading all the connector instance, the `edc_data_request` can be deleted.