forked from miguel456/rbrecruiter
RSM-3 Add teams migration and config
This commit is contained in:
parent
d4f1b433dc
commit
67d1df7571
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auth Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Auth model used by Teamwork.
|
||||
|
|
||||
*/
|
||||
'user_model' => config('auth.providers.users.model', App\User::class),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork users Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the users table name used by Teamwork.
|
||||
|
|
||||
*/
|
||||
'users_table' => 'users',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork Team Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Team model used by Teamwork to create correct relations. Update
|
||||
| the team if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'team_model' => Mpociot\Teamwork\TeamworkTeam::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork teams Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the teams table name used by Teamwork to save teams to the database.
|
||||
|
|
||||
*/
|
||||
'teams_table' => 'teams',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork team_user Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the team_user table used by Teamwork to save assigned teams to the
|
||||
| database.
|
||||
|
|
||||
*/
|
||||
'team_user_table' => 'team_user',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Foreign key on Teamwork's team_user Table (Pivot)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'user_foreign_key' => 'id',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork Team Invite Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the Team Invite model used by Teamwork to create correct relations.
|
||||
| Update the team if it is in a different namespace.
|
||||
|
|
||||
*/
|
||||
'invite_model' => Mpociot\Teamwork\TeamInvite::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teamwork team invites Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the team invites table name used by Teamwork to save sent/pending
|
||||
| invitation into teams to the database.
|
||||
|
|
||||
*/
|
||||
'team_invites_table' => 'team_invites',
|
||||
];
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class TeamworkSetupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(\Config::get('teamwork.users_table'), function (Blueprint $table) {
|
||||
$table->integer('current_team_id')->unsigned()->nullable();
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.teams_table'), function (Blueprint $table) {
|
||||
$table->increments('id')->unsigned();
|
||||
$table->integer('owner_id')->unsigned()->nullable();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.team_user_table'), function (Blueprint $table) {
|
||||
$table->bigInteger('user_id')->unsigned();
|
||||
$table->integer('team_id')->unsigned();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references(\Config::get('teamwork.user_foreign_key'))
|
||||
->on(\Config::get('teamwork.users_table'))
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('team_id')
|
||||
->references('id')
|
||||
->on(\Config::get('teamwork.teams_table'))
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.team_invites_table'), function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->bigInteger('user_id')->unsigned();
|
||||
$table->integer('team_id')->unsigned();
|
||||
$table->enum('type', ['invite', 'request']);
|
||||
$table->string('email');
|
||||
$table->string('accept_token');
|
||||
$table->string('deny_token');
|
||||
$table->timestamps();
|
||||
$table->foreign('team_id')
|
||||
->references('id')
|
||||
->on(\Config::get('teamwork.teams_table'))
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(\Config::get('teamwork.users_table'), function (Blueprint $table) {
|
||||
$table->dropColumn('current_team_id');
|
||||
});
|
||||
|
||||
Schema::table(\Config::get('teamwork.team_user_table'), function (Blueprint $table) {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign(\Config::get('teamwork.team_user_table').'_user_id_foreign');
|
||||
}
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign(\Config::get('teamwork.team_user_table').'_team_id_foreign');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::drop(\Config::get('teamwork.team_user_table'));
|
||||
Schema::drop(\Config::get('teamwork.team_invites_table'));
|
||||
Schema::drop(\Config::get('teamwork.teams_table'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue