diff --git a/.gitignore b/.gitignore index ccef056..e52a026 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ -.idea \ No newline at end of file +.idea +database.sqlite \ No newline at end of file diff --git a/browser.php b/browser.php index 6511538..e429948 100644 --- a/browser.php +++ b/browser.php @@ -7,7 +7,7 @@ use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'sqlite', - 'database' => __DIR__ . '/database.sample.sqlite', + 'database' => __DIR__ . '/database.sqlite', 'prefix' => '', ]); $capsule->setAsGlobal(); diff --git a/database.sample.sqlite b/database.sample.sqlite deleted file mode 100644 index f7bf764..0000000 Binary files a/database.sample.sqlite and /dev/null differ diff --git a/index.php b/index.php index 8a98fac..027f5a7 100644 --- a/index.php +++ b/index.php @@ -11,8 +11,7 @@ if (php_sapi_name() !== 'cli') { $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'sqlite', - 'database' => __DIR__ . '/database.sample.sqlite', - 'prefix' => '', + 'database' => __DIR__ . '/database.sqlite', ]); $capsule->setAsGlobal(); $client = new GuzzleHttp\Client(); diff --git a/migration.php b/migration.php new file mode 100644 index 0000000..5716717 --- /dev/null +++ b/migration.php @@ -0,0 +1,47 @@ +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(); + }); +}