From 4f2e811abbd7544d3e0182bf1edcb10abbf23c6e Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 23 Jun 2025 17:42:38 +0530 Subject: [PATCH] Added guard_names table migration --- ..._06_19_152813_create_guard_names_table.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 database/migrations/2025_06_19_152813_create_guard_names_table.php diff --git a/database/migrations/2025_06_19_152813_create_guard_names_table.php b/database/migrations/2025_06_19_152813_create_guard_names_table.php new file mode 100644 index 000000000..8584fabb4 --- /dev/null +++ b/database/migrations/2025_06_19_152813_create_guard_names_table.php @@ -0,0 +1,49 @@ +id(); + // $table->timestamps(); + // }); + $sql = <<<'SQL' + CREATE TABLE guard_names ( + id BIGINT GENERATED always AS IDENTITY PRIMARY KEY, + + plant_id BIGINT NOT NULL, + + name TEXT NOT NULL, + identification1 TEXT NOT NULL, + identification2 TEXT NULL, + + 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, name), + FOREIGN KEY (plant_id) REFERENCES plants (id) + ); + SQL; + + DB::statement($sql); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('guard_names'); + } +};