Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/TermsOfUseVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -24,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();
}
Expand Down
1 change: 0 additions & 1 deletion app/UserTermsOfUseAcceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class UserTermsOfUseAcceptance extends Model {
protected $visible = self::FIELDS;

protected $casts = [
'tou_version' => 'string',
'tou_accepted_at' => 'datetime',
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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('tou_versions', function (Blueprint $table) {
$table->dropColumn('id');
$table->char('version', 10)->primary()->change();
});

Schema::table('tou_acceptances', function (Blueprint $table) {
$table->char('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_versions');
Schema::dropIfExists('tou_acceptances');
}
};
Loading