diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..1bea851 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -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'); } -}; +}; \ No newline at end of file diff --git a/database/migrations/2025_03_11_070823_create_customers_table.php b/database/migrations/2025_03_11_070823_create_customers_table.php new file mode 100644 index 0000000..302fabb --- /dev/null +++ b/database/migrations/2025_03_11_070823_create_customers_table.php @@ -0,0 +1,45 @@ +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'); + } +}; diff --git a/database/migrations/2025_03_11_070856_create_assets_table.php b/database/migrations/2025_03_11_070856_create_assets_table.php new file mode 100644 index 0000000..6f9f2fe --- /dev/null +++ b/database/migrations/2025_03_11_070856_create_assets_table.php @@ -0,0 +1,42 @@ +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'); + } +}; diff --git a/database/migrations/2025_03_11_070912_create_devices_table.php b/database/migrations/2025_03_11_070912_create_devices_table.php new file mode 100644 index 0000000..41426c5 --- /dev/null +++ b/database/migrations/2025_03_11_070912_create_devices_table.php @@ -0,0 +1,47 @@ +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'); + } +}; diff --git a/database/migrations/2025_03_11_075522_create_user_asset_link_table.php b/database/migrations/2025_03_11_075522_create_user_asset_link_table.php new file mode 100644 index 0000000..2ed3a46 --- /dev/null +++ b/database/migrations/2025_03_11_075522_create_user_asset_link_table.php @@ -0,0 +1,32 @@ +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'); + } +}; \ No newline at end of file