Welcome to mirror list, hosted at ThFree Co, Russian Federation.

2016_03_05_043127_migrate_1x_to_2x_users.php « migrations « database - github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8c841955681f0cd735c85316e7c9dd201b08d4a2 (plain)
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
45
46
47
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Migrate1xTo2xUsers extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::rename('auth', 'users');

        Schema::table('users', function (Blueprint $table) {
            // Rename needed columns
            $table->renameColumn('rkey', 'recovery_key');
            $table->renameColumn('valid', 'active');
            $table->renameColumn('uid', 'id');

            // Drop unused columns
            $table->dropColumn('theme');

            // Create new columns
            $table->string('api_key')->nullable();
            $table->boolean('api_active')->default(0);
            $table->string('api_quota')->default(60);

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            //
        });
    }
}