diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index e811bd9..b6ef4df 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -17,14 +17,34 @@ return new class extends Migration $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); + $table->string('role')->default('user'); $table->text('bio')->nullable(); + $table->integer('height')->nullable(); + $table->date('date_of_birth')->nullable(); + $table->string('sex')->default('unknown'); + $table->string('physical_activity_level')->default('sedentary'); + $table->string('weight_goal')->default('lose_weight'); + $table->string('pace_preference')->default('slow'); + $table->string('locale', 8)->default('en')->after('email'); $table->string('avatar_url', 2048)->nullable(); + + // Goals $table->unsignedInteger('daily_calorie_goal')->default(2000)->after('avatar_url'); $table->decimal('daily_protein_goal', 8, 2)->default(120)->after('daily_calorie_goal'); $table->decimal('daily_carbs_goal', 8, 2)->default(250)->after('daily_protein_goal'); $table->decimal('daily_fats_goal', 8, 2)->default(70)->after('daily_carbs_goal'); + // Moderation + $table->timestamp('suspended_at')->nullable()->after('deleted_at')->index(); + $table->ulid('suspended_by')->nullable()->after('suspended_at')->index(); + $table->text('suspended_reason')->nullable()->after('suspended_by'); $table->rememberToken(); + $table->timestampTz('account_verified_at')->nullable(); $table->timestamps(); + $table->softDeletesTz(); + }); + + Schema::table('users', function (Blueprint $table) { + $table->foreign('suspended_by')->references('id')->on('users')->nullOnDelete(); }); Schema::create('password_reset_tokens', function (Blueprint $table) { diff --git a/database/migrations/2026_05_15_111236_create_meal_posts_table.php b/database/migrations/2026_05_15_111236_create_meal_posts_table.php index eabab8c..11500c4 100644 --- a/database/migrations/2026_05_15_111236_create_meal_posts_table.php +++ b/database/migrations/2026_05_15_111236_create_meal_posts_table.php @@ -17,9 +17,14 @@ return new class extends Migration $table->decimal('proteins', 8, 2)->nullable(); $table->decimal('carbs', 8, 2)->nullable(); $table->decimal('fats', 8, 2)->nullable(); + $table->string('diet_type')->default('omnivore'); + $table->boolean('ai_generated')->default(false)->index(); $table->string('title'); $table->string('type')->default('breakfast'); $table->string('visibility', 20)->default('private')->index(); + $table->timestamp('hidden_at')->nullable()->after('deleted_at')->index(); + $table->foreignUlid('hidden_by')->nullable()->after('hidden_at')->constrained('users')->nullOnDelete(); + $table->text('hidden_reason')->nullable()->after('hidden_by'); $table->timestamp('eaten_at'); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2026_05_16_131810_create_notifications_table.php b/database/migrations/2026_05_16_131810_create_notifications_table.php index 60f790a..13f21ab 100644 --- a/database/migrations/2026_05_16_131810_create_notifications_table.php +++ b/database/migrations/2026_05_16_131810_create_notifications_table.php @@ -15,7 +15,7 @@ return new class extends Migration $table->uuid('id')->primary(); $table->string('type'); $table->ulidMorphs('notifiable'); - $table->text('data'); + $table->jsonb('data'); $table->timestamp('read_at')->nullable(); $table->timestamps(); }); diff --git a/database/migrations/2026_05_18_122038_create_meal_post_ingredients_table.php b/database/migrations/2026_05_18_122038_create_meal_post_ingredients_table.php index 9e30c69..59d2a6b 100644 --- a/database/migrations/2026_05_18_122038_create_meal_post_ingredients_table.php +++ b/database/migrations/2026_05_18_122038_create_meal_post_ingredients_table.php @@ -12,6 +12,7 @@ return new class extends Migration $table->id(); $table->foreignUlid('meal_posts_id')->constrained('meal_posts')->cascadeOnDelete(); $table->integer('position'); + $table->unsignedInteger('quantity')->default(1); $table->string('ingredient'); $table->string('unit'); $table->timestamps(); diff --git a/database/migrations/2026_05_18_124718_add_quantity_to_meal_ingredient.php b/database/migrations/2026_05_18_124718_add_quantity_to_meal_ingredient.php deleted file mode 100644 index cdc66b4..0000000 --- a/database/migrations/2026_05_18_124718_add_quantity_to_meal_ingredient.php +++ /dev/null @@ -1,28 +0,0 @@ -unsignedInteger('quantity')->default(1); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('meal_post_ingredients', function (Blueprint $table) { - $table->dropColumn('quantity'); - }); - } -}; diff --git a/database/migrations/2026_05_18_152010_add_height_to_user.php b/database/migrations/2026_05_18_152010_add_height_to_user.php deleted file mode 100644 index 0b348ab..0000000 --- a/database/migrations/2026_05_18_152010_add_height_to_user.php +++ /dev/null @@ -1,28 +0,0 @@ -integer('height')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('user', function (Blueprint $table) { - $table->dropColumn('height'); - }); - } -}; diff --git a/database/migrations/2026_05_18_170714_add_ai_generated_to_meal_posts.php b/database/migrations/2026_05_18_170714_add_ai_generated_to_meal_posts.php deleted file mode 100644 index 7daf726..0000000 --- a/database/migrations/2026_05_18_170714_add_ai_generated_to_meal_posts.php +++ /dev/null @@ -1,29 +0,0 @@ -boolean('ai_generated')->default(false)->index(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('meal_posts', function (Blueprint $table) { - $table->dropIndex(['ai_generated']); - $table->dropColumn('ai_generated'); - }); - } -}; diff --git a/database/migrations/2026_05_18_171214_add_diet_type_to_meal_posts_table.php b/database/migrations/2026_05_18_171214_add_diet_type_to_meal_posts_table.php deleted file mode 100644 index f12b1d8..0000000 --- a/database/migrations/2026_05_18_171214_add_diet_type_to_meal_posts_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('diet_type')->default('omnivore'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('meal_posts', function (Blueprint $table) { - $table->dropColumn('diet_type'); - }); - } -}; diff --git a/database/migrations/2026_05_21_091112_add_fields_to_users_table.php b/database/migrations/2026_05_21_091112_add_fields_to_users_table.php deleted file mode 100644 index 7f7818d..0000000 --- a/database/migrations/2026_05_21_091112_add_fields_to_users_table.php +++ /dev/null @@ -1,38 +0,0 @@ -date('date_of_birth')->nullable(); - $table->string('sex')->default('unknown'); - $table->string('physical_activity_level')->default('sedentary'); - $table->string('weight_goal')->default('lose_weight'); - $table->string('pace_preference')->default('slow'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn([ - 'date_of_birth', - 'sex', - 'physical_activity_level', - 'weight_goal', - 'pace_preference', - ]); - }); - } -}; diff --git a/database/migrations/2026_05_21_123308_add_account_verified_at_to_users.php b/database/migrations/2026_05_21_123308_add_account_verified_at_to_users.php deleted file mode 100644 index 34368a2..0000000 --- a/database/migrations/2026_05_21_123308_add_account_verified_at_to_users.php +++ /dev/null @@ -1,28 +0,0 @@ -timestampTz('account_verified_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - // - }); - } -}; diff --git a/database/migrations/2026_05_21_192621_add_locale_to_users_table.php b/database/migrations/2026_05_21_192621_add_locale_to_users_table.php deleted file mode 100644 index 201d76b..0000000 --- a/database/migrations/2026_05_21_192621_add_locale_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('locale', 8)->default('en')->after('email'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('locale'); - }); - } -}; diff --git a/database/migrations/2026_05_22_073307_add_role_to_users_table.php b/database/migrations/2026_05_22_073307_add_role_to_users_table.php deleted file mode 100644 index 5538d45..0000000 --- a/database/migrations/2026_05_22_073307_add_role_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('role')->default('user'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('role'); - }); - } -}; diff --git a/database/migrations/2026_05_22_074902_add_soft_deletes_to_users_table.php b/database/migrations/2026_05_22_074902_add_soft_deletes_to_users_table.php deleted file mode 100644 index 1eefa36..0000000 --- a/database/migrations/2026_05_22_074902_add_soft_deletes_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -softDeletesTz(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropSoftDeletesTz(); - }); - } -}; diff --git a/database/migrations/2026_05_22_093542_add_moderation_fields_to_meal_posts_table.php b/database/migrations/2026_05_22_093542_add_moderation_fields_to_meal_posts_table.php deleted file mode 100644 index 0dbebb5..0000000 --- a/database/migrations/2026_05_22_093542_add_moderation_fields_to_meal_posts_table.php +++ /dev/null @@ -1,31 +0,0 @@ -timestamp('hidden_at')->nullable()->after('deleted_at')->index(); - $table->foreignUlid('hidden_by')->nullable()->after('hidden_at')->constrained('users')->nullOnDelete(); - $table->text('hidden_reason')->nullable()->after('hidden_by'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('meal_posts', function (Blueprint $table) { - $table->dropForeign(['hidden_by']); - $table->dropColumn(['hidden_at', 'hidden_by', 'hidden_reason']); - }); - } -}; diff --git a/database/migrations/2026_05_22_093550_add_moderation_fields_to_users_table.php b/database/migrations/2026_05_22_093550_add_moderation_fields_to_users_table.php deleted file mode 100644 index b85cf01..0000000 --- a/database/migrations/2026_05_22_093550_add_moderation_fields_to_users_table.php +++ /dev/null @@ -1,31 +0,0 @@ -timestamp('suspended_at')->nullable()->after('deleted_at')->index(); - $table->foreignUlid('suspended_by')->nullable()->after('suspended_at')->constrained('users')->nullOnDelete(); - $table->text('suspended_reason')->nullable()->after('suspended_by'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropForeign(['suspended_by']); - $table->dropColumn(['suspended_at', 'suspended_by', 'suspended_reason']); - }); - } -}; diff --git a/database/migrations/2026_05_22_102611_change_type_notifications_table.php b/database/migrations/2026_05_22_102611_change_type_notifications_table.php deleted file mode 100644 index dce95f0..0000000 --- a/database/migrations/2026_05_22_102611_change_type_notifications_table.php +++ /dev/null @@ -1,45 +0,0 @@ -getDriverName() !== 'pgsql') { - return; - } - - DB::statement('ALTER TABLE notifications ALTER COLUMN notifiable_id TYPE char(26) USING notifiable_id::text'); - DB::statement('ALTER TABLE notifications ALTER COLUMN data TYPE jsonb USING data::jsonb'); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (DB::connection()->getDriverName() !== 'pgsql') { - return; - } - - DB::statement('ALTER TABLE notifications ALTER COLUMN data TYPE text USING data::text'); - DB::statement(<<<'SQL' - DO $$ - BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM notifications - WHERE notifiable_id !~ '^[0-9]+$' - ) THEN - ALTER TABLE notifications - ALTER COLUMN notifiable_id TYPE bigint USING notifiable_id::bigint; - END IF; - END $$; - SQL); - } -};