水质监测日志模型和数据库迁移
parent
dd2b56a0d2
commit
7a0b6e3b17
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WaterQualityMonitoringLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $casts = [
|
||||
'monitored_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'device_id',
|
||||
'agricultural_base_id',
|
||||
'chlorine',
|
||||
'conductivity',
|
||||
'oxygen',
|
||||
'ph',
|
||||
'temperature',
|
||||
'turbidity',
|
||||
'monitored_at',
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('water_quality_monitoring_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('device_id')->comment('设备ID');
|
||||
$table->unsignedBigInteger('agricultural_base_id')->comment('农业基地ID');
|
||||
$table->decimal('chlorine', 8, 2)->nullable()->comment('余氯 (单位: mg/L)');
|
||||
$table->decimal('conductivity', 8, 2)->nullable()->comment('电导率 (单位: us/cm)');
|
||||
$table->decimal('oxygen', 8, 2)->nullable()->comment('溶解氧 (单位: mg/L)');
|
||||
$table->decimal('ph', 8, 2)->nullable()->comment('PH');
|
||||
$table->decimal('temperature', 8, 2)->nullable()->comment('温度 (单位: ℃)');
|
||||
$table->decimal('turbidity', 8, 2)->nullable()->comment('浊度 (单位: NTU)');
|
||||
$table->timestamp('monitored_at')->comment('监控时间(小时)');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('device_id');
|
||||
$table->index('agricultural_base_id');
|
||||
$table->unique('monitored_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('water_quality_monitoring_logs');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue