Add database migration script.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
.idea
|
.idea
|
||||||
|
database.sqlite
|
||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Capsule\Manager as Capsule;
|
|||||||
$capsule = new Capsule;
|
$capsule = new Capsule;
|
||||||
$capsule->addConnection([
|
$capsule->addConnection([
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'database' => __DIR__ . '/database.sample.sqlite',
|
'database' => __DIR__ . '/database.sqlite',
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
]);
|
]);
|
||||||
$capsule->setAsGlobal();
|
$capsule->setAsGlobal();
|
||||||
|
|||||||
Binary file not shown.
@@ -11,8 +11,7 @@ if (php_sapi_name() !== 'cli') {
|
|||||||
$capsule = new Capsule;
|
$capsule = new Capsule;
|
||||||
$capsule->addConnection([
|
$capsule->addConnection([
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'database' => __DIR__ . '/database.sample.sqlite',
|
'database' => __DIR__ . '/database.sqlite',
|
||||||
'prefix' => '',
|
|
||||||
]);
|
]);
|
||||||
$capsule->setAsGlobal();
|
$capsule->setAsGlobal();
|
||||||
$client = new GuzzleHttp\Client();
|
$client = new GuzzleHttp\Client();
|
||||||
|
|||||||
47
migration.php
Normal file
47
migration.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
|
if (php_sapi_name() !== 'cli') {
|
||||||
|
echo 'Execute this script in cli only';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
touch('database.sqlite');
|
||||||
|
$capsule = new Capsule;
|
||||||
|
$capsule->addConnection([
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'database' => __DIR__ . '/database.sqlite',
|
||||||
|
]);
|
||||||
|
$capsule->setAsGlobal();
|
||||||
|
|
||||||
|
if (!Capsule::schema()->hasTable('product')) {
|
||||||
|
Capsule::schema()->create('product', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('skuID');
|
||||||
|
$table->integer('availableQuantity');
|
||||||
|
$table->integer('stock');
|
||||||
|
$table->json('categories');
|
||||||
|
$table->string('image');
|
||||||
|
$table->string('subTitle');
|
||||||
|
$table->string('variantCode');
|
||||||
|
$table->string('modelCode');
|
||||||
|
$table->string('url');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!Capsule::schema()->hasTable('price')) {
|
||||||
|
Capsule::schema()->create('price', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->foreignId('product_id');
|
||||||
|
$table->float('price');
|
||||||
|
$table->float('productStandardPrice');
|
||||||
|
$table->float('lowestProductPrice30Days');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user