forked from skydiver/october-plugin-forms
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadd_unread_field.php
33 lines (23 loc) · 872 Bytes
/
add_unread_field.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace BlakeJones\MagicForms\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
use BlakeJones\MagicForms\Models\Record;
class AddUnreadField extends Migration {
public function up() {
// CREATE FIELD
Schema::table('blakejones_magicforms_records', function ($table) {
$table->boolean('unread')->default(1)->after('ip');
});
// UPDATE EXISTING RECORDS TO READED
Record::where('unread', 1)->update(['unread' => 0]);
}
public function down() {
if(Schema::hasColumn('blakejones_magicforms_records', 'unread')) {
Schema::table('blakejones_magicforms_records', function ($table) {
$table->dropColumn('unread');
});
}
}
}
?>