feat: soft delete and rename service-related models, tables, and columns to connection-focused terms
- Renamed models, migration files, and database tables for greater consistency (e.g., `service_protocols` to `connection_protocols`, `service_providers` to `connection_providers`). - Enabled `SoftDeletes` trait on core models, including `User`, `ConnectionProvider`, `ConnectedApp`, and others. - Updated migration schemas to include `softDeletes()` and adjusted `down()` methods accordingly. - Enhanced indexing in `connected_apps` to optimize query performance.
This commit is contained in:
parent
bc69ea2f95
commit
1c5ab498d7
@ -5,7 +5,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\{Model, SoftDeletes};
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
#[Fillable([
|
#[Fillable([
|
||||||
@ -17,6 +17,8 @@
|
|||||||
])]
|
])]
|
||||||
class ConnectedApp extends Model
|
class ConnectedApp extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
public function protocol(): HasOne
|
public function protocol(): HasOne
|
||||||
{
|
{
|
||||||
return $this->hasOne(ConnectionProtocol::class, 'id', 'connection_protocol_id');
|
return $this->hasOne(ConnectionProtocol::class, 'id', 'connection_protocol_id');
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\{Model, SoftDeletes};
|
||||||
|
|
||||||
final class ConnectionProtocol extends Model {}
|
final class ConnectionProtocol extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
}
|
||||||
|
|||||||
@ -5,7 +5,10 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\{Model, SoftDeletes};
|
||||||
|
|
||||||
#[Fillable(['name', 'slug'])]
|
#[Fillable(['name', 'slug'])]
|
||||||
final class ConnectionProvider extends Model {}
|
final class ConnectionProvider extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
}
|
||||||
|
|||||||
@ -5,7 +5,10 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\{Model, SoftDeletes};
|
||||||
|
|
||||||
#[Table('connection_statuses')]
|
#[Table('connection_statuses')]
|
||||||
class ConnectionStatus extends Model {}
|
class ConnectionStatus extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
use Database\Factories\UserFactory;
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Attributes\{Fillable, Hidden};
|
use Illuminate\Database\Eloquent\Attributes\{Fillable, Hidden};
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@ -18,7 +19,7 @@
|
|||||||
final class User extends Authenticatable
|
final class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use TwoFactorAuthenticatable;
|
use TwoFactorAuthenticatable;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public function up(): void
|
|||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::create('password_reset_tokens', function (Blueprint $table): void {
|
Schema::create('password_reset_tokens', function (Blueprint $table): void {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ public function up(): void
|
|||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('slug')->unique();
|
$table->string('slug')->unique();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +27,6 @@ public function up(): void
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('service_providers');
|
Schema::dropIfExists('connection_providers');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -17,6 +17,7 @@ public function up(): void
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name')->unique();
|
$table->string('name')->unique();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,6 @@ public function up(): void
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('service_statuses');
|
Schema::dropIfExists('connection_statuses');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -17,6 +17,7 @@ public function up(): void
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name')->unique();
|
$table->string('name')->unique();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,6 @@ public function up(): void
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('service_protocols');
|
Schema::dropIfExists('connection_protocols');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -23,7 +23,8 @@ public function up(): void
|
|||||||
$table->foreignIdFor(ConnectionStatus::class);
|
$table->foreignIdFor(ConnectionStatus::class);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->index(['name', 'slug']);
|
$table->index(['name', 'slug']);
|
||||||
$table->index(['connection_protocol_id', 'connection_provider_id']);
|
$table->index(['connection_protocol_id', 'connection_provider_id'], 'ca_protocol_provider_index');
|
||||||
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +33,6 @@ public function up(): void
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('connected_services');
|
Schema::dropIfExists('connected_apps');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
@ -17,10 +18,10 @@ public function run(): void
|
|||||||
{
|
{
|
||||||
// User::factory(10)->create();
|
// User::factory(10)->create();
|
||||||
|
|
||||||
// User::factory()->create([
|
User::factory()->create([
|
||||||
// 'name' => 'Test User',
|
'name' => 'Test User',
|
||||||
// 'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
// ]);
|
]);
|
||||||
|
|
||||||
$this->call(ConnectionStatusSeeder::class);
|
$this->call(ConnectionStatusSeeder::class);
|
||||||
$this->call(ConnectionProtocolSeeder::class);
|
$this->call(ConnectionProtocolSeeder::class);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user