Search code examples
postgresqldockersqitch

Running Sqitch to deploy a database in Postgres on a Docker container


I am running Postgres on a Docker container.

I have been trying to following the example show to deploy scripts using Sqitch from the following page:

https://metacpan.org/pod/sqitchtutorial

Now I have got as far as creating my folders for Deploy, Revert and Verify

I then try to deploy changes using the following command:

sqitch deploy db:pg://username:password@localhost/flipr_test

where i pass in my username and password

However i get the following error message:

Adding registry tables to db:pg://postgres:@localhost/flipr_test
"/opt/local/pgsql/bin/psql" failed to start: "The system cannot find the path specified"

How can I get Sqitch to run to deploy a database to Postgres running on a Docker Container?


Solution

  • Need to do the following :

    1. Get a Sqitch.bat file using the following command wget https://git.io/JTAi6 -o sqitch.bat
    2. Copy this Sqitch.bat file into the flipr folder.

    This sqitch file runs Sqitch in a Docker Container

    1. Add the following line to docker-compose.yml for the Postgres Database (Under 'environment'): environment:
    - POSTGRES_HOST_AUTH_METHOD=trust 
    
    1. Then in ~/.sqitch/sqitch.conf

    Comment out the following line:

    #client = /opt/local/pgsql/bin/psql
    

    This means that psql will then be used from the Postgres container

    1. Now I can run the following command
    .\sqitch.bat deploy db:pg://postgres:password!@localhost/flipr_test
    

    Here the sqitch.bat is running up Sqitch in the Docker Container and then from there can run the deploy command to deploy changes