Revamped the organisation approvals process & refactored some files
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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\v003;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Capsule\Manager as DB;
|
||||
use UserFrosting\Sprinkle\Core\Database\Migration;
|
||||
|
||||
/**
|
||||
* Organisations approvals table migration
|
||||
* Drops the requester_id (moved to organisations as registrant_id) and organisation_id in favor of an owner_id.
|
||||
* Version 1.0.0.
|
||||
*
|
||||
* @author Craig Williams (https://avsdev.uk)
|
||||
*/
|
||||
class UpdateOrganisationApprovalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $dependencies = [
|
||||
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v002\UpdateOrganisationApprovalsTable',
|
||||
];
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if ($this->schema->hasTable('organisation_approvals')) {
|
||||
DB::table('organisation_approvals')->delete();
|
||||
$this->schema->table('organisation_approvals', function (Blueprint $table) {
|
||||
$table->dropForeign(['requester_id']);
|
||||
$table->dropForeign(['organisation_id']);
|
||||
$table->dropIndex(['requester_id']);
|
||||
$table->dropColumn(['requester_id']);
|
||||
$table->dropColumn(['organisation_id']);
|
||||
|
||||
$table->integer('owner_id')->unsigned();
|
||||
$table->index('owner_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::table('organisation_approvals')->delete();
|
||||
$this->schema->table('organisation_approvals', function (Blueprint $table) {
|
||||
$table->dropIndex(['owner_id']);
|
||||
$table->dropColumn('owner_id')->unsigned();
|
||||
|
||||
$table->integer('requester_id')->unsigned();
|
||||
$table->integer('organisation_id')->unsigned();
|
||||
$table->index('requester_id');
|
||||
$table->foreign('requester_id')->references('id')->on('users');
|
||||
$table->foreign('organisation_id')->references('id')->on('organisations');
|
||||
});
|
||||
}
|
||||
}
|
||||
55
src/Database/Migrations/v003/UpdateOrganisationsTable.php
Normal file
55
src/Database/Migrations/v003/UpdateOrganisationsTable.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\v003;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use UserFrosting\Sprinkle\Organisations\Database\Models\Organisation;
|
||||
use UserFrosting\Sprinkle\Core\Database\Migration;
|
||||
use UserFrosting\Sprinkle\Core\Facades\Seeder;
|
||||
|
||||
/**
|
||||
* Organisations table migration
|
||||
* Adds a `registrant_id` column to the `organisations` table
|
||||
* Version 1.0.0.
|
||||
*
|
||||
* @author Craig Williams (https://avsdev.uk)
|
||||
*/
|
||||
class UpdateOrganisationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $dependencies = [
|
||||
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable',
|
||||
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v002\UpdateOrganisationsTable',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if ($this->schema->hasTable('organisations')) {
|
||||
$this->schema->table('organisations', function (Blueprint $table) {
|
||||
$table->integer('registrant_id')->unsigned()->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->table('organisations', function (Blueprint $table) {
|
||||
$table->dropColumn('registrant_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user