Skip to content

Commit 93f3dec

Browse files
committed
Add migration
1 parent d312d1f commit 93f3dec

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* UserFrosting (http://www.userfrosting.com)
4+
*
5+
* @link https://github.com/userfrosting/UserFrosting
6+
* @copyright Copyright (c) 2019 Alexander Weissman
7+
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
8+
*/
9+
10+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v430;
11+
12+
use Illuminate\Database\Schema\Blueprint;
13+
use UserFrosting\Sprinkle\Core\Database\Migration;
14+
15+
/**
16+
* Groups table migration
17+
* Changes `group_id` column properties to allow user to be created without a group.
18+
* Version 4.3.0
19+
*
20+
* See https://laravel.com/docs/5.4/migrations#tables
21+
* @author Alex Weissman (https://alexanderweissman.com)
22+
*/
23+
class UpdateUsersTable extends Migration
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public static $dependencies = [
29+
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable'
30+
];
31+
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function up()
36+
{
37+
if ($this->schema->hasTable('users')) {
38+
$this->schema->table('users', function (Blueprint $table) {
39+
$table->integer('group_id')->unsigned()->default(null)->comment('The id of the user group.')->nullable()->change();
40+
});
41+
}
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function down()
48+
{
49+
$this->schema->table('users', function (Blueprint $table) {
50+
$table->integer('group_id')->unsigned()->default(1)->comment('The id of the user group.')->nullable(false)->change();
51+
});
52+
}
53+
}

0 commit comments

Comments
 (0)