Migration files

This commit is contained in:
kshitige
2025-03-11 13:49:55 +05:30
parent d8aaa2c691
commit bfd8a0de09
5 changed files with 190 additions and 20 deletions

View File

@@ -12,29 +12,33 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->uuid('id')->primary();
$table->bigInteger('created_time');
$table->integer('tenant_id');
$table->uuid('customer_id');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->string('authority', 50);
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('phone', 20)->nullable();
$table->integer('version');
$table->string('name');
$table->text('description')->nullable();
$table->uuid('default_dashboard_id')->nullable();
$table->boolean('default_dashboard_fullscreen')->default(false);
$table->uuid('home_dashboard_id')->nullable();
$table->boolean('home_dashboard_hide_toolbar')->default(true);
$table->boolean('user_credentials_enabled')->default(true);
$table->integer('failed_login_attempts')->default(0);
$table->bigInteger('last_login_ts')->nullable();
// Foreign keys
// $table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('cascade');
// $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
$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();
});
}
/**
@@ -46,4 +50,4 @@ return new class extends Migration
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
};

View File

@@ -0,0 +1,45 @@
<?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('customers', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('entity_type')->default('CUSTOMER');
$table->bigInteger('created_time');
$table->string('name');
$table->string('country', 5)->nullable();
$table->string('state', 50)->nullable();
$table->string('city', 100)->nullable();
$table->string('address')->nullable();
$table->string('address2')->nullable();
$table->string('zip', 20)->nullable();
$table->string('phone', 20)->nullable();
$table->string('email')->unique();
$table->string('title')->nullable();
$table->uuid('tenant_id');
$table->uuid('external_id')->nullable();
$table->integer('version')->default(1);
$table->json('additional_info')->nullable();
$table->timestamps();
// $table->foreign('tenant_id')->references('id')->on('tenants');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('customers');
}
};

View File

@@ -0,0 +1,42 @@
<?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('assets', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('entity_type')->default('ASSET');
$table->bigInteger('created_time');
$table->uuid('tenant_id');
$table->uuid('customer_xid');
$table->string('name');
$table->string('type');
$table->string('label')->nullable();
$table->uuid('asset_profile_id');
$table->uuid('external_id')->nullable();
$table->integer('version')->default(1);
$table->json('additional_info')->nullable();
$table->timestamps();
// $table->foreign('tenant_id')->references('id')->on('tenants');
// $table->foreign('customer_id')->references('id')->on('customers');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('assets');
}
};

View File

@@ -0,0 +1,47 @@
<?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('devices', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('entity_type')->default('DEVICE');
$table->bigInteger('created_time');
$table->uuid('tenant_id');
$table->uuid('customer_id');
$table->uuid('asset_id');
$table->string('name');
$table->string('type');
$table->string('label')->nullable();
$table->uuid('device_profile_id');
$table->uuid('firmware_id')->nullable();
$table->uuid('software_id')->nullable();
$table->uuid('external_id')->nullable();
$table->integer('version')->default(1);
$table->json('additional_info')->nullable();
$table->json('device_data')->nullable();
$table->timestamps();
// $table->foreign('tenant_id')->references('id')->on('tenants');
// $table->foreign('customer_id')->references('id')->on('customers');
// $table->foreign('asset_id')->references('id')->on('assets');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('devices');
}
};

View File

@@ -0,0 +1,32 @@
<?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('user_asset_link', function (Blueprint $table) {
$table->id();
$table->uuid('user_id');
$table->uuid('asset_id');
$table->timestamps();
// $table->foreign('user_id')->references('id')->on('users');
// $table->foreign('asset_id')->references('id')->on('assets');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_asset_link');
}
};