Added check_point_times table migration
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?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('check_point_times', function (Blueprint $table) {
|
||||
// $table->id();
|
||||
// $table->timestamps();
|
||||
// });
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE check_point_times (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
check_point1_id BIGINT NOT NULL,
|
||||
check_point2_id BIGINT NOT NULL,
|
||||
|
||||
sequence_number INT NOT NULL DEFAULT (1),
|
||||
time_lapse INT NOT NULL DEFAULT (1),
|
||||
time_lapse_cushioning INT NOT NULL DEFAULT (1),
|
||||
min_cushioning INT NOT NULL DEFAULT (0),
|
||||
max_cushioning INT NOT NULL DEFAULT (2),
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
created_by TEXT NOT NULL,
|
||||
|
||||
UNIQUE (plant_id, check_point1_id, check_point2_id, sequence_number),
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (check_point1_id) REFERENCES check_point_names (id),
|
||||
FOREIGN KEY (check_point2_id) REFERENCES check_point_names (id)
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('check_point_times');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user