fix(db): SSL certificates table and model
- server_id is a foreign id - server_id must be unique as each server can only have 1 CA cert - resource_id must be unique as each resource can only have 1 SSL cert
This commit is contained in:
parent
0915303769
commit
34216af497
2 changed files with 10 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ class SslCertificate extends Model
|
|||
'ssl_private_key',
|
||||
'resource_type',
|
||||
'resource_id',
|
||||
'server_id',
|
||||
'valid_until',
|
||||
];
|
||||
|
||||
|
|
@ -24,4 +25,9 @@ public function resource()
|
|||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
public function server()
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ public function up()
|
|||
$table->text('ssl_private_key');
|
||||
$table->string('resource_type')->nullable();
|
||||
$table->unsignedBigInteger('resource_id')->nullable();
|
||||
$table->timestamp('valid_until')->nullable();
|
||||
$table->unsignedBigInteger('server_id')->nullable();
|
||||
$table->timestamp('valid_until');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['resource_type', 'resource_id']);
|
||||
$table->foreign('server_id')->references('id')->on('servers');
|
||||
$table->unique(['server_id', 'resource_id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue