#!/bin/sh
set -ev

# Start service containers
spoc-container start decidim-postgres

# Run database migration
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim:upgrade'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_conferences:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_consultations:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_initiatives:install:migrations'
# spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_templates:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_calendar:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_comparative_stats:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_decidim_awesome:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_ldap:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_navbar_links:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_navigation_maps:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_time_tracker:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails redirector_engine:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails decidim_url_aliases:install:migrations'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'

# Stop service containers
spoc-container stop decidim-postgres
