Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Основные таблицы новой версии магазина
- Loading branch information
Showing
12 changed files
with
258 additions
and
159 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
core/db/migrations/20210322072616_files.php → core/db/migrations/20230814024249_files.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Vesp\Services\Migration; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Vesp\Services\Migration; | ||
|
||
final class Languages extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
$this->schema->create( | ||
'languages', | ||
function (Blueprint $table) { | ||
$table->char('lang', 2)->primary(); | ||
$table->string('title')->unique(); | ||
$table->unsignedInteger('rank')->nullable()->index(); | ||
$table->boolean('active')->default(true)->index(); | ||
} | ||
); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
$this->schema->drop('languages'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Vesp\Services\Migration; | ||
|
||
final class Categories extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
$this->schema->create( | ||
'categories', | ||
static function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('file_id')->nullable() | ||
->constrained('files')->nullOnDelete(); | ||
$table->string('alias'); | ||
$table->string('uri')->unique(); | ||
$table->boolean('active')->default(true); | ||
$table->unsignedInteger('rank')->default(0); | ||
$table->unsignedInteger('remote_id')->nullable()->index(); | ||
$table->timestamps(); | ||
|
||
$table->index(['uri', 'active']); | ||
} | ||
); | ||
|
||
$this->schema->table( | ||
'categories', | ||
static function (Blueprint $table) { | ||
$table->foreignId('parent_id')->nullable()->after('id') | ||
->constrained('categories')->nullOnDelete(); | ||
|
||
$table->index(['parent_id', 'rank']); | ||
} | ||
); | ||
|
||
$this->schema->create( | ||
'category_translations', | ||
static function (Blueprint $table) { | ||
$table->foreignId('category_id') | ||
->constrained('categories')->cascadeOnDelete(); | ||
$table->char('lang', 2); | ||
|
||
$table->string('title'); | ||
$table->text('description')->nullable(); | ||
|
||
$table->primary(['category_id', 'lang']); | ||
$table->unique(['lang', 'title']); | ||
$table->foreign('lang') | ||
->references('lang') | ||
->on('languages') | ||
->cascadeOnDelete(); | ||
} | ||
); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
$this->schema->drop('category_translations'); | ||
$this->schema->drop('categories'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Vesp\Services\Migration; | ||
|
||
final class Products extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
$this->schema->create( | ||
'products', | ||
static function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('category_id') | ||
->constrained('categories')->cascadeOnDelete(); | ||
$table->string('alias'); | ||
$table->string('uri')->unique(); | ||
|
||
$table->decimal('price')->default(0); | ||
$table->decimal('old_price')->default(0); | ||
$table->string('article')->nullable(); | ||
$table->decimal('weight')->nullable(); | ||
|
||
$table->boolean('new')->default(false)->index(); | ||
$table->boolean('popular')->default(false)->index(); | ||
$table->boolean('favorite')->default(false)->index(); | ||
|
||
$table->string('made_in')->nullable(); | ||
$table->json('colors')->nullable(); | ||
$table->json('variants')->nullable(); | ||
|
||
$table->boolean('active')->default(true); | ||
$table->unsignedInteger('rank')->default(0); | ||
$table->unsignedInteger('remote_id')->nullable()->index(); | ||
$table->timestamps(); | ||
|
||
$table->index(['uri', 'active']); | ||
$table->index(['category_id', 'rank']); | ||
} | ||
); | ||
|
||
$this->schema->create( | ||
'product_translations', | ||
static function (Blueprint $table) { | ||
$table->foreignId('product_id') | ||
->constrained('products')->cascadeOnDelete(); | ||
$table->char('lang', 2); | ||
|
||
$table->string('title')->nullable(); | ||
$table->string('subtitle')->nullable(); | ||
$table->text('description')->nullable(); | ||
$table->text('content')->nullable(); | ||
|
||
$table->primary(['product_id', 'lang']); | ||
} | ||
); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
$this->schema->drop('product_translations'); | ||
$this->schema->drop('products'); | ||
} | ||
} |
Oops, something went wrong.