Deploying Elixir Apps with structure.sql in Production Environments

91
clicks
Deploying Elixir Apps with structure.sql in Production Environments
In environments where the 'mix' build tool is not available—such as production—deploying an Elixir application after having used 'mix ecto.dump' can pose a challenge. This is especially true when older migration files have been deleted and the structure of the database must be set up from a 'structure.sql' file. The provided solution involves ensuring that 'psql' is available on the server, which may require amending the Dockerfile to install the 'postgresql-client' package. Additionally, custom functions such as 'check_and_execute_structure_sql/1' are added to the release's code, enabling the execution of the 'structure.sql' file upon deployment. This approach extracts the necessary elements from the 'mix ecto.load' task, adapting them to work in a production environment where mix is not present.

© HashMerge 2024