Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4690695
2021_05_12_150000_groups_add_tenant_id.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_05_12_150000_groups_add_tenant_id.php
View Options
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Schema
;
// phpcs:ignore
class
GroupsAddTenantId
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'groups'
,
function
(
Blueprint
$table
)
{
$table
->
bigInteger
(
'tenant_id'
)->
unsigned
()->
nullable
();
$table
->
foreign
(
'tenant_id'
)->
references
(
'id'
)->
on
(
'tenants'
)->
onDelete
(
'set null'
);
}
);
if
(
$tenant_id
=
\config
(
'app.tenant_id'
))
{
DB
::
statement
(
"UPDATE `groups` SET `tenant_id` = {$tenant_id}"
);
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'groups'
,
function
(
Blueprint
$table
)
{
$table
->
dropForeign
([
'tenant_id'
]);
$table
->
dropColumn
(
'tenant_id'
);
}
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, May 1, 5:07 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
644049
Default Alt Text
2021_05_12_150000_groups_add_tenant_id.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment