Correct application build + migration
authorymh <ymh.work@gmail.com>
Fri, 21 Oct 2016 16:07:19 +0200
changeset 383 82a3db4b1d39
parent 382 ea0e8417e4dc
child 384 5598bad67f8d
Correct application build + migration
build/build_rpm.sh
build/post_upgrade.sh
build/pre_upgrade.sh
server/src/database/migrations/2016_09_30_132045_create_geonames_hierarchies_table.php
--- a/build/build_rpm.sh	Fri Oct 21 14:45:47 2016 +0200
+++ b/build/build_rpm.sh	Fri Oct 21 16:07:19 2016 +0200
@@ -1,22 +1,29 @@
 #!/usr/bin/env bash
 
-pushd /vagrant/root/var/www/corpusdelaparole/corpus-back/
+pushd /vagrant/root/var/www/corpusdelaparole/corpus-back/ > /dev/null
 echo "---> Launching composer"
 php composer.phar install --ignore-platform-reqs -o
-echo "---> Optimizing config"
-php artisan config:cache
-echo "---> Optimizing route"
-php artisan route:cache
+echo "---> Composer done"
+echo "---> Clear cache"
+php artisan cache:clear
+echo "---> Clear config cache"
+php artisan config:clear
+echo "---> Clear route"
+php artisan route:clear
 echo "---> Clear views"
 php artisan view:clear
-echo "---> Composer done"
-popd
+echo "---> put application in maintenance"
+php artisan down
+
+popd > /dev/null
 
 mkdir -p /vagrant/dist
-pushd /vagrant/dist
+pushd /vagrant/dist > /dev/null
 echo "---> Launching packaging"
 rm -f *.rpm
-#TODO: read version from corpus
+
+popd > /dev/null
+
 version=$(grep -oP "\'version\'\s*=>\s*\'\K[\.0-9]+(?=\')" /vagrant/root/var/www/corpusdelaparole/corpus-back/config/version.php)
 version=${version:-0.0.0}
 
@@ -45,4 +52,3 @@
     .
 
 echo "---> Packaging done"
-popd
--- a/build/post_upgrade.sh	Fri Oct 21 14:45:47 2016 +0200
+++ b/build/post_upgrade.sh	Fri Oct 21 16:07:19 2016 +0200
@@ -9,19 +9,26 @@
 fi
 
 if [ -d /var/www/corpusdelaparole/corpus-back/ ]; then
-    pushd /var/www/corpusdelaparole/corpus-back/
+    pushd /var/www/corpusdelaparole/corpus-back/ > /dev/null
 
     echo "Migrating back office database"
-    php artisan migrate
+    php artisan migrate -n --force
 
     echo "Optimizing framework"
     php artisan optimize
+    php artisan config:cache
+    php artisan route:cache
+    php artisan view:cache
+
 
     echo "Correcting file permissions for back office"
     chgrp -R apache storage bootstrap/cache
     chmod -R ug+rwx storage bootstrap/cache
 
-    popd
+    echo "Put back application in production"
+    php artisan up
+
+    popd > /dev/null
 fi
 
 echo "Restart httpd"
--- a/build/pre_upgrade.sh	Fri Oct 21 14:45:47 2016 +0200
+++ b/build/pre_upgrade.sh	Fri Oct 21 16:07:19 2016 +0200
@@ -1,6 +1,16 @@
 #!/usr/bin/env sh
 PATH=/opt/remi/php56/root/usr/bin/:$PATH
 
+if [ -d /var/www/corpusdelaparole/corpus-back/ ]; then
+    pushd /var/www/corpusdelaparole/corpus-back/ > /dev/null
+
+    echo "Put back application in maintenance"
+    php artisan down
+
+    popd > /dev/null
+fi
+
+
 if [ -x /usr/local/bin/drush ]; then
     echo "Deactivate corpus module"
     /usr/local/bin/drush -r /var/www/corpusdelaparole/drupal pm-disable -y corpus
--- a/server/src/database/migrations/2016_09_30_132045_create_geonames_hierarchies_table.php	Fri Oct 21 14:45:47 2016 +0200
+++ b/server/src/database/migrations/2016_09_30_132045_create_geonames_hierarchies_table.php	Fri Oct 21 16:07:19 2016 +0200
@@ -4,6 +4,8 @@
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
+use Illuminate\Support\Facades\DB;
+
 class CreateGeonamesHierarchiesTable extends Migration
 {
     /**
@@ -17,7 +19,7 @@
             $table->increments('id');
             $table->timestamps();
             $table->string('geonamesid')->unique();
-            $table->json('hierarchy');
+            $table->text('hierarchy');
         });
     }