Save user flights
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('flight_classes', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('id')->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
|
||||
Schema::create('seat_types', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('id')->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
|
||||
Schema::create('flight_reasons', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('id')->primary();
|
||||
$table->string('name');
|
||||
});
|
||||
|
||||
DB::table('flight_classes')->insert([
|
||||
['id' => 0, 'name' => 'Unspecified'],
|
||||
['id' => 1, 'name' => 'Economy'],
|
||||
['id' => 2, 'name' => 'Business'],
|
||||
['id' => 3, 'name' => 'First'],
|
||||
['id' => 4, 'name' => 'Premium Economy'],
|
||||
['id' => 5, 'name' => 'Private'],
|
||||
]);
|
||||
|
||||
DB::table('seat_types')->insert([
|
||||
['id' => 0, 'name' => 'Unspecified'],
|
||||
['id' => 1, 'name' => 'Window'],
|
||||
['id' => 2, 'name' => 'Middle'],
|
||||
['id' => 3, 'name' => 'Aisle'],
|
||||
]);
|
||||
|
||||
DB::table('flight_reasons')->insert([
|
||||
['id' => 0, 'name' => 'No Particular Reason'],
|
||||
['id' => 1, 'name' => 'Pleasure'],
|
||||
['id' => 2, 'name' => 'Business'],
|
||||
['id' => 3, 'name' => 'Crew'],
|
||||
['id' => 4, 'name' => 'Other'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('flight_reasons');
|
||||
Schema::dropIfExists('seat_types');
|
||||
Schema::dropIfExists('flight_classes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_flights', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestampTz('departure_date');
|
||||
$table->timestampTz('arrival_date');
|
||||
$table->string('flight_number')->nullable();
|
||||
$table->foreignId('departure_airport_id')->constrained('airports');
|
||||
$table->foreignId('arrival_airport_id')->constrained('airports');
|
||||
$table->foreignId('airline_id')->nullable()->constrained('airlines');
|
||||
$table->foreignId('aircraft_id')->nullable()->constrained('aircraft');
|
||||
$table->string('aircraft_registration')->nullable();
|
||||
$table->string('seat_number')->nullable();
|
||||
$table->unsignedTinyInteger('seat_type_id')->nullable();
|
||||
$table->unsignedTinyInteger('flight_reason_id')->nullable();
|
||||
$table->unsignedTinyInteger('flight_class_id')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('seat_type_id')->references('id')->on('seat_types');
|
||||
$table->foreign('flight_reason_id')->references('id')->on('flight_reasons');
|
||||
$table->foreign('flight_class_id')->references('id')->on('flight_classes');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_flights');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user