diff --git a/Procfile b/Procfile index 48aab52..29aa7d5 100644 --- a/Procfile +++ b/Procfile @@ -1 +1,2 @@ web: vendor/bin/heroku-php-apache2 public/ +release: php release.php diff --git a/lib/helpers.php b/lib/helpers.php index 95876dd..5dfd49a 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -33,6 +33,10 @@ function setupDB($host, $user, $pass, $dbname, $port='') { define('DB_SETUP', true); } +function installDB() { + ORM::raw_execute(file_get_contents('schema/schema.sql')); +} + function make_logger($channel) { $log = new Logger($channel); $log->pushHandler(new StreamHandler(dirname(__FILE__).'/../logs/app.log', Logger::DEBUG)); diff --git a/release.php b/release.php new file mode 100644 index 0000000..fd96e5b --- /dev/null +++ b/release.php @@ -0,0 +1,20 @@ +error("Unable to release without APP_NAME, BASE_URL and valid DB_ ENV"); + exit(-1); +} +try { + installDB(); +} catch(\Exception $e) { + $userlog->error( + 'Schema restore / migration failed' + ); + exit(-1); +} +$userlog->info('Release success'); +exit(0);