mirror of https://github.com/kcal-app/kcal.git
No-op meal field migrations
This allows tests to pass easier and the migrations are not entirely necessary anyway.
This commit is contained in:
parent
8ab11d5456
commit
2eccf84fea
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
|
@ -19,6 +20,7 @@ class CreateUsersTable extends Migration
|
|||
$table->string('username')->unique();
|
||||
$table->string('password');
|
||||
$table->string('name');
|
||||
$table->json('meals')->default(User::getDefaultMeals());
|
||||
$table->boolean('admin')->default(false);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class CreateJournalEntriesTable extends Migration
|
|||
$table->unsignedFloat('sodium')->default(0);
|
||||
$table->unsignedFloat('carbohydrates')->default(0);
|
||||
$table->unsignedFloat('protein')->default(0);
|
||||
$table->enum('meal', JournalEntry::meals()->pluck('value')->toArray());
|
||||
$table->integer('meal')->unsigned();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ class AddMealsToUsersTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->json('meals')->nullable()->after('name');
|
||||
});
|
||||
|
||||
User::each(function (User $user) {
|
||||
$user->meals = User::getDefaultMeals();
|
||||
$user->save();
|
||||
});
|
||||
// Schema::table('users', function (Blueprint $table) {
|
||||
// $table->json('meals')->nullable()->after('name');
|
||||
// });
|
||||
//
|
||||
// User::each(function (User $user) {
|
||||
// $user->meals = User::getDefaultMeals();
|
||||
// $user->save();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -31,8 +31,8 @@ class AddMealsToUsersTable extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('meals');
|
||||
});
|
||||
// Schema::table('users', function (Blueprint $table) {
|
||||
// $table->dropColumn('meals');
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ class ChangeMealToIntInJournalEntries extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('journal_entries', function (Blueprint $table) {
|
||||
$table->integer('meal_int')->unsigned()->nullable()->after('protein');
|
||||
});
|
||||
DB::update('UPDATE `journal_entries` SET meal_int =
|
||||
IF(meal = "breakfast", 0,
|
||||
IF(meal = "lunch", 1,
|
||||
IF(meal = "dinner", 2, 3)
|
||||
)
|
||||
)');
|
||||
Schema::table('journal_entries', function (Blueprint $table) {
|
||||
$table->dropColumn('meal');
|
||||
$table->renameColumn('meal_int', 'meal');
|
||||
});
|
||||
// Schema::table('journal_entries', function (Blueprint $table) {
|
||||
// $table->integer('meal_int')->unsigned()->nullable()->after('protein');
|
||||
// });
|
||||
// DB::update('UPDATE `journal_entries` SET meal_int =
|
||||
// IF(meal = "breakfast", 0,
|
||||
// IF(meal = "lunch", 1,
|
||||
// IF(meal = "dinner", 2, 3)
|
||||
// )
|
||||
// )');
|
||||
// Schema::table('journal_entries', function (Blueprint $table) {
|
||||
// $table->dropColumn('meal');
|
||||
// $table->renameColumn('meal_int', 'meal');
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,20 +37,20 @@ class ChangeMealToIntInJournalEntries extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('journal_entries', function (Blueprint $table) {
|
||||
$table->renameColumn('meal', 'meal_int');
|
||||
});
|
||||
Schema::table('journal_entries', function (Blueprint $table) {
|
||||
$table->enum('meal', JournalEntry::meals()->pluck('value')->toArray())->after('protein');
|
||||
});
|
||||
DB::update('UPDATE `journal_entries` SET meal =
|
||||
IF(meal_int = 0, "breakfast",
|
||||
IF(meal_int = 1, "lunch",
|
||||
IF(meal_int = 2, "dinner", "snacks")
|
||||
)
|
||||
)');
|
||||
Schema::table('journal_entries', function (Blueprint $table) {
|
||||
$table->dropColumn('meal_int');
|
||||
});
|
||||
// Schema::table('journal_entries', function (Blueprint $table) {
|
||||
// $table->renameColumn('meal', 'meal_int');
|
||||
// });
|
||||
// Schema::table('journal_entries', function (Blueprint $table) {
|
||||
// $table->enum('meal', JournalEntry::meals()->pluck('value')->toArray())->after('protein');
|
||||
// });
|
||||
// DB::update('UPDATE `journal_entries` SET meal =
|
||||
// IF(meal_int = 0, "breakfast",
|
||||
// IF(meal_int = 1, "lunch",
|
||||
// IF(meal_int = 2, "dinner", "snacks")
|
||||
// )
|
||||
// )');
|
||||
// Schema::table('journal_entries', function (Blueprint $table) {
|
||||
// $table->dropColumn('meal_int');
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue