Skip to content

Commit

Permalink
Merge pull request #94 from EscolaLMS/feature/#51
Browse files Browse the repository at this point in the history
Change migrate in tables
  • Loading branch information
KrzysztofDziedziechEscolasoft authored Apr 11, 2022
2 parents 98a9a18 + 6f3be09 commit c04938a
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
.phpunit.result.cache
composer.lock
openapi.json
openapi.json
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ChangeHh5pContentsLibrariesStructureTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('hh5p_contents_libraries', function (Blueprint $table) {
$table->dropPrimary('hh5p_contents_libraries_pkey');
$table->unique(['content_id', 'library_id', 'dependency_type'], 'hh5p_contents_libraries_unique_key');
});
Schema::table('hh5p_contents_libraries', function (Blueprint $table) {
$table->id();
});
Schema::table('hh5p_libraries_languages', function (Blueprint $table) {
$table->dropPrimary('hh5p_libraries_languages_pkey');
$table->unique(['library_id', 'language_code'], 'hh5p_libraries_languages_unique_key');
});
Schema::table('hh5p_libraries_languages', function (Blueprint $table) {
$table->id();
});
Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) {
$table->dropPrimary('hh5p_libraries_dependencies_pkey');
$table->unique(['library_id', 'required_library_id'], 'hh5p_libraries_dependencies_unique_key');
});
Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) {
$table->id();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('hh5p_contents_libraries', function (Blueprint $table) {
$table->dropColumn('id');
});
Schema::table('hh5p_contents_libraries', function (Blueprint $table) {
$table->dropUnique('hh5p_contents_libraries_unique_key');
});
Schema::table('hh5p_libraries_languages', function (Blueprint $table) {
$table->dropUnique('hh5p_libraries_languages_unique_key');
});
Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) {
$table->dropUnique('hh5p_libraries_dependencies_unique_key');
});
Schema::table('hh5p_contents_libraries', function (Blueprint $table) {
$table->primary(['content_id', 'library_id', 'dependency_type'], 'fk_primary');
});
Schema::table('hh5p_libraries_languages', function (Blueprint $table) {
$table->dropColumn('id');
});
Schema::table('hh5p_libraries_languages', function (Blueprint $table) {
$table->primary(['library_id', 'language_code'], 'fk_primary');
});
Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) {
$table->dropColumn('id');
});
Schema::table('hh5p_libraries_dependencies', function (Blueprint $table) {
$table->primary(['library_id', 'required_library_id'], 'fk_primary');
});
}
}
20 changes: 10 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<testsuite name="Escola LMS Auth">
<directory suffix="Test.php">./tests</directory>
</testsuite>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="APP_DEBUG" value="true"/>
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_HOST" value="mysql"/>
<env name="DB_PORT" value="3306"/>
<env name="DB_DATABASE" value="database"/>
<env name="DB_USERNAME" value="username"/>
<env name="DB_PASSWORD" value="password"/>
</php>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="APP_DEBUG" value="true"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_HOST" value="127.0.0.1"/>
<env name="DB_PORT" value="5432"/>
<env name="DB_DATABASE" value="default"/>
<env name="DB_USERNAME" value="default"/>
<env name="DB_PASSWORD" value="secret"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Models/H5PContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EscolaLms\HeadlessH5P\Models;

use App\User;
use EscolaLms\Core\Models\User;
use EscolaLms\HeadlessH5P\Database\Factories\H5PContentFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down
2 changes: 0 additions & 2 deletions src/Models/H5PContentLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class H5PContentLibrary extends Model

protected $table = 'hh5p_contents_libraries';

protected $primaryKey = ['content_id', 'library_id', 'dependency_type'];

protected $fillable = [
'content_id',
'library_id',
Expand Down
1 change: 0 additions & 1 deletion src/Models/H5PLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class H5PLibrary extends Model
use HasFactory;

protected $table = 'hh5p_libraries';
//protected $primaryKey = 'id';
protected $fillable = [
'name',
'title',
Expand Down
2 changes: 0 additions & 2 deletions src/Models/H5PLibraryDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class H5PLibraryDependency extends Model
public $timestamps = false;

protected $table = 'hh5p_libraries_dependencies';

protected $primaryKey = ['library_id', 'required_library_id'];

protected $fillable = [
'library_id',
Expand Down
4 changes: 1 addition & 3 deletions src/Models/H5PLibraryLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class H5PLibraryLanguage extends Model
public $timestamps = false;

protected $table = 'hh5p_libraries_languages';

protected $primaryKey = ['library_id', 'language_code'];

protected $fillable = [
'library_id',
Expand All @@ -26,7 +24,7 @@ public function getTranslationAttribute($value)
{
return json_decode($value);
}


public function library():BelongsTo
{
Expand Down
1 change: 0 additions & 1 deletion src/Models/H5PTempFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class H5PTempFile extends Model
{
protected $primaryKey = 'id';
protected $table = 'hh5p_temp_files';
protected $fillable = [
'path',
Expand Down

0 comments on commit c04938a

Please sign in to comment.