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'); + } +};