diff options
author | Devian <devianleong@gmail.com> | 2021-04-30 12:59:12 +0800 |
---|---|---|
committer | Devian <devianleong@gmail.com> | 2021-04-30 12:59:12 +0800 |
commit | 9b10a3453e0b95178a84a87077f4e160f5b7bba4 (patch) | |
tree | 16f299dba39d9f4685757b2a1653fc35bd1a4ca8 | |
parent | 878362c0f34c5240871dc2eb6cc26b35fedd89bf (diff) |
Fixed migration
-rw-r--r-- | database/migrations/create_scorm_tables.php.stub | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/database/migrations/create_scorm_tables.php.stub b/database/migrations/create_scorm_tables.php.stub index 319434c..c246365 100644 --- a/database/migrations/create_scorm_tables.php.stub +++ b/database/migrations/create_scorm_tables.php.stub @@ -22,7 +22,6 @@ class CreateScormTables extends Migration // scorm_model Schema::create($tableNames['scorm_table'], function (Blueprint $table) { $table->bigIncrements('id'); - $table->morphs('resource'); $table->string('version'); $table->string('hash_name'); $table->string('origin_file')->nullable(); @@ -35,9 +34,9 @@ class CreateScormTables extends Migration // scorm_sco_model Schema::create($tableNames['scorm_sco_table'], function (Blueprint $table) use ($tableNames) { $table->bigIncrements('id'); - $table->bigInteger('scorm_id'); + $table->bigInteger('scorm_id')->unsigned(); $table->string('uuid'); - $table->bigInteger('sco_parent_id')->nullable(); + $table->bigInteger('sco_parent_id')->unsigned()->nullable(); $table->string('entry_url')->nullable(); $table->string('identifier'); $table->string('title'); @@ -59,8 +58,8 @@ class CreateScormTables extends Migration // scorm_sco_tracking_model Schema::create($tableNames['scorm_sco_tracking_table'], function (Blueprint $table) use ($tableNames) { $table->bigIncrements('id'); - $table->bigInteger('user_id'); - $table->bigInteger('sco_id'); + $table->bigInteger('user_id')->unsigned(); + $table->bigInteger('sco_id')->unsigned(); $table->string('uuid'); $table->double('progression'); $table->integer('score_raw')->nullable(); @@ -97,16 +96,26 @@ class CreateScormTables extends Migration */ public function down() { - $tableNames = config('permission.table_names'); + $tableNames = config('scorm_sco_tracking_table'); if (empty($tableNames)) { - throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + throw new \Exception('Error: Table not found.'); } - Schema::drop($tableNames['role_has_permissions']); - Schema::drop($tableNames['model_has_roles']); - Schema::drop($tableNames['model_has_permissions']); - Schema::drop($tableNames['roles']); - Schema::drop($tableNames['permissions']); + $tableNames = config('scorm_sco_table'); + + if (empty($tableNames)) { + throw new \Exception('Error: Table not found.'); + } + + $tableNames = config('scorm_table'); + + if (empty($tableNames)) { + throw new \Exception('Error: Table not found.'); + } + + Schema::drop($tableNames['scorm_sco_tracking_table']); + Schema::drop($tableNames['scorm_sco_table']); + Schema::drop($tableNames['scorm_table']); } } |