the browser-facing portion of osu!
1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6use Illuminate\Database\Migrations\Migration;
7
8class UpdateAchievementsTable extends Migration
9{
10 /**
11 * Run the migrations.
12 *
13 * @return void
14 */
15 public function up()
16 {
17 if (!Schema::hasColumn('osu_achievements', 'enabled')) {
18 Schema::table('osu_achievements', function ($table) {
19 $table->boolean('enabled')->default(true);
20 });
21 }
22
23 if (!Schema::hasColumn('osu_achievements', 'mode')) {
24 Schema::table('osu_achievements', function ($table) {
25 $table->tinyInteger('mode')->nullable();
26 });
27 }
28
29 Schema::table('osu_achievements', function ($table) {
30 $table->string('image', 50)->nullable()->change();
31 });
32
33 Schema::table('osu_achievements', function ($table) {
34 $table->mediumInteger('achievement_id')->unsigned()->change();
35 });
36 }
37
38 /**
39 * Reverse the migrations.
40 *
41 * @return void
42 */
43 public function down()
44 {
45 Schema::table('osu_achievements', function ($table) {
46 $table->dropColumn('enabled');
47 $table->dropColumn('mode');
48 $table->string('image', 50)->change();
49 });
50
51 // Laravel mediumIncrements() always specifies primary key, causing conflicts.
52
53 DB::statement('ALTER TABLE osu_achievements MODIFY achievement_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT');
54 }
55}