migration-from-mysql-to-postgresql.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #
  2. # Test the migration from mysql/mariadb to postgresql.
  3. #
  4. .template_migration_from_mysql_to_postgresql:
  5. stage: test
  6. rules:
  7. - if: $CI_COMMIT_REF_NAME =~ /^private/
  8. when: manual
  9. allow_failure: true
  10. - when: on_success
  11. variables:
  12. ENFORCE_DB_SERVICE: mysql
  13. script:
  14. - !reference [.scripts, configure_environment]
  15. - !reference [.scripts, zammad_db_init]
  16. - 'bundle exec rails r "FillDb.load(object_manager_attributes: {user: {multiselect: 1, multi_tree_select: 1}, ticket: {multiselect: 1, multi_tree_select: 1}, organization: {multiselect: 1, multi_tree_select: 1}}, organization: 2, agents: 2, tickets: 10, public_links: 2, nice: 0)"'
  17. - bundle exec rake zammad:db:pgloader > tmp/pgloader-command
  18. - sed -i 's#pgsql://zammad:pgsql_password@localhost/zammad#pgsql://zammad:zammad@postgresql/zammad_test#' tmp/pgloader-command
  19. - cat tmp/pgloader-command # for debugging
  20. - bundle exec rails r 'pp Ticket.all.as_json; pp User.all.as_json; pp Organization.all.as_json; pp PublicLink.all.as_json' > tmp/before-migration-dump.json
  21. - rm -f config/database.yml && export ENFORCE_DB_SERVICE=postgresql
  22. - !reference [.scripts, configure_environment]
  23. - bundle exec rake db:drop db:create # re-create an empty database
  24. - pgloader --verbose tmp/pgloader-command
  25. - bundle exec rails r 'Rails.cache.clear'
  26. - bundle exec rails r 'pp Ticket.all.as_json; pp User.all.as_json; pp Organization.all.as_json; pp PublicLink.all.as_json' > tmp/after-migration-dump.json
  27. - .gitlab/check_database_migration_consistency.sh
  28. - .gitlab/check_postgres_array_columns.rb
  29. migration:database:mysql_to_postgresql:
  30. extends:
  31. - .template_migration_from_mysql_to_postgresql
  32. services:
  33. - !reference [.services, mysql]
  34. - !reference [.services, redis]
  35. # We need to override the default postgresql service to use the stable version of postgresql until issues with pgloader are resolved.
  36. - name: $CI_REGISTRY/docker/zammad-postgresql:stable
  37. alias: postgresql
  38. migration:database:mariadb_to_postgresql:
  39. extends:
  40. - .template_migration_from_mysql_to_postgresql
  41. services:
  42. - !reference [.services, mariadb]
  43. - !reference [.services, redis]
  44. # We need to override the default postgresql service to use the stable version of postgresql until issues with pgloader are resolved.
  45. - name: $CI_REGISTRY/docker/zammad-postgresql:stable
  46. alias: postgresql