]> git.ekhem.eu.org Git - server.git/commitdiff
[matrix] Use Postgres as the database.
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 25 Nov 2022 22:23:10 +0000 (23:23 +0100)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 3 Dec 2023 21:03:23 +0000 (22:03 +0100)
Matrix automatically generates and populates necessary tables.

databases/matrix/matrix_db_create.sql [new file with mode: 0644]
databases/matrix/matrix_db_drop.sql [new file with mode: 0644]
matrix/homeserver.yaml
postgres/pg_hba.conf

diff --git a/databases/matrix/matrix_db_create.sql b/databases/matrix/matrix_db_create.sql
new file mode 100644 (file)
index 0000000..857db5d
--- /dev/null
@@ -0,0 +1,14 @@
+DO $$
+BEGIN
+    IF NOT EXISTS (SELECT * FROM pg_user WHERE usename = 'synapse_user')
+    THEN
+        CREATE USER synapse_user;
+    END IF;
+END$$;
+
+CREATE DATABASE matrix_db
+    ENCODING 'UTF8'
+    LC_COLLATE='C'
+    LC_CTYPE='C'
+    TEMPLATE=template0
+    OWNER synapse_user;
diff --git a/databases/matrix/matrix_db_drop.sql b/databases/matrix/matrix_db_drop.sql
new file mode 100644 (file)
index 0000000..4ae4e8a
--- /dev/null
@@ -0,0 +1,9 @@
+DROP DATABASE matrix_db;
+
+DO $$
+BEGIN
+    IF EXISTS (SELECT * FROM pg_user WHERE usename = 'synapse_user')
+    THEN
+        DROP USER synapse_user;
+    END IF;
+END$$;
index 1ed7f77bfe7dee6c155bc479c7a3c76304803e44..d842ab4d8b5b253038e71e9051794407ea47f664 100644 (file)
@@ -312,11 +312,13 @@ listeners:
 # Database configuration
 database:
   # The database engine name
-  name: "sqlite3"
+  name: "psycopg2"
   # Arguments to pass to the engine
   args:
-    # Path to the database
-    database: "/var/lib/matrix-synapse/homeserver.db"
+    user: "synapse_user"
+    database: "matrix_db"
+    cp_min: 5
+    cp_max: 10
 
 # Number of events to cache in memory.
 event_cache_size: "10K"
index 2b6bc56418d8d47304fb35d105c9ea3deb12edcb..81e567041140b84c62193d9efa0705254b90d41c 100644 (file)
@@ -93,6 +93,7 @@ local   all             postgres                                peer
 local   mail_db         dovecot                                 trust
 host    mail_db         dovecot         ::1/128                 trust
 host    mail_db         dkim            ::1/128                 trust
+local   matrix_db       synapse_user                            trust
 # "local" is for Unix domain socket connections only
 local   all             all                                     peer
 # IPv4 local connections: