first commit

This commit is contained in:
2026-02-15 01:34:17 +07:00
commit baac22e3ae
95 changed files with 13238 additions and 0 deletions

1
laravel/database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,84 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement(
"
CREATE TABLE stocks (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
date DATE NULL,
last_change_date DATE NULL,
supplier_article VARCHAR(255) NULL,
tech_size VARCHAR(255) NULL,
barcode VARCHAR(255) NULL,
quantity INT NOT NULL DEFAULT 0,
is_supply TINYINT(1) NULL,
is_realization TINYINT(1) NULL,
quantity_full INT NULL,
warehouse_name VARCHAR(255) NULL,
in_way_to_client INT NULL,
in_way_from_client INT NULL,
nm_id BIGINT NULL,
subject VARCHAR(255) NULL,
category VARCHAR(255) NULL,
brand VARCHAR(255) NULL,
sc_code VARCHAR(255) NULL,
price VARCHAR(255) NULL,
discount VARCHAR(255) NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL,
PRIMARY KEY (id, date),
INDEX idx_warehouse_date (warehouse_name, date),
INDEX idx_nm_id_date (nm_id, date),
INDEX idx_barcode_date (barcode, date)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
PARTITION BY RANGE COLUMNS(date) (
PARTITION p202602 VALUES LESS THAN ('2026-03-01'),
PARTITION p202603 VALUES LESS THAN ('2026-04-01'),
PARTITION p202604 VALUES LESS THAN ('2026-05-01'),
PARTITION p202605 VALUES LESS THAN ('2026-06-01'),
PARTITION p202606 VALUES LESS THAN ('2026-07-01'),
PARTITION p202607 VALUES LESS THAN ('2026-08-01'),
PARTITION p202608 VALUES LESS THAN ('2026-09-01'),
PARTITION p202609 VALUES LESS THAN ('2026-10-01'),
PARTITION p202610 VALUES LESS THAN ('2026-11-01'),
PARTITION p202611 VALUES LESS THAN ('2026-12-01'),
PARTITION p202612 VALUES LESS THAN ('2027-01-01'),
PARTITION p202701 VALUES LESS THAN ('2027-02-01'),
PARTITION p202702 VALUES LESS THAN ('2027-03-01'),
PARTITION p202703 VALUES LESS THAN ('2027-04-01'),
PARTITION p202704 VALUES LESS THAN ('2027-05-01'),
PARTITION p202705 VALUES LESS THAN ('2027-06-01'),
PARTITION p202706 VALUES LESS THAN ('2027-07-01'),
PARTITION p202707 VALUES LESS THAN ('2027-08-01'),
PARTITION p202708 VALUES LESS THAN ('2027-09-01'),
PARTITION p202709 VALUES LESS THAN ('2027-10-01'),
PARTITION p202710 VALUES LESS THAN ('2027-11-01'),
PARTITION p202711 VALUES LESS THAN ('2027-12-01'),
PARTITION p202712 VALUES LESS THAN ('2028-01-01'),
PARTITION future VALUES LESS THAN (MAXVALUE)
)
"
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('stocks');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sync_states', function (Blueprint $table) {
$table->id();
$table->string('entity');
$table->timestamp('started_at')->nullable();
$table->date('date_from');
$table->date('date_to')->nullable();
$table->string('status');
$table->string('batch_id')->nullable();
$table->integer('total_pages')->nullable();
$table->integer('processed_pages')->default(0);
$table->timestamps();
$table->unique(['entity', 'date_from', 'date_to']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sync_states');
}
};

View File

@@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement(
"
CREATE TABLE incomes (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
income_id BIGINT NOT NULL,
number VARCHAR(255) NULL,
date DATE NULL,
last_change_date DATE NULL,
supplier_article VARCHAR(255) NULL,
tech_size VARCHAR(255) NULL,
barcode BIGINT NULL,
quantity INT NOT NULL DEFAULT 0,
total_price VARCHAR(255) NULL,
date_close DATE NULL,
warehouse_name VARCHAR(255) NULL,
nm_id BIGINT NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL,
PRIMARY KEY (id, date),
INDEX idx_warehouse_date (warehouse_name, date),
INDEX idx_nm_id_date (nm_id, date),
INDEX idx_barcode_date (barcode, date)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
PARTITION BY RANGE COLUMNS(date) (
PARTITION p202602 VALUES LESS THAN ('2026-03-01'),
PARTITION p202603 VALUES LESS THAN ('2026-04-01'),
PARTITION p202604 VALUES LESS THAN ('2026-05-01'),
PARTITION p202605 VALUES LESS THAN ('2026-06-01'),
PARTITION p202606 VALUES LESS THAN ('2026-07-01'),
PARTITION p202607 VALUES LESS THAN ('2026-08-01'),
PARTITION p202608 VALUES LESS THAN ('2026-09-01'),
PARTITION p202609 VALUES LESS THAN ('2026-10-01'),
PARTITION p202610 VALUES LESS THAN ('2026-11-01'),
PARTITION p202611 VALUES LESS THAN ('2026-12-01'),
PARTITION p202612 VALUES LESS THAN ('2027-01-01'),
PARTITION p202701 VALUES LESS THAN ('2027-02-01'),
PARTITION p202702 VALUES LESS THAN ('2027-03-01'),
PARTITION p202703 VALUES LESS THAN ('2027-04-01'),
PARTITION p202704 VALUES LESS THAN ('2027-05-01'),
PARTITION p202705 VALUES LESS THAN ('2027-06-01'),
PARTITION p202706 VALUES LESS THAN ('2027-07-01'),
PARTITION p202707 VALUES LESS THAN ('2027-08-01'),
PARTITION p202708 VALUES LESS THAN ('2027-09-01'),
PARTITION p202709 VALUES LESS THAN ('2027-10-01'),
PARTITION p202710 VALUES LESS THAN ('2027-11-01'),
PARTITION p202711 VALUES LESS THAN ('2027-12-01'),
PARTITION p202712 VALUES LESS THAN ('2028-01-01'),
PARTITION future VALUES LESS THAN (MAXVALUE)
)
"
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('incomes');
}
};

View File

@@ -0,0 +1,80 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement(
"
CREATE TABLE sales (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
g_number VARCHAR(255) NOT NULL,
date DATE NULL,
last_change_date DATE NULL,
supplier_article VARCHAR(255) NULL,
tech_size VARCHAR(255) NULL,
barcode BIGINT NULL,
total_price VARCHAR(255) NULL,
discount_percent TINYINT NULL,
is_supply BOOLEAN NOT NULL DEFAULT FALSE,
is_realization BOOLEAN NOT NULL DEFAULT FALSE,
promo_code_discount VARCHAR(255) NULL,
warehouse_name VARCHAR(255) NULL,
country_name VARCHAR(255) NULL,
oblast_okrug_name VARCHAR(255) NULL,
region_name VARCHAR(255) NULL,
income_id BIGINT NULL,
sale_id VARCHAR(255) NULL,
odid BIGINT NULL,
spp VARCHAR(10) NULL,
for_pay DECIMAL(12,2) NULL,
finished_price DECIMAL(12,2) NULL,
price_with_disc DECIMAL(12,2) NULL,
nm_id BIGINT NULL,
subject VARCHAR(255) NULL,
category VARCHAR(255) NULL,
brand VARCHAR(255) NULL,
is_storno BOOLEAN NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL,
PRIMARY KEY (id, date),
INDEX idx_warehouse_date (warehouse_name, date),
INDEX idx_nm_id_date (nm_id, date),
INDEX idx_barcode_date (barcode, date)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
PARTITION BY RANGE COLUMNS(date) (
PARTITION p202602 VALUES LESS THAN ('2026-03-01'),
PARTITION p202603 VALUES LESS THAN ('2026-04-01'),
PARTITION p202604 VALUES LESS THAN ('2026-05-01'),
PARTITION p202605 VALUES LESS THAN ('2026-06-01'),
PARTITION p202606 VALUES LESS THAN ('2026-07-01'),
PARTITION p202607 VALUES LESS THAN ('2026-08-01'),
PARTITION p202608 VALUES LESS THAN ('2026-09-01'),
PARTITION p202609 VALUES LESS THAN ('2026-10-01'),
PARTITION p202610 VALUES LESS THAN ('2026-11-01'),
PARTITION p202611 VALUES LESS THAN ('2026-12-01'),
PARTITION p202612 VALUES LESS THAN ('2027-01-01'),
PARTITION p202701 VALUES LESS THAN ('2027-02-01'),
PARTITION future VALUES LESS THAN (MAXVALUE)
)
"
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sales');
}
};

View File

@@ -0,0 +1,84 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement(
"
CREATE TABLE orders (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
g_number VARCHAR(255) NOT NULL,
date DATETIME NULL,
last_change_date DATE NULL,
supplier_article VARCHAR(255) NULL,
tech_size VARCHAR(255) NULL,
barcode BIGINT NULL,
total_price VARCHAR(255) NULL,
discount_percent TINYINT NULL,
warehouse_name VARCHAR(255) NULL,
oblast VARCHAR(255) NULL,
income_id BIGINT NULL,
odid BIGINT NULL,
nm_id BIGINT NULL,
subject VARCHAR(255) NULL,
category VARCHAR(255) NULL,
brand VARCHAR(255) NULL,
is_cancel BOOLEAN NOT NULL DEFAULT FALSE,
cancel_dt DATETIME NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL,
PRIMARY KEY (id, date),
INDEX idx_warehouse_date (warehouse_name, date),
INDEX idx_nm_id_date (nm_id, date),
INDEX idx_barcode_date (barcode, date)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
PARTITION BY RANGE COLUMNS(date) (
PARTITION p202402 VALUES LESS THAN ('2024-03-01'),
PARTITION p202403 VALUES LESS THAN ('2024-04-01'),
PARTITION p202404 VALUES LESS THAN ('2024-05-01'),
PARTITION p202405 VALUES LESS THAN ('2024-06-01'),
PARTITION p202406 VALUES LESS THAN ('2024-07-01'),
PARTITION p202407 VALUES LESS THAN ('2024-08-01'),
PARTITION p202408 VALUES LESS THAN ('2024-09-01'),
PARTITION p202409 VALUES LESS THAN ('2024-10-01'),
PARTITION p202410 VALUES LESS THAN ('2024-11-01'),
PARTITION p202411 VALUES LESS THAN ('2024-12-01'),
PARTITION p202412 VALUES LESS THAN ('2025-01-01'),
PARTITION p202501 VALUES LESS THAN ('2025-02-01'),
PARTITION p202502 VALUES LESS THAN ('2025-03-01'),
PARTITION p202503 VALUES LESS THAN ('2025-04-01'),
PARTITION p202504 VALUES LESS THAN ('2025-05-01'),
PARTITION p202505 VALUES LESS THAN ('2025-06-01'),
PARTITION p202506 VALUES LESS THAN ('2025-07-01'),
PARTITION p202507 VALUES LESS THAN ('2025-08-01'),
PARTITION p202508 VALUES LESS THAN ('2025-09-01'),
PARTITION p202509 VALUES LESS THAN ('2025-10-01'),
PARTITION p202510 VALUES LESS THAN ('2025-11-01'),
PARTITION p202511 VALUES LESS THAN ('2025-12-01'),
PARTITION p202512 VALUES LESS THAN ('2026-01-01'),
PARTITION p202601 VALUES LESS THAN ('2026-02-01'),
PARTITION p202602 VALUES LESS THAN ('2026-03-01'),
PARTITION future VALUES LESS THAN (MAXVALUE)
)
"
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('orders');
}
};

View File

@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
}
}