File tree Expand file tree Collapse file tree
app/sprinkles/account/src/Database/Migrations/v430 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * UserFrosting (http://www.userfrosting.com)
5+ *
6+ * @link https://github.com/userfrosting/UserFrosting
7+ * @copyright Copyright (c) 2019 Alexander Weissman
8+ * @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
9+ */
10+
11+ namespace UserFrosting \Sprinkle \Account \Database \Migrations \v430 ;
12+
13+ use Illuminate \Database \Schema \Blueprint ;
14+ use UserFrosting \Sprinkle \Core \Database \Migration ;
15+
16+ /**
17+ * Groups table migration
18+ * Changes `group_id` column properties to allow user to be created without a group.
19+ * Version 4.3.0.
20+ *
21+ * See https://laravel.com/docs/5.4/migrations#tables
22+ *
23+ * @author Amos Folz
24+ */
25+ class UpdateUsersTable extends Migration
26+ {
27+ /**
28+ * {@inheritdoc}
29+ */
30+ public static $ dependencies = [
31+ '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\GroupsTable ' ,
32+ '\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable ' ,
33+ '\UserFrosting\Sprinkle\Account\Database\Migrations\v420\AddingForeignKeys ' ,
34+ ];
35+
36+ /**
37+ * {@inheritdoc}
38+ */
39+ public function up ()
40+ {
41+ if ($ this ->schema ->hasTable ('users ' )) {
42+ $ this ->schema ->table ('users ' , function (Blueprint $ table ) {
43+ $ table ->dropIndex (['group_id ' ]);
44+ $ table ->unsignedInteger ('group_id ' )->comment ('The id of the user group. ' )->nullable ()->change ();
45+ });
46+ }
47+ }
48+
49+ /**
50+ * {@inheritdoc}
51+ */
52+ public function down ()
53+ {
54+ $ this ->schema ->table ('users ' , function (Blueprint $ table ) {
55+ $ table ->unsignedInteger ('group_id ' )->default (1 )->comment ('The id of the user group. ' )->nullable (false )->change ();
56+ });
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments