Skip to content

Commit

Permalink
Основные таблицы новой версии магазина
Browse files Browse the repository at this point in the history
  • Loading branch information
bezumkin committed Aug 14, 2023
1 parent e51c427 commit fdbaed6
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 159 deletions.
45 changes: 0 additions & 45 deletions core/db/migrations/20220617043501_products.php

This file was deleted.

55 changes: 0 additions & 55 deletions core/db/migrations/20220628050120_aliases.php

This file was deleted.

49 changes: 0 additions & 49 deletions core/db/migrations/20220705002400_orders.php

This file was deleted.

@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Schema\Blueprint;
use Vesp\Services\Migration;

Expand Down
27 changes: 27 additions & 0 deletions core/db/migrations/20230814054338_languages.php
@@ -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');
}
}
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Schema\Blueprint;
use Vesp\Services\Migration;

Expand All @@ -23,13 +25,36 @@ function (Blueprint $table) {
function (Blueprint $table) {
$table->id();
$table->string('username')->unique();
$table->string('password');
$table->string('fullname')->nullable();
$table->string('password');
$table->string('tmp_password')->nullable();
$table->string('salt')->nullable();
$table->string('email')->nullable();
$table->string('phone')->nullable();

$table->tinyInteger('gender')->nullable();
$table->string('company')->nullable();
$table->string('address')->nullable();
$table->string('country')->nullable();
$table->string('city')->nullable();
$table->string('zip')->nullable();
$table->char('lang', 2)->nullable();

$table->foreignId('role_id')
->constrained('user_roles')->cascadeOnDelete();
$table->boolean('active')->default(true)->index();
$table->foreignId('file_id')->nullable()
->constrained('files')->nullOnDelete();
$table->boolean('active')->default(true);
$table->boolean('blocked')->default(false);
$table->text('comment')->nullable();
$table->unsignedInteger('remote_id')->nullable()->index();
$table->timestamps();

$table->index(['active', 'blocked']);
$table->foreign('lang')
->references('lang')
->on('languages')
->nullOnDelete();
}
);

Expand Down
63 changes: 63 additions & 0 deletions core/db/migrations/20230814061716_categories.php
@@ -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');
}
}
66 changes: 66 additions & 0 deletions core/db/migrations/20230814062903_products.php
@@ -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');
}
}

0 comments on commit fdbaed6

Please sign in to comment.