Add (Postgres + SQLite) support to matrix-mautrix-hangouts bridge

I don't use this bridge, so this is completely untested.
This commit is contained in:
Slavi Pantaleev
2020-12-14 12:34:59 +02:00
parent 43d6ff2af8
commit ce21ea3640
4 changed files with 51 additions and 1 deletions

View File

@ -8,6 +8,26 @@
The matrix-bridge-mautrix-hangouts role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)"
- block:
- name: Check if an SQLite database already exists
stat:
path: "{{ matrix_mautrix_hangouts_sqlite_database_path_local }}"
register: matrix_mautrix_hangouts_sqlite_database_path_local_stat_result
- name: Fail if an SQLite database already exists when using Postgres
fail:
msg: >-
matrix_mautrix_hangouts_database_engine has been set to `postgres` (which is our new default now).
However, we've discovered an existing SQLite database in {{ matrix_mautrix_hangouts_sqlite_database_path_local }}.
It appears that you've been using this bridge with the SQLite engine until now.
To continue using SQLite, opt into it explicitly: add `matrix_mautrix_hangouts_database_engine: sqlite` to your vars.yml file and re-run this same command.
Alternatively, to migrate your existing SQLite database to Postgres:
1. Stop all services (`ansible-playbook -i inventory/hosts setup.yml --tags=stop`)
2. Import the SQLite database into Postgres (`ansible-playbook -v -i inventory/hosts setup.yml --tags=import-generic-sqlite-db --extra-vars='sqlite_database_path={{ matrix_mautrix_hangouts_sqlite_database_path_local }} postgres_connection_string_variable_name=matrix_mautrix_hangouts_postgres_connection_string'`)
3. Re-run the playbook (`ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`)
when: "matrix_mautrix_hangouts_sqlite_database_path_local_stat_result.stat.exists"
when: "matrix_mautrix_hangouts_database_engine == 'postgres'"
- name: Ensure Mautrix Hangouts image is pulled
docker_image:
name: "{{ matrix_mautrix_hangouts_docker_image }}"