forked from eahlys/EdPaste
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2020_05_22_100435_invert_syntaxhl_option.php
44 lines (40 loc) · 1.14 KB
/
2020_05_22_100435_invert_syntaxhl_option.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
34
35
36
37
38
39
40
41
42
43
44
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Paste;
class InvertSyntaxhlOption extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('pastes', function (Blueprint $table) {
$table->boolean('syntaxHl')->nullable();
});
Paste::where('noSyntax', 1)->update(['syntaxHl' => 0]);
Paste::where('noSyntax', 0)->update(['syntaxHl' => 1]);
Schema::table('pastes', function (Blueprint $table) {
$table->dropColumn(['noSyntax']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('pastes', function (Blueprint $table) {
$table->boolean('noSyntax')->nullable();
});
Paste::where('syntaxHl', 1)->update(['noSyntax' => 0]);
Paste::where('syntaxHl', 0)->update(['noSyntax' => 1]);
Schema::table('pastes', function (Blueprint $table) {
$table->dropColumn(['syntaxHl']);
});
}
}