- change relation between document and dataset_subjects to M : n:
a. during creating a dataste, also find existing keywords and attach them b. DatasetExtension.php c. Subject.php: protected $table = 'dataset_subjects'; d. migration file for crete_dataset_subjects_table - change api routes for also using url alias if defined - composer updates: composer.lock
This commit is contained in:
parent
105e31dbbd
commit
75b37368e4
7 changed files with 115 additions and 34 deletions
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDatasetSubjects extends Migration
|
||||
{
|
||||
// php artisan make:migration create_dataset_subjects_table --table=dataset_subjects --create=dataset_subjects
|
||||
// php artisan migrate
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('dataset_subjects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('language', 3)->nullable();
|
||||
$table->enum(
|
||||
'type',
|
||||
['uncontrolled']
|
||||
);
|
||||
$table->string('value', 255);
|
||||
$table->string('external_key', 255)->nullable();
|
||||
$table->nullableTimestamps();
|
||||
});
|
||||
|
||||
Schema::create('link_dataset_subjects', function (Blueprint $table) {
|
||||
// $table->increments('id');
|
||||
|
||||
$table->unsignedInteger('subject_id')->index();
|
||||
$table->foreign('subject_id')
|
||||
->references('id')->on('dataset_subjects')
|
||||
->onDelete('no action')->onUpdate('no action'); //detach the relation via code
|
||||
|
||||
$table->unsignedInteger('document_id')->index();
|
||||
$table->foreign('document_id')
|
||||
->references('id')->on('documents')
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
|
||||
$table->primary(['subject_id', 'document_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('link_dataset_subjects');
|
||||
Schema::dropIfExists('dataset_subjects');
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue