Fail if appservice-discord wants Postgres, but has leftover SQLite data

This commit is contained in:
Slavi Pantaleev 2020-12-14 01:36:15 +02:00
parent dd994995bc
commit b87b754372
2 changed files with 18 additions and 1 deletions

View file

@ -49,7 +49,8 @@ matrix_appservice_discord_bridge_enableSelfServiceBridging: false
# - change the engine (`matrix_appservice_discord_database_engine: 'postgres'`) # - change the engine (`matrix_appservice_discord_database_engine: 'postgres'`)
# - adjust your database credentials # - adjust your database credentials
matrix_appservice_discord_database_engine: 'sqlite' matrix_appservice_discord_database_engine: 'sqlite'
matrix_appservice_discord_database_filename: "/data/discord.db" matrix_appservice_discord_database_filename: "/data/{{ matrix_appservice_discord_database_filename_name }}"
matrix_appservice_discord_database_filename_name: "discord.db"
matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_database_connString_username }}:{{ matrix_appservice_discord_database_connString_password }}@{{ matrix_appservice_discord_database_connString_hostname }}:{{ matrix_appservice_discord_database_connString_port }}/{{ matrix_appservice_discord_database_connString_db_name }}' matrix_appservice_discord_database_connString: 'postgresql://{{ matrix_appservice_discord_database_connString_username }}:{{ matrix_appservice_discord_database_connString_password }}@{{ matrix_appservice_discord_database_connString_hostname }}:{{ matrix_appservice_discord_database_connString_port }}/{{ matrix_appservice_discord_database_connString_db_name }}'
matrix_appservice_discord_database_connString_username: 'matrix_appservice_discord' matrix_appservice_discord_database_connString_username: 'matrix_appservice_discord'
matrix_appservice_discord_database_connString_password: 'some-password' matrix_appservice_discord_database_connString_password: 'some-password'

View file

@ -1,5 +1,21 @@
--- ---
- block:
- name: Check if an SQLite database already exists
stat:
path: "{{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}"
register: matrix_appservice_discord_stat_sqlite_db
- name: Fail if an SQLite database already exists when using Postgres
fail:
msg: >-
matrix_appservice_discord_database_engine has been set to `postgres` (which is our new default now).
However, we've discovered an existing SQLite database in {{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}.
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_appservice_discord_database_engine: sqlite` to your vars.yml file.
To migrate to Postgres: TODO - migration instructions here.
when: "matrix_appservice_discord_database_engine == 'postgres'"
- name: Ensure Appservice Discord image is pulled - name: Ensure Appservice Discord image is pulled
docker_image: docker_image:
name: "{{ matrix_appservice_discord_docker_image }}" name: "{{ matrix_appservice_discord_docker_image }}"