From 44582665289951657d4d01e7a6834dfc0a1eba0b Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 10:46:48 +0100 Subject: [PATCH 1/7] Update ToU version migration --- .../2026_01_08_091559_tou_version.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 database/migrations/2026_01_08_091559_tou_version.php diff --git a/database/migrations/2026_01_08_091559_tou_version.php b/database/migrations/2026_01_08_091559_tou_version.php new file mode 100644 index 00000000..30b3324e --- /dev/null +++ b/database/migrations/2026_01_08_091559_tou_version.php @@ -0,0 +1,24 @@ +dropColumn('id'); + $table->string('version', 10)->primary()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void { + Schema::dropIfExists('tou_versions'); + } +}; From cbd82d65994998e29df7d17971f0ede7c3485758 Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 10:54:14 +0100 Subject: [PATCH 2/7] Update TermsOfUseVersion Model --- app/TermsOfUseVersion.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/TermsOfUseVersion.php b/app/TermsOfUseVersion.php index e4472407..8d8923ce 100644 --- a/app/TermsOfUseVersion.php +++ b/app/TermsOfUseVersion.php @@ -13,6 +13,12 @@ class TermsOfUseVersion extends Model { use HasFactory; + protected $primaryKey = 'version'; + + protected $keyType = 'string'; + + public $incrementing = false; + protected $table = 'tou_versions'; const FIELDS = [ From c3894ba04775ddfa2aafc3d6647487902049271b Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 12:45:28 +0100 Subject: [PATCH 3/7] improve tou_acceptances table --- .../2026_01_08_113952_tou_acceptances.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/migrations/2026_01_08_113952_tou_acceptances.php diff --git a/database/migrations/2026_01_08_113952_tou_acceptances.php b/database/migrations/2026_01_08_113952_tou_acceptances.php new file mode 100644 index 00000000..1f758f7d --- /dev/null +++ b/database/migrations/2026_01_08_113952_tou_acceptances.php @@ -0,0 +1,28 @@ +string('tou_version', 10)->change(); + $table->foreign('tou_version') + ->references('version') + ->on('tou_versions') + ->cascadeOnUpdate() + ->restrictOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void { + Schema::dropIfExists('tou_acceptances'); + } +}; From a0015ae48895ad966b465338b3a1ca656ffe0bc5 Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 15:45:00 +0100 Subject: [PATCH 4/7] Merge tou_versions and tou_acceptances migration and set version as CHAR(10) --- .../2026_01_08_091559_tou_version.php | 24 ------------------- ...rsions_and_tou_acceptances_tables.php.php} | 17 +++++++++---- 2 files changed, 13 insertions(+), 28 deletions(-) delete mode 100644 database/migrations/2026_01_08_091559_tou_version.php rename database/migrations/{2026_01_08_113952_tou_acceptances.php => 2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php} (58%) diff --git a/database/migrations/2026_01_08_091559_tou_version.php b/database/migrations/2026_01_08_091559_tou_version.php deleted file mode 100644 index 30b3324e..00000000 --- a/database/migrations/2026_01_08_091559_tou_version.php +++ /dev/null @@ -1,24 +0,0 @@ -dropColumn('id'); - $table->string('version', 10)->primary()->change(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void { - Schema::dropIfExists('tou_versions'); - } -}; diff --git a/database/migrations/2026_01_08_113952_tou_acceptances.php b/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php similarity index 58% rename from database/migrations/2026_01_08_113952_tou_acceptances.php rename to database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php index 1f758f7d..2509009d 100644 --- a/database/migrations/2026_01_08_113952_tou_acceptances.php +++ b/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php @@ -4,13 +4,20 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration { +return new class extends Migration +{ /** * Run the migrations. */ - public function up(): void { + public function up(): void + { + Schema::table('tou_versions', function (Blueprint $table) { + $table->dropColumn('id'); + $table->char('version', 10)->primary()->change(); + }); + Schema::table('tou_acceptances', function (Blueprint $table) { - $table->string('tou_version', 10)->change(); + $table->char('tou_version', 10)->change(); $table->foreign('tou_version') ->references('version') ->on('tou_versions') @@ -22,7 +29,9 @@ public function up(): void { /** * Reverse the migrations. */ - public function down(): void { + public function down(): void + { + Schema::dropIfExists('tou_versions'); Schema::dropIfExists('tou_acceptances'); } }; From d550c27f75650ea193acbe640a7bdff233cb0ac7 Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 15:46:56 +0100 Subject: [PATCH 5/7] Remove the redundant castings of version and active status --- app/TermsOfUseVersion.php | 5 ----- app/UserTermsOfUseAcceptance.php | 1 - 2 files changed, 6 deletions(-) diff --git a/app/TermsOfUseVersion.php b/app/TermsOfUseVersion.php index 8d8923ce..25f9b027 100644 --- a/app/TermsOfUseVersion.php +++ b/app/TermsOfUseVersion.php @@ -30,11 +30,6 @@ class TermsOfUseVersion extends Model { protected $visible = self::FIELDS; - protected $casts = [ - 'version' => 'string', - 'active' => 'boolean', - ]; - public static function latestActiveVersion(): ?self { return self::query()->where('active', true)->latest()->first(); } diff --git a/app/UserTermsOfUseAcceptance.php b/app/UserTermsOfUseAcceptance.php index 3a13bcf9..5a6de0d4 100644 --- a/app/UserTermsOfUseAcceptance.php +++ b/app/UserTermsOfUseAcceptance.php @@ -20,7 +20,6 @@ class UserTermsOfUseAcceptance extends Model { protected $visible = self::FIELDS; protected $casts = [ - 'tou_version' => 'string', 'tou_accepted_at' => 'datetime', ]; From 8c54b91404d371a45073ded841b8ef5f150d7b75 Mon Sep 17 00:00:00 2001 From: Dat Date: Thu, 8 Jan 2026 15:52:22 +0100 Subject: [PATCH 6/7] Fix linting errors --- ...ersions_and_tou_acceptances_tables.php.php | 9 +++---- ...rsions_and_tou_acceptances_tables2.php.php | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php diff --git a/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php b/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php index 2509009d..80e32517 100644 --- a/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php +++ b/database/migrations/2026_01_08_144222_update_tou_versions_and_tou_acceptances_tables.php.php @@ -4,13 +4,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. */ - public function up(): void - { + public function up(): void { Schema::table('tou_versions', function (Blueprint $table) { $table->dropColumn('id'); $table->char('version', 10)->primary()->change(); @@ -29,8 +27,7 @@ public function up(): void /** * Reverse the migrations. */ - public function down(): void - { + public function down(): void { Schema::dropIfExists('tou_versions'); Schema::dropIfExists('tou_acceptances'); } diff --git a/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php b/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php new file mode 100644 index 00000000..88fa2f36 --- /dev/null +++ b/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php @@ -0,0 +1,24 @@ + Date: Thu, 8 Jan 2026 15:55:01 +0100 Subject: [PATCH 7/7] remove stray migration stub --- ...rsions_and_tou_acceptances_tables2.php.php | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php diff --git a/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php b/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php deleted file mode 100644 index 88fa2f36..00000000 --- a/database/migrations/2026_01_08_145121_update_tou_versions_and_tou_acceptances_tables2.php.php +++ /dev/null @@ -1,24 +0,0 @@ -