mirror of https://github.com/kcal-app/kcal.git
Reset migrations
The extensive migration of the goals table caused unhappiness for sqlite.
This commit is contained in:
parent
6a93254781
commit
6bb2439378
|
|
@ -17,11 +17,14 @@ class CreateGoalsTable extends Migration
|
|||
Schema::create('goals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(User::class)->constrained()->cascadeOnUpdate()->cascadeOnDelete();
|
||||
$table->date('from')->nullable();
|
||||
$table->date('to')->nullable();
|
||||
$table->string('frequency')->nullable();
|
||||
$table->string('name');
|
||||
$table->unsignedFloat('goal');
|
||||
$table->unsignedTinyInteger('days')->nullable();
|
||||
$table->unsignedFloat('calories')->nullable();
|
||||
$table->unsignedFloat('fat')->nullable();
|
||||
$table->unsignedFloat('cholesterol')->nullable();
|
||||
$table->unsignedFloat('sodium')->nullable();
|
||||
$table->unsignedFloat('carbohydrates')->nullable();
|
||||
$table->unsignedFloat('protein')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('user_id');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RefactorGoalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::table('goals')->truncate();
|
||||
Schema::table('goals', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('days')->default(127)->after('name');
|
||||
$table->unsignedFloat('calories')->nullable()->after('days');
|
||||
$table->unsignedFloat('fat')->nullable()->after('calories');
|
||||
$table->unsignedFloat('cholesterol')->nullable()->after('fat');
|
||||
$table->unsignedFloat('sodium')->nullable()->after('cholesterol');
|
||||
$table->unsignedFloat('carbohydrates')->nullable()->after('sodium');
|
||||
$table->unsignedFloat('protein')->nullable()->after('carbohydrates');
|
||||
$table->dropColumn(['frequency', 'from', 'goal', 'to']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::table('goals')->truncate();
|
||||
Schema::table('goals', function (Blueprint $table) {
|
||||
$table->date('from')->nullable();
|
||||
$table->date('to')->nullable();
|
||||
$table->string('frequency')->nullable();
|
||||
$table->unsignedFloat('goal')->nullable();
|
||||
$table->dropColumn(['days', 'calories', 'fat', 'cholesterol', 'sodium', 'carbohydrates', 'protein']);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue