Skip to content

Commit

Permalink
fix: mark existing policies as accepted for all users, then set the d…
Browse files Browse the repository at this point in the history
…efault value to false for new users
  • Loading branch information
rafaucau committed Jun 16, 2024
1 parent 02bf04b commit 2d2570d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
use Flarum\Database\Migration;

return Migration::addColumns('fof_terms_policy_user', [
'is_accepted' => ['boolean'],
'is_accepted' => [
'boolean',
// Prior to this migration, all policies were required, so we mark them as accepted.
'default' => true
],
]);
26 changes: 26 additions & 0 deletions migrations/2024_06_17_01_change_accepted_state_default_value.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of fof/terms.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
$schema->table('fof_terms_policy_user', function (Blueprint $table) {
$table->boolean('is_accepted')->default(false)->change();
});
},
'down' => function (Builder $schema) {
$schema->table('fof_terms_policy_user', function (Blueprint $table) {
$table->boolean('is_accepted')->default(true)->change();
});
},
];

0 comments on commit 2d2570d

Please sign in to comment.