Added organisation members table & associated table column data

This commit is contained in:
2022-02-04 13:58:44 +00:00
parent 830a1b49a8
commit 1edd850170
5 changed files with 197 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
<?php
/*
* AVSDev UF Organisations (https://avsdev.uk)
*
* @link https://git.avsdev.uk/avsdev/sprinkle-organisations
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v001;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Organisations\Database\Models\Organisation;
use UserFrosting\Sprinkle\Organisations\Database\Models\OrganisationMember;
use UserFrosting\Sprinkle\Core\Database\Migration;
use UserFrosting\Sprinkle\Core\Facades\Seeder;
/**
* Organisation members table migration
* "Organisations" are intended to replace groups by providing logical grouping where users may be in none or more organisations.
* The organisation members table is used to hold the many-to-many mapping as well as indicate if a user has admin privileges over the organisation.
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class OrganisationMembersTable extends Migration
{
/**
* {@inheritdoc}
*/
public function up()
{
if (!$this->schema->hasTable('organisation_members')) {
$this->schema->create('organisation_members', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('organisation_id')->unsigned();
$table->boolean('flag_admin');
$table->timestamps();
$table->engine = 'InnoDB';
$table->collation = 'utf8_unicode_ci';
$table->charset = 'utf8';
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('organisation_id')->references('id')->on('organisations');
$table->index('user_id');
$table->index('organisation_id');
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->drop('organisation_members');
}
}