parent
34e4ed5d9b
commit
52ab2c474e
@ -0,0 +1,20 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class Changeset extends Model |
||||
{ |
||||
/** Parent data table */ |
||||
public function dataTable() |
||||
{ |
||||
return $this->belongsTo(DataTable::class); |
||||
} |
||||
|
||||
/** Author who created it user */ |
||||
public function author() |
||||
{ |
||||
return $this->belongsTo(User::class, 'author_id'); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class DataRow extends Model |
||||
{ |
||||
/** Parent data table */ |
||||
public function dataTable() |
||||
{ |
||||
return $this->belongsTo(DataTable::class); |
||||
} |
||||
} |
@ -1,10 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot; |
||||
|
||||
class DiscussionFollow extends Pivot |
||||
{ |
||||
// |
||||
} |
@ -1,10 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class TableComment extends Model |
||||
{ |
||||
// |
||||
} |
@ -1,10 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot; |
||||
|
||||
class TableFavourite extends Pivot |
||||
{ |
||||
// |
||||
} |
@ -1,10 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
class TableRevision extends Model |
||||
{ |
||||
// |
||||
} |
@ -1,10 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot; |
||||
|
||||
class UserFollow extends Pivot |
||||
{ |
||||
// |
||||
} |
@ -0,0 +1,44 @@ |
||||
<?php |
||||
|
||||
use Illuminate\Support\Facades\Schema; |
||||
use Illuminate\Database\Schema\Blueprint; |
||||
use Illuminate\Database\Migrations\Migration; |
||||
|
||||
class CreateChangesetsTable extends Migration |
||||
{ |
||||
/** |
||||
* Run the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function up() |
||||
{ |
||||
Schema::create('changesets', function (Blueprint $table) { |
||||
$table->increments('id'); |
||||
$table->timestamp('created_at'); |
||||
$table->unsignedInteger('data_table_id')->index(); |
||||
$table->unsignedInteger('target_revision'); |
||||
$table->boolean('applied'); |
||||
$table->unsignedInteger('author_id')->index()->nullable(); |
||||
$table->longText('content'); // incremental changeset including original row values so that it can be reversed |
||||
|
||||
$table->foreign('data_table_id')->references('id')->on('data_tables') |
||||
->onDelete('cascade'); |
||||
|
||||
// Deleting a user should not delete their applied patches, as that would break history. |
||||
// We set the author to null and unmerged patches may be cleaned manually or by a separate query. |
||||
$table->foreign('author_id')->references('id')->on('users') |
||||
->onDelete('set null'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Reverse the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function down() |
||||
{ |
||||
Schema::dropIfExists('changesets'); |
||||
} |
||||
} |
@ -0,0 +1,35 @@ |
||||
<?php |
||||
|
||||
use Illuminate\Support\Facades\Schema; |
||||
use Illuminate\Database\Schema\Blueprint; |
||||
use Illuminate\Database\Migrations\Migration; |
||||
|
||||
class CreateDataRowsTable extends Migration |
||||
{ |
||||
/** |
||||
* Run the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function up() |
||||
{ |
||||
Schema::create('data_rows', function (Blueprint $table) { |
||||
$table->increments('id'); |
||||
$table->unsignedInteger('data_table_id')->index(); |
||||
$table->longtext('data'); |
||||
|
||||
$table->foreign('data_table_id')->references('id')->on('data_tables') |
||||
->onDelete('cascade'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Reverse the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function down() |
||||
{ |
||||
Schema::dropIfExists('data_rows'); |
||||
} |
||||
} |
Loading…
Reference in new issue