Skip to content

Commit

Permalink
fix: post table field types
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Sep 20, 2023
1 parent dd59d29 commit 2ba5cdc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Categories are now unique and required, enforced at the database level
- Various database indexes were added for common lookup patterns for quick retrieval
- Fixes various database field types and type validation on form submission to better align with the context they are used with
- Fixes a bug that didn't show the dropdown chevrons for form-select fields when creating a post
- Fixes a Bootstrap deprecation warning
- Updates MariaDB from 10.11 to 11.1
Expand Down
4 changes: 2 additions & 2 deletions src/app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function create(Request $request): RedirectResponse
})
],
'keywords' => 'nullable|string',
'category_id' => 'nullable|string',
'category_id' => 'nullable|integer',
'post' => 'required|string',
'banner_image_url' => 'nullable|string',
'published' => 'required|integer',
Expand Down Expand Up @@ -206,7 +206,7 @@ public function update(Request $request, int $id): RedirectResponse
})
],
'keywords' => 'nullable|string',
'category_id' => 'nullable|string',
'category_id' => 'nullable|integer',
'post' => 'required|string',
'banner_image_url' => 'nullable|string',
'published' => 'required|integer',
Expand Down
32 changes: 32 additions & 0 deletions src/database/migrations/2023_09_20_055545_fix_post_field_types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->integer('category_id')->change();
$table->string('keywords')->change();
$table->mediumText('post')->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->string('category_id')->change();
$table->text('keywords')->change();
$table->longText('post')->change();
});
}
};

0 comments on commit 2ba5cdc

Please sign in to comment.