-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
167 additions
and
8 deletions.
There are no files selected for viewing
55 changes: 48 additions & 7 deletions
55
.../buildSrc/src/main/kotlin/documentation/generators/asciidoc/DatabasesOverviewGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,66 @@ | ||
package documentation.generators.asciidoc | ||
|
||
import documentation.model.Application | ||
import documentation.model.Database | ||
import documentation.model.Database.Table | ||
import documentation.model.Distance.OWNED | ||
import documentation.model.componentName | ||
|
||
class DatabasesOverviewGenerator(applications: List<Application>) { | ||
|
||
private val ourApplicationsWithDatabases = applications | ||
private val keyEmoji = "\uD83D\uDD11" | ||
private val ourDatabases = applications | ||
.filter { it.distanceFromUs == OWNED } | ||
.filter { it.databases.isNotEmpty() } | ||
.sortedBy { componentName(it.id) } | ||
.flatMap(Application::databases) | ||
.sortedBy(Database::name) | ||
|
||
fun asciiDocSource(): String = | ||
buildString { | ||
appendLine(":toc: left") | ||
appendLine(":toclevels: 2") | ||
appendLine(":toclevels: 3") | ||
appendLine() | ||
appendLine("= Databases") | ||
appendLine() | ||
ourApplicationsWithDatabases | ||
.forEach { application -> | ||
ourDatabases | ||
.sortedBy(Database::name) | ||
.forEach { database -> | ||
appendLine("== ${database.name}") | ||
appendLine() | ||
if (database.description != null) { | ||
appendLine(database.description) | ||
appendLine() | ||
} | ||
appendLine("Type: ${database.type}") | ||
appendLine() | ||
database.tables | ||
.sortedBy(Table::name) | ||
.forEach { table -> | ||
appendLine("=== Table: ${table.name}") | ||
appendLine() | ||
if (table.description != null) { | ||
appendLine(table.description) | ||
appendLine() | ||
} | ||
appendLine(".${table.name} columns") | ||
appendLine("[width=100%, cols=\"~,~,~,~,~\"]") | ||
appendLine("|===") | ||
appendLine("|Column |Type |Nullable? |Default Value |Description") | ||
appendLine() | ||
table.columns | ||
.forEach { column -> | ||
if (column.partOfPrimaryKey) { | ||
appendLine("|`$keyEmoji ${column.name}`") | ||
} else { | ||
appendLine("|`${column.name}`") | ||
} | ||
appendLine("|${column.dataType}") | ||
appendLine("|${column.nullable}") | ||
appendLine("|${column.defaultValue ?: ""}") | ||
appendLine("|${column.description ?: ""}") | ||
appendLine() | ||
} | ||
appendLine("|===") | ||
appendLine() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,117 @@ | ||
:toc: left | ||
:toclevels: 2 | ||
:toclevels: 3 | ||
|
||
= Databases | ||
|
||
== Order Service Database | ||
|
||
The database of the Order Service. | ||
|
||
Type: PostgreSQL | ||
|
||
=== Table: addresses | ||
|
||
Stores saved addresses of customers. | ||
|
||
.addresses columns | ||
[width=100%, cols="~,~,~,~,~"] | ||
|=== | ||
|Column |Type |Nullable? |Default Value |Description | ||
|
||
|`🔑 id` | ||
|uuid | ||
|false | ||
| | ||
|The unique ID of this address. | ||
|
||
|`customer_id` | ||
|uuid | ||
|false | ||
| | ||
|The unique ID of the customer this address belongs to. | ||
|
||
|`name` | ||
|text | ||
|true | ||
| | ||
|The name of the customer used for this address. | ||
|
||
|`street` | ||
|text | ||
|true | ||
| | ||
|The name of the street incl. house numbers and other additions. | ||
|
||
|`city` | ||
|text | ||
|true | ||
| | ||
|The name of the city. | ||
|
||
|`zip_code` | ||
|text | ||
|true | ||
| | ||
|The ZIP code. | ||
|
||
|`country` | ||
|character (2) | ||
|true | ||
| | ||
|A ISO 3166-2 country code. | ||
|
||
|=== | ||
|
||
=== Table: orders | ||
|
||
Central table of this service. Stores all orders and their state. | ||
|
||
.orders columns | ||
[width=100%, cols="~,~,~,~,~"] | ||
|=== | ||
|Column |Type |Nullable? |Default Value |Description | ||
|
||
|`🔑 id` | ||
|uuid | ||
|false | ||
| | ||
|The unique ID of this address. | ||
|
||
|`customer_id` | ||
|uuid | ||
|false | ||
| | ||
|The unique ID of the customer from the central customer management service. | ||
|
||
|`ordered_at` | ||
|timestamp with time zone | ||
|false | ||
| | ||
|The exact point in time when this order was submitted by the customer. | ||
|
||
|`dispatched_at` | ||
|timestamp with time zone | ||
|true | ||
| | ||
| | ||
|
||
|`billing_address_id` | ||
|uuid | ||
|false | ||
| | ||
|ID of the address used for billing. Foreign key from 'addresses' table. | ||
|
||
|`shipping_address_id` | ||
|uuid | ||
|false | ||
| | ||
|ID of the address used for shipping. Foreign key from 'addresses' table. | ||
|
||
|`status` | ||
|text | ||
|false | ||
|'OPEN'::text | ||
|The status of the order. Can be 'OPEN', 'PROCESSING', 'DISPATCHED', 'DELIVERED', 'CANCELED' or 'FAILED' | ||
|
||
|=== | ||
|