Add support for automatic (nedb -> Postgres) migration to mx-appservice-irc

This commit is contained in:
Slavi Pantaleev
2020-12-22 19:32:43 +02:00
parent 815a80c290
commit 715bdf2c64
9 changed files with 109 additions and 81 deletions

View File

@ -67,22 +67,6 @@
become: false
when: "matrix_postgres_service_start_result.changed|bool"
# See https://github.com/matrix-org/matrix-appservice-irc/wiki/Migrating-from-NEdB-to-PostgreSQL
- name: Import appservice_irc NeDB database from {{ sqlite_database_path }} into Postgres
when: database == 'appservice_irc'
command:
cmd: >-
{{ matrix_host_command_docker }} run
--rm
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--cap-drop=ALL
--network={{ matrix_docker_network }}
--mount type=bind,src={{ matrix_appservice_irc_data_path }}:/data:ro
--entrypoint=/bin/sh
{{ matrix_appservice_irc_docker_image }}
-c
'./scripts/migrate-db-to-pgres.sh -d /data -p passkey.pem -c {{ postgres_db_connection_string }}'
# No migration.sh available, but found this:
# https://github.com/matrix-org/matrix-appservice-slack/blob/develop/src/scripts/migrateToPostgres.ts
# Usage should be similar to appservice_irc
@ -95,15 +79,12 @@
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--cap-drop=ALL
--network={{ matrix_docker_network }}
--mount type=bind,src={{ matrix_appservice_irc_data_path }}:/data:ro
--mount type=bind,src={{ matrix_appservice_irc_data_path }},dst=/data,ro
--entrypoint=/bin/sh
{{ matrix_appservice_slack_docker_image }}
-c
'node /lib/scripts/migrate-db-to-pgres.js -d /data -p passkey.pem -c {{ postgres_db_connection_string }}'
- name: Archive NeDB database ({{ sqlite_database_path }} -> {{ sqlite_database_path }}.backup)
command:
cmd: "mv {{ sqlite_database_path }} {{ sqlite_database_path }}.backup"
- name: Inject result
set_fact:

View File

@ -32,14 +32,6 @@
tags:
- import-generic-sqlite-db
# Imports appservice-irc NeDB into postgres
- import_tasks: "{{ role_path }}/tasks/import_nedb.yml"
vars:
database: appservice_irc
when: run_postgres_import_nedb|bool
tags:
- import-irc-nedb
# Imports slacks neDB to postgres.
- import_tasks: "{{ role_path }}/tasks/import_nedb.yml"
vars: