From 5456902f77377e671eafb5ea68381076cb8fcbd3 Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Tue, 22 Feb 2022 16:40:39 +0000 Subject: [PATCH] Beta version of migration scripts --- .../v002/UpdateOrganisationApprovalsTable.php | 51 -------------- .../v002/UpdateOrganisationMembersTable.php | 51 -------------- ...teOrganisationMembershipApprovalsTable.php | 64 ----------------- .../v002/UpdateOrganisationsTable.php | 55 --------------- .../v003/UpdateOrganisationApprovalsTable.php | 68 ------------------- .../v003/UpdateOrganisationsTable.php | 55 --------------- .../v004/UpdateOrganisationsTable.php | 55 --------------- .../OrganisationApprovalsTable.php | 19 +++--- .../OrganisationMembersTable.php | 4 +- .../OrganisationMembershipApprovalsTable.php | 17 +++-- .../{v001 => v010}/OrganisationsTable.php | 12 +++- 11 files changed, 35 insertions(+), 416 deletions(-) delete mode 100644 src/Database/Migrations/v002/UpdateOrganisationApprovalsTable.php delete mode 100644 src/Database/Migrations/v002/UpdateOrganisationMembersTable.php delete mode 100644 src/Database/Migrations/v002/UpdateOrganisationMembershipApprovalsTable.php delete mode 100644 src/Database/Migrations/v002/UpdateOrganisationsTable.php delete mode 100644 src/Database/Migrations/v003/UpdateOrganisationApprovalsTable.php delete mode 100644 src/Database/Migrations/v003/UpdateOrganisationsTable.php delete mode 100644 src/Database/Migrations/v004/UpdateOrganisationsTable.php rename src/Database/Migrations/{v001 => v010}/OrganisationApprovalsTable.php (77%) rename src/Database/Migrations/{v001 => v010}/OrganisationMembersTable.php (92%) rename src/Database/Migrations/{v001 => v010}/OrganisationMembershipApprovalsTable.php (81%) rename src/Database/Migrations/{v001 => v010}/OrganisationsTable.php (78%) diff --git a/src/Database/Migrations/v002/UpdateOrganisationApprovalsTable.php b/src/Database/Migrations/v002/UpdateOrganisationApprovalsTable.php deleted file mode 100644 index e813c9f..0000000 --- a/src/Database/Migrations/v002/UpdateOrganisationApprovalsTable.php +++ /dev/null @@ -1,51 +0,0 @@ -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(); - }); - } -} diff --git a/src/Database/Migrations/v002/UpdateOrganisationMembersTable.php b/src/Database/Migrations/v002/UpdateOrganisationMembersTable.php deleted file mode 100644 index ab0ad7c..0000000 --- a/src/Database/Migrations/v002/UpdateOrganisationMembersTable.php +++ /dev/null @@ -1,51 +0,0 @@ -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'); - }); - } -} diff --git a/src/Database/Migrations/v002/UpdateOrganisationMembershipApprovalsTable.php b/src/Database/Migrations/v002/UpdateOrganisationMembershipApprovalsTable.php deleted file mode 100644 index c298487..0000000 --- a/src/Database/Migrations/v002/UpdateOrganisationMembershipApprovalsTable.php +++ /dev/null @@ -1,64 +0,0 @@ -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'); - }); - } - } -} diff --git a/src/Database/Migrations/v002/UpdateOrganisationsTable.php b/src/Database/Migrations/v002/UpdateOrganisationsTable.php deleted file mode 100644 index 5a9d306..0000000 --- a/src/Database/Migrations/v002/UpdateOrganisationsTable.php +++ /dev/null @@ -1,55 +0,0 @@ -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'); - }); - } -} diff --git a/src/Database/Migrations/v003/UpdateOrganisationApprovalsTable.php b/src/Database/Migrations/v003/UpdateOrganisationApprovalsTable.php deleted file mode 100644 index d8d0158..0000000 --- a/src/Database/Migrations/v003/UpdateOrganisationApprovalsTable.php +++ /dev/null @@ -1,68 +0,0 @@ -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'); - }); - } -} diff --git a/src/Database/Migrations/v003/UpdateOrganisationsTable.php b/src/Database/Migrations/v003/UpdateOrganisationsTable.php deleted file mode 100644 index d39b46a..0000000 --- a/src/Database/Migrations/v003/UpdateOrganisationsTable.php +++ /dev/null @@ -1,55 +0,0 @@ -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'); - }); - } -} diff --git a/src/Database/Migrations/v004/UpdateOrganisationsTable.php b/src/Database/Migrations/v004/UpdateOrganisationsTable.php deleted file mode 100644 index d88e3cc..0000000 --- a/src/Database/Migrations/v004/UpdateOrganisationsTable.php +++ /dev/null @@ -1,55 +0,0 @@ -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']); - }); - } -} \ No newline at end of file diff --git a/src/Database/Migrations/v001/OrganisationApprovalsTable.php b/src/Database/Migrations/v010/OrganisationApprovalsTable.php similarity index 77% rename from src/Database/Migrations/v001/OrganisationApprovalsTable.php rename to src/Database/Migrations/v010/OrganisationApprovalsTable.php index 72c36be..69191c5 100644 --- a/src/Database/Migrations/v001/OrganisationApprovalsTable.php +++ b/src/Database/Migrations/v010/OrganisationApprovalsTable.php @@ -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'); }); } diff --git a/src/Database/Migrations/v001/OrganisationMembersTable.php b/src/Database/Migrations/v010/OrganisationMembersTable.php similarity index 92% rename from src/Database/Migrations/v001/OrganisationMembersTable.php rename to src/Database/Migrations/v010/OrganisationMembersTable.php index b84bc1e..dac83ff 100644 --- a/src/Database/Migrations/v001/OrganisationMembersTable.php +++ b/src/Database/Migrations/v010/OrganisationMembersTable.php @@ -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'; diff --git a/src/Database/Migrations/v001/OrganisationMembershipApprovalsTable.php b/src/Database/Migrations/v010/OrganisationMembershipApprovalsTable.php similarity index 81% rename from src/Database/Migrations/v001/OrganisationMembershipApprovalsTable.php rename to src/Database/Migrations/v010/OrganisationMembershipApprovalsTable.php index 74527c2..0067148 100644 --- a/src/Database/Migrations/v001/OrganisationMembershipApprovalsTable.php +++ b/src/Database/Migrations/v010/OrganisationMembershipApprovalsTable.php @@ -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'); }); } diff --git a/src/Database/Migrations/v001/OrganisationsTable.php b/src/Database/Migrations/v010/OrganisationsTable.php similarity index 78% rename from src/Database/Migrations/v001/OrganisationsTable.php rename to src/Database/Migrations/v010/OrganisationsTable.php index e7da410..61e20dc 100644 --- a/src/Database/Migrations/v001/OrganisationsTable.php +++ b/src/Database/Migrations/v010/OrganisationsTable.php @@ -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'); });