浏览代码

Add support for executing additional DB migration statements

In cases where pgloader is not enough and we need to do some additional
migration work after it, we can now use
`additional_psql_statements_list` and
`additional_psql_statements_db_name`.

This is to be used when migrating `matrix-registration`'s data at the
very least.
pull/740/head
Slavi Pantaleev 5 年前
父节点
当前提交
1bd5c240e5
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. +23
    -0
      roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml

+ 23
- 0
roles/matrix-postgres/tasks/util/migrate_db_to_postgres.yml 查看文件

@@ -99,6 +99,29 @@
command:
cmd: "mv {{ matrix_postgres_db_migration_request.src }} {{ matrix_postgres_db_migration_request.src }}.backup"

- block:
# We can't use `{{ role_path }}` here, neither with `import_tasks`, nor with `include_tasks`,
# because it refers to the role that included this util, and not to the role this file belongs to.
- import_tasks: "roles/matrix-postgres/tasks/util/detect_existing_postgres_version.yml"

- set_fact:
matrix_postgres_docker_image_to_use: "{{ matrix_postgres_docker_image_latest if matrix_postgres_detected_version_corresponding_docker_image == '' else matrix_postgres_detected_version_corresponding_docker_image }}"

- name: Execute additional Postgres SQL migration statements
command:
cmd: >-
{{ matrix_host_command_docker }} run
--rm
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
--cap-drop=ALL
--env-file={{ matrix_postgres_base_path }}/env-postgres-psql
--network={{ matrix_docker_network }}
{{ matrix_postgres_docker_image_to_use }}
psql --host=matrix-postgres --dbname={{ matrix_postgres_db_migration_request.additional_psql_statements_db_name }} --command='{{ item }}'
with_items: "{{ matrix_postgres_db_migration_request.additional_psql_statements_list }}"

when: "matrix_postgres_db_migration_request.additional_psql_statements_list|default([])|length > 0"

- name: Inject result
set_fact:
matrix_playbook_runtime_results: |


正在加载...
取消
保存