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;
7use Illuminate\Support\Facades\Schema;
8
9class AddIpBans extends Migration
10{
11 /**
12 * Run the migrations.
13 *
14 * @return void
15 */
16 public function up()
17 {
18 if (Schema::hasTable('osu_ip_bans')) {
19 return;
20 }
21
22 Schema::create('osu_ip_bans', function ($table) {
23 $table->string('ip', 40)->primary()->default('');
24 $table->unsignedMediumInteger('user_id')->nullable();
25 $table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
26 $table->integer('length')->default(72 * 3600);
27 $table->boolean('active')->default(true);
28
29 $table->index('user_id', 'user_id');
30 $table->index(['active', 'timestamp'], 'active');
31 });
32 }
33
34 /**
35 * Reverse the migrations.
36 *
37 * @return void
38 */
39 public function down()
40 {
41 Schema::drop('osu_ip_bans');
42 }
43}