<commit_before>#!/usr/bin/env bash
#
# Author: <NAME>
# Contact: mailto:<EMAIL>
# Version: $id$
# 
# after composer ran, update the app
# 

set +e
scriptPath=$(readlink -f "${0%/*}")

function usage() {
    cat << EOF
Usage: $(basename $0) <options> -t

This script updates a sf2 environment after RemoteUpdateBundle started a composer update

OPTIONS:
   -h Show this help
   -s Skip installing and dumping of assets
   -d Without db update
   -r With db drop and recreate
   -a With ACL initialisation (only with -d)
   -f With Fixture loading (only with -d)
   -w With Webserver restart
   -c With chmodding of dirs (see envvars file)
EOF
}

APP=$(readlink -f "$scriptPath/../app/console") # assuming we are in bin/
APACHE_RUN_USER="${APACHE_RUN_USER-www-data}"
APACHE_RUN_GROUP="${APACHE_RUN_GROUP-www-data}"
DIRS="${DIRS-app/cache app/logs web/media/}"
WITHASSETS=1
WITHDB=1
WITHDBDROP=0
WITHWEBSERVER=0
WITHDBACL=0
WITHDBFIXTURES=0
WITHCHMOD=0

if [ -e "$scriptPath/envvars" ]; then
    . $scriptPath/envvars
    WITHCHMOD=1
fi

while getopts "hsdrafwc" OPTION ; do
    case $OPTION in
        s)
            WITHASSETS=0
            ;;
        d)
            WITHDB=0
            ;;
        r)
            WITHDBDROP=1
            ;;
        a)
            WITHDBACL=1
            ;;
        f)
            WITHDBFIXTURES=1
            ;;
        w)
            WITHWEBSERVER=1
            ;;
        c)
            WITHCHMOD=0
            ;;
        ?)
            usage
            exit 1
            ;;
    esac
done

if [ $WITHDB = 1 ]; then
    # create db
    if [ $WITHDBDROP = 1 ]; then
        $APP doctrine:database:drop --force
        $APP doctrine:database:create
    fi
    $APP doctrine:schema:update --force
    if [ $WITHDBACL = 1 ]; then
        $APP init:acl
    fi
    if [ $WITHDBFIXTURES = 1 ]; then
        $APP doctrine:fixtures:load
    fi
else
    $APP doctrine:schema:update --force
fi

if [ $WITHASSETS = 1 ]; then
    $APP assets:install --symlink web<commit_msg>Added schema recreation<commit_after>#!/usr/bin/env bash
#
# Author: <NAME>
# Contact: mailto:<EMAIL>
# Version: $id$
# 
# after composer ran, update the app
# 

set +e
scriptPath=$(readlink -f "${0%/*}")

function usage() {
    cat << EOF
Usage: $(basename $0) <options> -t

This script updates a sf2 environment after RemoteUpdateBundle started a composer update

OPTIONS:
   -h Show this help
   -s Skip installing and dumping of assets
   -d Without db update
   -r With db drop and recreate
   -a With ACL initialisation (only with -d)
   -f With Fixture loading (only with -d)
   -w With Webserver restart
   -c With chmodding of dirs (see envvars file)
EOF
}

APP=$(readlink -f "$scriptPath/../app/console") # assuming we are in bin/
APACHE_RUN_USER="${APACHE_RUN_USER-www-data}"
APACHE_RUN_GROUP="${APACHE_RUN_GROUP-www-data}"
DIRS="${DIRS-app/cache app/logs web/media/}"
WITHASSETS=1
WITHDB=1
WITHDBDROP=0
WITHSCHEMADROP=0
WITHWEBSERVER=0
WITHDBACL=0
WITHDBFIXTURES=0
WITHCHMOD=0

if [ -e "$scriptPath/envvars" ]; then
    . $scriptPath/envvars
    WITHCHMOD=1
fi

while getopts "hsdruafwc" OPTION ; do
    case $OPTION in
        s)
            WITHASSETS=0
            ;;
        d)
            WITHDB=0
            ;;
        r)
            WITHDBDROP=1
            ;;
        u)
            WITHSCHEMADROP=1
            ;;
        a)
            WITHDBACL=1
            ;;
        f)
            WITHDBFIXTURES=1
            ;;
        w)
            WITHWEBSERVER=1
            ;;
        c)
            WITHCHMOD=0
            ;;
        ?)
            usage
            exit 1
            ;;
    esac
done

if [ $WITHDB = 1 ]; then
    # create db
    if [ $WITHDBDROP = 1 ]; then
        $APP doctrine:database:drop --force
        $APP doctrine:database:create
    fi
    if [ $WITHSCHEMADROP = 1 ]; then
        $APP doctrine:schema:drop --force
        $APP doctrine:schema:create
    else
        $APP doctrine:schema:update --force
    fi
    if [ $WITHDBACL = 1 ]; then
        $APP init:acl
    fi
    if [ $WITHDBFIXTURES = 1 ]; then
        $APP doctrine:fixtures:load
    fi
else
    $APP doctrine:schema:update --force
fi

if [ $WITHASSETS = 1 ]; then
    $APP assets:install --symlink web
{'fraction_non_alphanumeric': 0.10910815939278938, 'fraction_numerical': 0.012096774193548387, 'mean_word_length': 1.967628430682618, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '751616', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1420, 'n_words': 393}