qonto / postgresql-partition-manager

Simplified PostgreSQL partioning management
MIT License
6 stars 2 forks source link

PostgreSQL package organisation #6

Closed qfritz closed 6 months ago

qfritz commented 6 months ago

Creating an issue because discussing in MR is painful. 😭

Opening this topic to discuss internal/infra/postgresql package organisation.

This is the current overview of the package:

Open Mermaid Schema

```mermaid graph TD subgraph cmd run end subgraph ppm c(check) s(server) end subgraph infra config subgraph postgresql pg[POSTGRESQL] bounds column connection error partition partitionconfiguration partitionsettings partitionstrategy server table end end DB[(PostgreSQL)] %% LINKS run ----> connection pg --> column & error & table & partitionconfiguration & partitionsettings partitionsettings --> partitionstrategy partitionconfiguration --> bounds & partition pg ----> bounds & partition c ----> partitionsettings s ----> server config --> partitionconfiguration pg & server & connection & column -...- DB ```

Initial notes:

qfritz commented 6 months ago

Proposal

Open Updated Mermaid Schema

```mermaid graph LR subgraph cmd run pg[POSTGRESQL
renamed to manager.go
.] end subgraph app subgraph ppp[partition] table partition partitionconfiguration[configuration] partitionsettings[settings] partitionstrategy[strategy] bounds end end subgraph infra config subgraph postgresql querier connection error server column end end DB[(PostgreSQL)] %% LINKS run ----> connection pg --> column & error & table & partitionconfiguration & partitionsettings partitionsettings --> partitionstrategy partitionconfiguration --> bounds & partition pg ----> bounds & partition & querier config --> partitionconfiguration table -.->|merge with| partition querier & server & connection & column -...- DB ```

Edit: absolutely not fixed on the naming, please consider my proposal for its concepts more than the actual names used.

dcupif commented 6 months ago

I'm aligned with @qfritz that the postgres package contains most of the "domain knowledge". Example: the concept of partition is only meaningful in our context, but this concept does not exist physically in Postgres, partitions are just tables. Ultimately, I would suggest something along the lines of:

internal/ (or public)
  partitioning/
    package partitioning
    Main types: Partition, Bound, Key, Manager, Strategy...
infra/
  postgres/
    package postgres
    Main types: Client, Table, Column, ColumnType, Query...

Very similar to what Eve suggests 👍

qfritz commented 6 months ago

partitions are just tables

That's also one of the reason I suggested to merge partition and table and their very similar functions.

vmercierfr commented 6 months ago

As discussed, it's now implemented :)