diff --git a/.env.dev.example b/.env.dev.example
index 8f71600a..a6dec8e9 100644
--- a/.env.dev.example
+++ b/.env.dev.example
@@ -7,13 +7,11 @@ APP_URL=http://localhost
APP_SETTINGS_STORE=json
DB_CONNECTION=local
-DB_HOST=localhost
+DB_HOST=127.0.0.1
DB_PORT=3306
-DB_DATABASE=
+DB_DATABASE=phpvms
DB_USERNAME=
DB_PASSWORD=
CACHE_DRIVER=array
CACHE_PREFIX=
-
-PHPVMS_CURRENCY=dollar
diff --git a/.env.travis b/.env.travis
index e90110c7..70b795d8 100644
--- a/.env.travis
+++ b/.env.travis
@@ -5,11 +5,11 @@ APP_LOG_LEVEL=debug
APP_URL=http://localhost
APP_SETTINGS_STORE=json
-DB_CONNECTION=local
-DB_HOST=localhost
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
DB_PORT=3306
-DB_DATABASE=
-DB_USERNAME=
+DB_DATABASE=phpvms
+DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=array
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 1cad2918..330a3966 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -24,10 +24,12 @@
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 7b84df9f..0eb8b5c7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,14 @@ php:
- '7.1'
# - hhvm
+services:
+ - mysql
+
+before_install:
+ - mysql -e 'CREATE DATABASE IF NOT EXISTS phpvms;'
+
before_script:
- #- cp .env.travis .env
- cp .env.travis .env
- #- mysql -e 'create database phpvms_test;'
- composer self-update
- make build
diff --git a/Makefile b/Makefile
index a451dbcb..1d04601a 100644
--- a/Makefile
+++ b/Makefile
@@ -25,11 +25,10 @@ clean:
@php artisan optimize
@php artisan route:clear
@php artisan config:clear
- @rm -f database/*.sqlite
.PHONY: reset
reset: clean
- @sqlite3 database/testing.sqlite ""
+ @php artisan database:create --reset
@php artisan migrate:refresh --seed
.PHONY: db
diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/CreateDatabase.php
new file mode 100644
index 00000000..045f2c54
--- /dev/null
+++ b/app/Console/Commands/CreateDatabase.php
@@ -0,0 +1,102 @@
+info('Running "' . $cmd . '"');
+
+ $proc = new Process($cmd);
+ $proc->run();
+ if (!$proc->isSuccessful()) {
+ throw new ProcessFailedException($proc);
+ }
+
+ echo $proc->getOutput();
+ }
+
+ protected function create_mysql($dbkey)
+ {
+ $mysql_cmd = [
+ 'mysql',
+ '-u' . config($dbkey . 'username'),
+ '-p' . config($dbkey . 'password'),
+ '-h' . config($dbkey . 'host'),
+ '-P' . config($dbkey . 'port'),
+ ];
+
+ if ($this->option('reset')) {
+ $cmd = array_merge(
+ $mysql_cmd,
+ ["-e 'DROP DATABASE ".config($dbkey . 'database')."'"]
+ );
+
+ $this->runCommand($cmd);
+ }
+
+ $cmd = array_merge(
+ $mysql_cmd,
+ ["-e 'CREATE DATABASE IF NOT EXISTS " . config($dbkey . 'database') . "'"]
+ );
+
+ $this->runCommand($cmd);
+ }
+
+ protected function create_sqlite($dbkey)
+ {
+ if ($this->option('reset')) {
+ $cmd = ['rm', '-rf', config($dbkey . 'database')];
+ $this->runCommand($cmd);
+ }
+
+ $cmd = [
+ 'sqlite3',
+ config($dbkey . 'database'),
+ '""',
+ ];
+
+ $this->runCommand($cmd);
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $this->info('Using connection "'.config('database.default').'"');
+
+ $dbkey = 'database.connections.' . config('database.default').'.';
+
+ if(config($dbkey.'driver') === 'mysql') {
+ $this->create_mysql($dbkey);
+ }
+
+ elseif (config($dbkey . 'driver') === 'sqlite') {
+ $this->create_sqlite($dbkey);
+ }
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 622e774b..708bcbf8 100755
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
- //
+ Commands\CreateDatabase::class,
];
/**
diff --git a/config/database.php b/config/database.php
index 752657d9..6c47fb8d 100755
--- a/config/database.php
+++ b/config/database.php
@@ -9,7 +9,7 @@ return [
'mysql' => [
'driver' => 'mysql',
- 'host' => env('DB_HOST', 'localhost'),
+ 'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'phpvms'),
'username' => env('DB_USERNAME', 'phpvms'),
diff --git a/phpvms.iml b/phpvms.iml
index 9eb8cdff..2f8fcdf1 100644
--- a/phpvms.iml
+++ b/phpvms.iml
@@ -32,48 +32,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file