Skip to content

Commit

Permalink
added documentation for guidelines for creating entity defnitions
Browse files Browse the repository at this point in the history
  • Loading branch information
techsmyth committed Aug 24, 2024
1 parent a71726a commit f0da118
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ The key takeaway is that the Alkemio server is designed to be integrated, so tha
- [Data Management - How data representing the domain model used by Alkemio Platform is managed, including database migrations](docs/DataManagement.md)
- [Quality Assurance - Details of the test harness around the server and how to execute the test suites](docs/QA.md).
- [Pushing - How new docker images are published to Dockerhub](docs/Publishing.md)
- [Database defnitions - Guidelines for creating TypeORM entity definitions](docs/database-defnitions.md)

For other questions / comments please feel free to reach out via the channels listed in the [Alkemio Repo](http://github.com/alkem-io/alkemio) or via [Alkemio organization](https://alkemio.org).
29 changes: 29 additions & 0 deletions docs/database-definitions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Specifying database entity defnitions for usage with the server

Please adhere to the following guidelines when creating TypeORM entity defnitions:

**Defaults**:

- no defaults in entity definitions; set defaults through business logic
- no defaults to the class fields

**Relations**:

- relations that are not eager need to be defined as optional, since they need to be loaded explicitly

**Lengths**:

- always define length with constants
- stick to the existing length constants OR in the rear case - create one if nothing fits

| data | what to use |
| ------------------- | ---------------------- |
| Alkemio identifiers | `char(UUID_LENGTH)` |
| enums | `varchar(ENUM_LENGTH)` |
| short text | `varchar(your length)` |
| long text | `text` |
| URI, URL | `varchar(URI_LENGHT)` |

## Usage

- generate a domain change migration via `migration:generate`

0 comments on commit f0da118

Please sign in to comment.