remove ref counting, will be replaced by cleanup jobs or triggers
This commit is contained in:
@@ -25,22 +25,6 @@ class Proposal extends Model
|
||||
use Reportable;
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function(Proposal $self) {
|
||||
$self->reportsOf()->delete();
|
||||
|
||||
// update refcounts
|
||||
$rev = $self->revision;
|
||||
$rev->decrement('refs');
|
||||
|
||||
// Delete the revision if it has no other refs (manually, to update row refs)
|
||||
if ($rev->refs <= 0) $rev->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/** Authoring user */
|
||||
public function author()
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ use Riesjart\Relaquent\Model\Concerns\HasRelaquentRelationships;
|
||||
* @property int $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property int $refs
|
||||
* @property int $ancestor_id
|
||||
* @property string $note
|
||||
* @property object $columns
|
||||
@@ -26,18 +25,6 @@ class Revision extends Model
|
||||
use HasRelaquentRelationships;
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function(Revision $self) {
|
||||
// update refcounts
|
||||
$self->rows()->decrement('refs');
|
||||
|
||||
$self->rows()->where('refs', '<=', 0)->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/** Included rows */
|
||||
public function rows()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* Row in a data table
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $refs
|
||||
* @property string $data - JSONB
|
||||
*/
|
||||
class Row extends Model
|
||||
|
||||
@@ -35,23 +35,6 @@ class Table extends Model
|
||||
use Reportable;
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function(Table $self) {
|
||||
// update revision refcounts
|
||||
$self->revisions()->decrement('refs');
|
||||
|
||||
$self->reportsOf()->delete();
|
||||
|
||||
// delete revisions with zero refs (manually, to properly cascade to rows)
|
||||
foreach ($self->revisions()->where('refs', '<=', 0)->get() as $rev) {
|
||||
$rev->delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Owning user */
|
||||
public function owner()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user