From eae2d49e259917d98c3038d95edbddcddcd50ccb Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 23 Jun 2025 18:23:09 +0530 Subject: [PATCH] Added check_point_times table migration --- ..._174259_create_check_point_times_table.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 database/migrations/2025_06_19_174259_create_check_point_times_table.php diff --git a/database/migrations/2025_06_19_174259_create_check_point_times_table.php b/database/migrations/2025_06_19_174259_create_check_point_times_table.php new file mode 100644 index 000000000..4ef44ae64 --- /dev/null +++ b/database/migrations/2025_06_19_174259_create_check_point_times_table.php @@ -0,0 +1,55 @@ +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'); + } +};