Skip to content

Commit

Permalink
Fix table names variables in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
assada committed Jul 21, 2020
1 parent 53419a4 commit 6c0d841
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Migrations/0000_00_00_000000_create_achievements_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
*/
class CreateAchievementsTables extends Migration
{
public $achievement_details;
public $achievement_progress;
public $achievementDetailsTableName;
public $achievementProgressTableName;

/**
* CreateAchievementsTables constructor.
*/
public function __construct()
{
$this->achievement_details = Config::get('achievements.table_names.details');
$this->achievement_progress = Config::get('achievements.table_names.progress');
$this->achievementDetailsTableName = Config::get('achievements.table_names.details');
$this->achievementProgressTableName = Config::get('achievements.table_names.progress');
}

/**
Expand All @@ -31,7 +31,7 @@ public function __construct()
public function up(): void
{
Schema::create(
$this->achievement_details,
$this->achievementDetailsTableName,
static function (Blueprint $table) {
$table->increments('id');
$table->string('name');
Expand All @@ -43,16 +43,16 @@ static function (Blueprint $table) {
}
);
Schema::create(
$this->achievement_progress,
static function (Blueprint $table) {
$this->achievementProgressTableName,
function (Blueprint $table) {
$table->uuid('id')->primary();
$table->unsignedInteger('achievement_id');
$table->morphs('achiever');
$table->unsignedInteger('points')->default(0);
$table->timestamp('unlocked_at')->nullable()->default(null);
$table->timestamps();

$table->foreign('achievement_id')->references('id')->on('achievement_details');
$table->foreign('achievement_id')->references('id')->on($this->achievementDetailsTableName);
}
);
}
Expand All @@ -64,7 +64,7 @@ static function (Blueprint $table) {
*/
public function down(): void
{
Schema::dropIfExists('achievement_progress');
Schema::dropIfExists('achievement_details');
Schema::dropIfExists($this->achievementProgressTableName);
Schema::dropIfExists($this->achievementDetailsTableName);
}
}

0 comments on commit 6c0d841

Please sign in to comment.