From 4e11fb7db04589548237d9ac51f44d0fdfd50791 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:19:03 -0600 Subject: [PATCH 1/8] chore: bump mariadb from 10.11 to 11.1 --- CHANGELOG.md | 4 ++++ docker-compose-prod.yml | 2 +- docker-compose.yml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1419bdf..c98f335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## Next Release + +- Updates MariaDB from 10.11 to 11.1 + ## v1.0.1 (2023-09-06) - Fixes long-string line wrapping on the posts page when viewing on mobile diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index 02f4f28..8fd7b40 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -34,7 +34,7 @@ services: cpus: '0.25' memory: '128M' healthcheck: - test: ['CMD', 'mysql', '-u${MARIADB_USER}', '-p${MARIADB_PASSWORD}', '-e', 'show databases;'] + test: ['CMD', 'mariadb', '-u${MARIADB_USER}', '-p${MARIADB_PASSWORD}', '-e', 'show databases;'] interval: 10s timeout: 10s retries: 3 diff --git a/docker-compose.yml b/docker-compose.yml index 879e4f1..e098539 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: depends_on: - glass-db glass-db: - image: 'mariadb:10.11.4' + image: 'mariadb:11.1.2' restart: always volumes: - database-data:/var/lib/mysql From f2ea5197cd942ee15524052a04ce14e1fc994672 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:19:15 -0600 Subject: [PATCH 2/8] fix: bootstrap deprecation warning --- src/package-lock.json | 8 ++++---- src/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/package-lock.json b/src/package-lock.json index 3b03662..809284e 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -7,7 +7,7 @@ "dependencies": { "@sindresorhus/slugify": "^1.1", "axios": "^1.3", - "bootstrap": "^5.2", + "bootstrap": "^5.3.2", "highlight.js": "^11.8", "laravel-vite-plugin": "^0.7.4", "pineapple-library": "^3.2", @@ -680,9 +680,9 @@ } }, "node_modules/bootstrap": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.1.tgz", - "integrity": "sha512-jzwza3Yagduci2x0rr9MeFSORjcHpt0lRZukZPZQJT1Dth5qzV7XcgGqYzi39KGAVYR8QEDVoO0ubFKOxzMG+g==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.2.tgz", + "integrity": "sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==", "funding": [ { "type": "github", diff --git a/src/package.json b/src/package.json index 22fcd17..cbf802c 100644 --- a/src/package.json +++ b/src/package.json @@ -9,7 +9,7 @@ "dependencies": { "@sindresorhus/slugify": "^1.1", "axios": "^1.3", - "bootstrap": "^5.2", + "bootstrap": "^5.3.2", "laravel-vite-plugin": "^0.7.4", "highlight.js": "^11.8", "pineapple-library": "^3.2", From 045a3c4082327cdd4d70283b237485c6570ff739 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:24:46 -0600 Subject: [PATCH 3/8] feat: unique and indexed categories --- CHANGELOG.md | 2 ++ .../Http/Controllers/CategoryController.php | 2 +- .../2023_09_20_040645_add_indexes.php | 30 +++++++++++++++++++ src/resources/views/create-post.blade.php | 4 +-- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/database/migrations/2023_09_20_040645_add_indexes.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c98f335..beac0a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next Release +- Categories are now unique, enforced at the database level, and are indexed for quick retrieval +- Fixed a bug that didn't show the dropdown chevrons for form-select fields when creating a post - Updates MariaDB from 10.11 to 11.1 ## v1.0.1 (2023-09-06) diff --git a/src/app/Http/Controllers/CategoryController.php b/src/app/Http/Controllers/CategoryController.php index af5afd3..76b4432 100644 --- a/src/app/Http/Controllers/CategoryController.php +++ b/src/app/Http/Controllers/CategoryController.php @@ -21,7 +21,7 @@ public function create(Request $request): RedirectResponse ->first() ?: new Category(); $request->validate([ - 'category' => 'required|string|unique:categories,category' . $category->id, + 'category' => 'required|string', ]); if ($category->trashed()) { diff --git a/src/database/migrations/2023_09_20_040645_add_indexes.php b/src/database/migrations/2023_09_20_040645_add_indexes.php new file mode 100644 index 0000000..3d3e56f --- /dev/null +++ b/src/database/migrations/2023_09_20_040645_add_indexes.php @@ -0,0 +1,30 @@ +string('category')->nullable(false)->change(); + $table->unique('category'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('categories', function (Blueprint $table) { + $table->dropUnique(['category']); + $table->string('category')->nullable(true)->change(); + }); + } +}; diff --git a/src/resources/views/create-post.blade.php b/src/resources/views/create-post.blade.php index fbb3e61..7b74266 100644 --- a/src/resources/views/create-post.blade.php +++ b/src/resources/views/create-post.blade.php @@ -15,7 +15,7 @@ - @@ -49,7 +49,7 @@ - @foreach ($categories as $category) @endforeach From f1a719afd82a6f4ebc4c3277596ebef3080cb1e8 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:57:06 -0600 Subject: [PATCH 4/8] feat: add post_id index to comments --- src/database/migrations/2023_09_20_040645_add_indexes.php | 8 ++++++++ src/resources/views/post.blade.php | 6 +----- src/resources/views/posts.blade.php | 6 +----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/database/migrations/2023_09_20_040645_add_indexes.php b/src/database/migrations/2023_09_20_040645_add_indexes.php index 3d3e56f..51d5e59 100644 --- a/src/database/migrations/2023_09_20_040645_add_indexes.php +++ b/src/database/migrations/2023_09_20_040645_add_indexes.php @@ -15,6 +15,10 @@ public function up(): void $table->string('category')->nullable(false)->change(); $table->unique('category'); }); + + Schema::table('comments', function (Blueprint $table) { + $table->index(['post_id']); + }); } /** @@ -26,5 +30,9 @@ public function down(): void $table->dropUnique(['category']); $table->string('category')->nullable(true)->change(); }); + + Schema::table('comments', function (Blueprint $table) { + $table->dropIndex('comments_post_id_index'); + }); } }; diff --git a/src/resources/views/post.blade.php b/src/resources/views/post.blade.php index ee2000e..268c7b5 100644 --- a/src/resources/views/post.blade.php +++ b/src/resources/views/post.blade.php @@ -30,11 +30,7 @@ {{ \App\Http\Controllers\PostController::generateReadingTime($post) }} minutes - @if (isset($post->category->category)) - {{ $post->category->category }} - @else - {{ 'Uncategorized' }} - @endif + {{ $post->category->category }}