This commit is contained in:
2024-10-12 16:17:16 +02:00
commit 1bdefcff66
65 changed files with 10816 additions and 0 deletions

1
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');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* 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,33 @@
<?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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,128 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('code')->unique();
$table->text('url')->nullable();
$table->string('creator')->nullable();
$table->bigInteger('created_t')->nullable();
$table->string('created_datetime')->nullable();
$table->bigInteger('last_modified_t')->nullable();
$table->string('last_modified_datetime')->nullable();
$table->string('last_modified_by')->nullable();
$table->bigInteger('last_updated_t')->nullable();
$table->string('last_updated_datetime')->nullable();
$table->text('product_name')->nullable();
$table->text('abbreviated_product_name')->nullable();
$table->text('generic_name')->nullable();
$table->string('quantity')->nullable();
$table->text('packaging')->nullable();
$table->text('packaging_tags')->nullable();
$table->text('packaging_en')->nullable();
$table->text('packaging_text')->nullable();
$table->text('brands')->nullable();
$table->text('brands_tags')->nullable();
$table->text('categories')->nullable();
$table->text('categories_tags')->nullable();
$table->text('categories_en')->nullable();
$table->text('origins')->nullable();
$table->text('origins_tags')->nullable();
$table->text('origins_en')->nullable();
$table->text('manufacturing_places')->nullable();
$table->text('manufacturing_places_tags')->nullable();
$table->text('labels')->nullable();
$table->text('labels_tags')->nullable();
$table->text('labels_en')->nullable();
$table->text('emb_codes')->nullable();
$table->text('emb_codes_tags')->nullable();
$table->text('first_packaging_code_geo')->nullable();
$table->text('cities')->nullable();
$table->text('cities_tags')->nullable();
$table->text('purchase_places')->nullable();
$table->text('stores')->nullable();
$table->text('countries')->nullable();
$table->text('countries_tags')->nullable();
$table->text('countries_en')->nullable();
$table->text('ingredients_text')->nullable();
$table->text('ingredients_tags')->nullable();
$table->text('ingredients_analysis_tags')->nullable();
$table->text('allergens')->nullable();
$table->text('allergens_en')->nullable();
$table->text('traces')->nullable();
$table->text('traces_tags')->nullable();
$table->text('traces_en')->nullable();
$table->text('serving_size')->nullable();
$table->float('serving_quantity')->nullable();
$table->boolean('no_nutrition_data')->default(false);
$table->integer('additives_n')->nullable();
$table->text('additives')->nullable();
$table->text('additives_tags')->nullable();
$table->text('additives_en')->nullable();
$table->integer('nutriscore_score')->nullable();
$table->string('nutriscore_grade')->nullable();
$table->integer('nova_group')->nullable();
$table->text('pnns_groups_1')->nullable();
$table->text('pnns_groups_2')->nullable();
$table->text('food_groups')->nullable();
$table->text('food_groups_tags')->nullable();
$table->text('food_groups_en')->nullable();
$table->text('states')->nullable();
$table->text('states_tags')->nullable();
$table->text('states_en')->nullable();
$table->text('brand_owner')->nullable();
$table->integer('ecoscore_score')->nullable();
$table->string('ecoscore_grade')->nullable();
$table->text('nutrient_levels_tags')->nullable();
$table->string('product_quantity')->nullable();
$table->string('owner')->nullable();
$table->text('data_quality_errors_tags')->nullable();
$table->integer('unique_scans_n')->nullable();
$table->text('popularity_tags')->nullable();
$table->float('completeness')->nullable();
$table->bigInteger('last_image_t')->nullable();
$table->string('last_image_datetime')->nullable();
$table->text('main_category')->nullable();
$table->text('main_category_en')->nullable();
$table->text('image_url')->nullable();
$table->text('image_small_url')->nullable();
$table->text('image_ingredients_url')->nullable();
$table->text('image_ingredients_small_url')->nullable();
$table->text('image_nutrition_url')->nullable();
$table->text('image_nutrition_small_url')->nullable();
$table->timestamps();
});
Schema::create('ingredients', function (Blueprint $table) {
$table->id();
$table->string('product_code');
$table->foreign('product_code')->references('code')->on('products')->onDelete('cascade');
$table->text('name');
$table->timestamps();
});
Schema::create('nutrition_facts', function (Blueprint $table) {
$table->id();
$table->string('product_code');
$table->foreign('product_code')->references('code')->on('products')->onDelete('cascade');
$table->string('nutrient');
$table->float('amount')->nullable();
$table->string('unit')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('nutrition_facts');
Schema::dropIfExists('ingredients');
Schema::dropIfExists('products');
}
};

View File

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