Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F12490028
2021_11_10_100000_add_group_name_column.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
2021_11_10_100000_add_group_name_column.php
View Options
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\DB
;
// phpcs:ignore
class
AddGroupNameColumn
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'groups'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'name'
)->
nullable
()->
after
(
'email'
);
}
);
// Fill the name with the local part of the email address
DB
::
table
(
'groups'
)->
update
([
'name'
=>
DB
::
raw
(
"SUBSTRING_INDEX(`email`, '@', 1)"
)
]);
Schema
::
table
(
'groups'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'name'
)->
nullable
(
false
)->
change
();
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'groups'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'name'
);
}
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Oct 19, 11:55 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1516968
Default Alt Text
2021_11_10_100000_add_group_name_column.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment