Beta version of migration scripts

This commit is contained in:
2022-02-22 16:40:39 +00:00
parent 3490f7c6f1
commit 5456902f77
11 changed files with 35 additions and 416 deletions

View File

@@ -1,51 +0,0 @@
<?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\v002;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Core\Database\Migration;
/**
* Organisations approvals table migration
* Make the approver_id nullable
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v001\OrganisationApprovalsTable',
];
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisation_approvals')) {
$this->schema->table('organisation_approvals', function (Blueprint $table) {
$table->integer('approver_id')->unsigned()->nullable()->change();
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->table('organisation_approvals', function (Blueprint $table) {
$table->integer('approver_id')->unsigned()->change();
});
}
}

View File

@@ -1,51 +0,0 @@
<?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\v002;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Core\Database\Migration;
/**
* Organisations members table migration
* Add an approved flag
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationMembersTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v001\OrganisationMembersTable',
];
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisation_members')) {
$this->schema->table('organisation_members', function (Blueprint $table) {
$table->integer('flag_approved')->unsigned();
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->table('organisation_members', function (Blueprint $table) {
$table->dropColumn('flag_approved');
});
}
}

View File

@@ -1,64 +0,0 @@
<?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\v002;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Capsule\Manager as DB;
use UserFrosting\Sprinkle\Core\Database\Migration;
/**
* Organisation Membership Approvals table migration
* Manages requests for organisation membership join requests.
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationMembershipApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisation_membership_approvals')) {
DB::table('organisation_membership_approvals')->delete();
$this->schema->table('organisation_membership_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()
{
if ($this->schema->hasTable('organisation_membership_approvals')) {
DB::table('organisation_membership_approvals')->delete();
$this->schema->table('organisation_membership_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');
});
}
}
}

View File

@@ -1,55 +0,0 @@
<?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\v002;
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 `flag_verified` 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\v001\OrganisationsTable',
];
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisations')) {
$this->schema->table('organisations', function (Blueprint $table) {
$table->boolean('flag_approved')->default(1)->comment('Set to 1 if the organisation has been approved, 0 otherwise.');
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->table('organisations', function (Blueprint $table) {
$table->dropColumn('flag_approved');
});
}
}

View File

@@ -1,68 +0,0 @@
<?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');
});
}
}

View File

@@ -1,55 +0,0 @@
<?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');
});
}
}

View File

@@ -1,55 +0,0 @@
<?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\v004;
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->foreign('registrant_id')->references('id')->on('users');
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->table('organisations', function (Blueprint $table) {
$table->dropForeign(['registrant_id']);
});
}
}

View File

@@ -7,7 +7,7 @@
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v001;
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v010;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Core\Database\Migration;
@@ -21,6 +21,13 @@ use UserFrosting\Sprinkle\Core\Database\Migration;
*/
class OrganisationApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable',
];
/**
* {@inheritdoc}
*/
@@ -29,23 +36,19 @@ class OrganisationApprovalsTable extends Migration
if (!$this->schema->hasTable('organisation_approvals')) {
$this->schema->create('organisation_approvals', function (Blueprint $table) {
$table->increments('id');
$table->integer('requester_id')->unsigned();
$table->integer('organisation_id')->unsigned();
$table->integer('owner_id')->unsigned();
$table->string('hash');
$table->boolean('completed')->default(0);
$table->timestamp('expires_at')->nullable();
$table->timestamp('completed_at')->nullable();
$table->integer('approver_id')->unsigned();
$table->integer('approver_id')->unsigned()->nullable();
$table->timestamps();
$table->engine = 'InnoDB';
$table->collation = 'utf8_unicode_ci';
$table->charset = 'utf8';
$table->foreign('requester_id')->references('id')->on('users');
$table->foreign('approver_id')->references('id')->on('users');
$table->foreign('organisation_id')->references('id')->on('organisations');
$table->index('requester_id');
$table->index('approver_id');
$table->index('owner_id');
$table->index('hash');
});
}

View File

@@ -7,7 +7,7 @@
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v001;
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v010;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Organisations\Database\Models\Organisation;
@@ -40,9 +40,11 @@ class OrganisationMembersTable extends Migration
{
if (!$this->schema->hasTable('organisation_members')) {
$this->schema->create('organisation_members', function (Blueprint $table) {
$table->increments('map_id');
$table->integer('user_id')->unsigned();
$table->integer('organisation_id')->unsigned();
$table->boolean('flag_admin');
$table->boolean('flag_approved')->default(1)->comment('Set to 1 if the user membership has been approved, 0 otherwise.');
$table->timestamps();
$table->engine = 'InnoDB';

View File

@@ -7,7 +7,7 @@
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v001;
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v010;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Core\Database\Migration;
@@ -21,6 +21,13 @@ use UserFrosting\Sprinkle\Core\Database\Migration;
*/
class OrganisationMembershipApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable',
];
/**
* {@inheritdoc}
*/
@@ -29,8 +36,7 @@ class OrganisationMembershipApprovalsTable extends Migration
if (!$this->schema->hasTable('organisation_membership_approvals')) {
$this->schema->create('organisation_membership_approvals', function (Blueprint $table) {
$table->increments('id');
$table->integer('requester_id')->unsigned();
$table->integer('organisation_id')->unsigned();
$table->integer('owner_id')->unsigned();
$table->string('hash');
$table->boolean('completed')->default(0);
$table->timestamp('expires_at')->nullable();
@@ -41,11 +47,8 @@ class OrganisationMembershipApprovalsTable extends Migration
$table->engine = 'InnoDB';
$table->collation = 'utf8_unicode_ci';
$table->charset = 'utf8';
$table->foreign('requester_id')->references('id')->on('users');
$table->foreign('approver_id')->references('id')->on('users');
$table->foreign('organisation_id')->references('id')->on('organisations');
$table->index('requester_id');
$table->index('approver_id');
$table->index('owner_id');
$table->index('hash');
});
}

View File

@@ -7,7 +7,7 @@
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v001;
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v010;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Organisations\Database\Models\Organisation;
@@ -23,6 +23,13 @@ use UserFrosting\Sprinkle\Core\Facades\Seeder;
*/
class OrganisationsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable',
];
/**
* {@inheritdoc}
*/
@@ -34,12 +41,15 @@ class OrganisationsTable extends Migration
$table->string('slug');
$table->string('name');
$table->text('description')->nullable();
$table->integer('registrant_id')->unsigned()->nullable();
$table->boolean('flag_approved')->default(1)->comment('Set to 1 if the organisation has been approved, 0 otherwise.');
$table->softDeletes();
$table->timestamps();
$table->engine = 'InnoDB';
$table->collation = 'utf8_unicode_ci';
$table->charset = 'utf8';
$table->foreign('registrant_id')->references('id')->on('users');
$table->unique('slug');
$table->index('slug');
});