From 26ff086de499e4efd71a30371c9015e37ba7c798 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Sat, 16 Dec 2017 00:29:56 +0100
Subject: [PATCH] Decision to add relational database and choose PostgreSQL.

---
 .../decisions/0011-add-relational-database.md | 26 +++++++++++++++++++
 .../decisions/0012-use-postgresql.md          | 25 ++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 docs/architecture/decisions/0011-add-relational-database.md
 create mode 100644 docs/architecture/decisions/0012-use-postgresql.md

diff --git a/docs/architecture/decisions/0011-add-relational-database.md b/docs/architecture/decisions/0011-add-relational-database.md
new file mode 100644
index 0000000..418f758
--- /dev/null
+++ b/docs/architecture/decisions/0011-add-relational-database.md
@@ -0,0 +1,26 @@
+# 11. Add relational database
+
+Date: 2017-12-15
+
+## Status
+
+Accepted
+
+## Context
+
+Number of document types which does not use Elasticsearch's fulltext  
+capabilities is growing. Recently released Elasticsearch 6 is bringing one type  
+per index which means management of many indices.
+
+## Decision
+
+We will add relational database as primary database. Elasticsearch will be used  
+for denormalized reports and related data intended for fulltext search.
+
+## Consequences
+
+* Proper relations in data on database level.
+* Simplification in data management and schema migrations.
+* If ORM is used then GraphQL types may be derived without additional effort  
+and translations between document types and GraphQL types.
+* Less indices in Elasticsearch.
diff --git a/docs/architecture/decisions/0012-use-postgresql.md b/docs/architecture/decisions/0012-use-postgresql.md
new file mode 100644
index 0000000..e970b7d
--- /dev/null
+++ b/docs/architecture/decisions/0012-use-postgresql.md
@@ -0,0 +1,25 @@
+# 12. Use PostgreSQL
+
+Date: 2017-12-16
+
+## Status
+
+Accepted
+
+## Context
+
+We want to add relational database.
+
+## Decision
+
+We will use PostgreSQL. It's a mature database with handy features like JSON  
+and hstore data types. It's fully ACID compliant including schema changes. It  
+has very good support in Django's ORM.
+
+Another popular option is MySQL/MariaDB. But because it has a major bug `#28727`  
+(10 years since it has been reported and it's still not fixed) breaking ACID in  
+schema changes it can't be used for any serious project.
+
+## Consequences
+
+We will have mature relatonal database with handy JSON and hstore data types.
-- 
GitLab