Initial Laravel API import
Some checks failed
continuous-integration/drone/push Build is failing

- Complete GGZ Ecademy Laravel backend application
- RESTful API for learning products, members, filters
- Authentication and authorization system
- Database migrations and seeders
- Custom CRUD generator commands
- Email notification system
- Integration with frontend applications
This commit is contained in:
Joris Slagter
2025-12-02 17:40:21 +01:00
parent 786b6b6a78
commit df155bb13d
341 changed files with 116385 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWebSocketsStatisticsEntriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('websockets_statistics_entries', function (Blueprint $table) {
$table->increments('id');
$table->string('app_id');
$table->integer('peak_connection_count');
$table->integer('websocket_message_count');
$table->integer('api_message_count');
$table->nullableTimestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('websockets_statistics_entries');
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamp('logged_at')->nullable();
$table->timestamp('last_login_at')->nullable();
$table->string('last_login_ip')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePersonalAccessTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('color');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('roles');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRoleUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('role_user', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('role_id');
});
Schema::table('role_user', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('role_user', function (Blueprint $table) {
$table->dropForeign('role_user_user_id_foreign');
$table->dropForeign('role_user_role_id_foreign');
});
Schema::dropIfExists('role_user');
}
}

View File

@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLearningProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('learning_products', function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->nullable();
$table->boolean('published')->default(0);
$table->string('title')->nullable();
$table->string('code')->nullable();
$table->string('video')->nullable();
$table->string('lead_time')->nullable();
$table->string('seo_title')->nullable();
$table->string('meta_description')->nullable();
$table->string('url')->nullable();
$table->longText('short_description')->nullable();
$table->longText('learning_goals')->nullable();
$table->longText('review')->nullable();
$table->longText('certification')->nullable();
$table->longText('extra_information')->nullable();
$table->longText('target_audience')->nullable();
$table->boolean('in_the_picture')->nullable()->default(false);
$table->dateTime('in_the_picture_start', 0)->nullable();
$table->dateTime('in_the_picture_end', 0)->nullable();
$table->string('owner')->nullable();
$table->string('partner')->nullable();
$table->string('supplier')->nullable();
$table->longText('contract_agreements')->nullable();
$table->string('prognosis_members')->nullable();
$table->string('prognosis_attendees')->nullable();
$table->string('sharepoint_link')->nullable();
$table->string('support_link')->nullable();
$table->string('support_tickets_link')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('learning_products');
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMediaTable extends Migration
{
public function up()
{
Schema::create('media', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('model');
$table->uuid('uuid')->nullable();
$table->string('collection_name');
$table->string('name');
$table->string('file_name');
$table->string('mime_type')->nullable();
$table->string('disk');
$table->string('conversions_disk')->nullable();
$table->unsignedBigInteger('size');
$table->json('manipulations');
$table->json('custom_properties');
$table->json('responsive_images');
$table->unsignedInteger('order_column')->nullable();
$table->nullableTimestamps();
});
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFiltersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('filters', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('filters');
}
}

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateVersionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('versions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('learning_product_id');
$table->string('version_number')->nullable();
$table->dateTime('release_start', 0)->nullable();
$table->dateTime('release_end', 0)->nullable();
$table->dateTime('release_planning_date', 0)->nullable();
$table->longText('release_planning_description')->nullable();
$table->longText('technical_information')->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::table('versions', function (Blueprint $table) {
$table->foreign('learning_product_id')->references('id')->on('learning_products');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('versions', function (Blueprint $table) {
$table->dropForeign('versions_learning_product_id_foreign');
});
Schema::dropIfExists('versions');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilteritemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('filter_items', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('filter_id');
$table->string('title');
$table->string('subtitle')->nullable();
$table->string('color')->nullable();
});
Schema::table('filter_items', function (Blueprint $table) {
$table->foreign('filter_id')->references('id')->on('filters');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('filter_items', function (Blueprint $table) {
$table->dropForeign('filter_items_filter_id_foreign');
});
Schema::dropIfExists('filter_items');
}
}

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilterItemsAssociationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('filter_items_associations', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('filter_item_id');
$table->integer('filter_items_associations_id');
$table->string('filter_items_associations_type');
$table->unique([
'filter_item_id',
'filter_items_associations_id',
'filter_items_associations_type'
], 'filter_item_id_model_id_type_unique');
$table->timestamps();
});
Schema::table('filter_items_associations', function (Blueprint $table) {
$table->foreign('filter_item_id')->references('id')->on('filter_items');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('filter_items_associations', function (Blueprint $table) {
$table->dropForeign('filter_items_associations_filter_item_id_foreign');
});
Schema::dropIfExists('filter_items_associations');
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAccreditationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accreditations', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('learning_product_id');
$table->string('credits')->nullable();
$table->dateTime('date_start', 0)->nullable();
$table->dateTime('date_end', 0)->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::table('accreditations', function (Blueprint $table) {
$table->foreign('learning_product_id')->references('id')->on('learning_products')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('accreditations', function (Blueprint $table) {
$table->dropForeign('accreditations_learning_product_id_foreign');
});
Schema::dropIfExists('accreditations');
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCourseNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('course_notifications', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('learning_product_id');
$table->dateTime('date', 0)->nullable();
$table->string('time', 0)->nullable();
$table->string('subject')->nullable();
$table->longText('message')->nullable();
$table->json('emails');
$table->json('users');
$table->timestamps();
});
Schema::table('course_notifications', function (Blueprint $table) {
$table->foreign('learning_product_id')->references('id')->on('learning_products')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('course_notifications', function (Blueprint $table) {
$table->dropForeign('course_notifications_learning_product_id_foreign');
});
Schema::dropIfExists('course_notifications');
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateChecklistCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('checklist_categories', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('checklist_categories');
}
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateChecklistsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('checklists', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('checklist_category_id');
$table->string('title');
$table->string('subtitle')->nullable();
});
Schema::table('checklists', function (Blueprint $table) {
$table->foreign('checklist_category_id')->references('id')->on('checklist_categories');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('checklists', function (Blueprint $table) {
$table->dropForeign('checklists_checklist_category_id_foreign');
});
Schema::dropIfExists('checklists');
}
}

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateChecklistVersionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('checklist_versions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('version_id');
$table->unsignedInteger('checklist_id');
$table->unsignedInteger('user_id');
$table->unique([
'version_id',
'checklist_id',
], 'checklist_id_version_id_unique');
$table->timestamps();
});
Schema::table('checklist_versions', function (Blueprint $table) {
$table->foreign('version_id')->references('id')->on('versions');
$table->foreign('checklist_id')->references('id')->on('checklists');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('checklist_versions', function (Blueprint $table) {
$table->dropForeign('checklist_versions_version_id_foreign');
$table->dropForeign('checklist_versions_checklist_id_foreign');
$table->dropForeign('checklist_versions_user_id_foreign');
});
Schema::dropIfExists('checklist_versions');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSynonymsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('synonyms', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('synonyms');
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLearningProductSynonym extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('learning_product_synonym', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('synonym_id');
$table->unsignedInteger('learning_product_id');
$table->unique([
'synonym_id',
'learning_product_id',
], 'synonym_id_learning_product_id_unique');
});
Schema::table('learning_product_synonym', function (Blueprint $table) {
$table->foreign('synonym_id')->references('id')->on('synonyms')->onDelete('cascade');
$table->foreign('learning_product_id')->references('id')->on('learning_products')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_product_synonym', function (Blueprint $table) {
$table->dropForeign('learning_product_synonym_synonym_id_foreign');
$table->dropForeign('learning_product_synonym_learning_product_id_foreign');
});
Schema::dropIfExists('learning_product_synonym');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBranchesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('branches', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('branches');
}
}

View File

@@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('members', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('branch_id')->nullable();
$table->string('type');
$table->string('informal_name')->nullable();
$table->string('formal_name')->nullable();
$table->string('kvk_number')->nullable();
$table->string('website')->nullable();
$table->string('logo')->nullable();
$table->integer('b_cp')->nullable();
$table->integer('b_cc')->nullable();
$table->integer('kg_cp')->nullable();
$table->integer('kg_cc')->nullable();
$table->integer('av_cp')->nullable();
$table->integer('av_cc')->nullable();
$table->boolean('show_on_website')->default(false);
$table->string('helpdesk_department')->nullable();
$table->string('helpdesk_contact_person')->nullable();
$table->string('helpdesk_email')->nullable();
$table->string('helpdesk_phone')->nullable();
$table->string('info_department')->nullable();
$table->string('info_contacteperson')->nullable();
$table->string('info_email')->nullable();
$table->string('info_phone')->nullable();
$table->string('info_address')->nullable();
$table->string('info_housenumber')->nullable();
$table->string('info_postal')->nullable();
$table->string('info_city')->nullable();
$table->string('info_link')->nullable();
$table->string('more_info_link')->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::table('members', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('branch_id')->references('id')->on('branches');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropForeign('members_user_id_foreign');
$table->dropForeign('members_branch_id_foreign');
});
Schema::dropIfExists('members');
}
}

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id');
$table->string('indicating')->nullable();
$table->enum('type', ['main', 'visiting', 'invoice', 'other']);
$table->string('first_name_contact_person')->nullable();
$table->string('last_name_contact_person')->nullable();
$table->string('infix')->nullable();
$table->string('email')->nullable();
$table->string('address')->nullable();
$table->string('postal')->nullable();
$table->string('phone')->nullable();
$table->string('city')->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::table('addresses', function (Blueprint $table) {
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('addresses', function (Blueprint $table) {
$table->dropForeign('addresses_member_id_foreign');
});
Schema::dropIfExists('addresses');
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSummariesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('summaries', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id');
$table->integer('year');
$table->integer('real_number_last_year')->nullable();
$table->integer('estimated_number_next_year')->nullable();
$table->unique(['member_id', 'year']);
$table->timestamps();
});
Schema::table('summaries', function (Blueprint $table) {
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('summaries', function (Blueprint $table) {
$table->dropForeign('summaries_member_id_foreign');
});
Schema::dropIfExists('summaries');
}
}

View File

@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contacts', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id');
$table->string('function')->nullable();
$table->string('salutation_cp')->nullable();
$table->string('initials_cp')->nullable();
$table->string('lastname_cp')->nullable();
$table->string('email_cp')->nullable();
$table->string('email2_cp')->nullable();
$table->string('phone_cp')->nullable();
$table->string('address_cp')->nullable();
$table->string('postal_cp')->nullable();
$table->string('city_cp')->nullable();
$table->string('salutation_cc')->nullable();
$table->string('initials_cc')->nullable();
$table->string('lastname_cc')->nullable();
$table->string('email_cc')->nullable();
$table->string('email2_cc')->nullable();
$table->string('phone_cc')->nullable();
$table->string('address_cc')->nullable();
$table->string('postal_cc')->nullable();
$table->string('city_cc')->nullable();
$table->timestamps();
});
Schema::table('contacts', function (Blueprint $table) {
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropForeign('contacts_member_id_foreign');
});
Schema::dropIfExists('contacts');
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBranchMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('branch_members', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('branch_id');
$table->unsignedInteger('member_id');
$table->unique([
'branch_id',
'member_id',
], 'branch_id_member_id_unique');
});
Schema::table('branch_members', function (Blueprint $table) {
$table->foreign('branch_id')->references('id')->on('branches')->onDelete('cascade');
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('branch_members', function (Blueprint $table) {
$table->dropForeign('branch_members_branch_id_foreign');
$table->dropForeign('branch_members_member_id_foreign');
});
Schema::dropIfExists('branch_members');
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateRevisionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('revisions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id')->unique();
$table->unsignedInteger('user_id');
$table->unsignedInteger('revisor_id')->nullable();
$table->json('data');
$table->timestamps();
$table->timestamp('accepted_at')->nullable();
});
Schema::table('revisions', function (Blueprint $table) {
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('revisor_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('revisions', function (Blueprint $table) {
$table->dropForeign('revisions_member_id_foreign');
$table->dropForeign('revisions_user_id_foreign');
$table->dropForeign('revisions_revisor_id_foreign');
});
Schema::dropIfExists('revisions');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddQualityStandardsToLearningProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->string('quality_standards')->after('target_audience')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->dropColumn('quality_standards');
});
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddMembershipFieldsToMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('members', function (Blueprint $table) {
$table->dateTime('start_membership', 0)->after('kvk_number')->nullable();
$table->dateTime('end_membership', 0)->after('start_membership')->nullable();
$table->string('contribution')->after('end_membership')->nullable();
$table->string('invoice_number')->after('contribution')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('start_membership');
$table->dropColumn('end_membership');
$table->dropColumn('contribution');
$table->dropColumn('invoice_number');
});
}
}

View File

@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsToAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('addresses', function (Blueprint $table) {
$table->string('title_contact_person')->after('last_name_contact_person')->nullable();
$table->string('initials_contact_person')->after('title_contact_person')->nullable();
$table->string('middle_name_contact_person')->after('initials_contact_person')->nullable();
$table->string('job_title_contact_person')->after('middle_name_contact_person')->nullable();
$table->string('house_number')->after('address')->nullable();
$table->string('country')->after('city')->nullable();
$table->string('title_representative')->after('country')->nullable();
$table->string('initials_representative')->after('title_representative')->nullable();
$table->string('first_name_representative')->after('initials_representative')->nullable();
$table->string('middle_name_representative')->after('first_name_representative')->nullable();
$table->string('last_name_representative')->after('middle_name_representative')->nullable();
$table->string('email_representative')->after('last_name_representative')->nullable();
$table->string('job_title_representative')->after('email_representative')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('addresses', function (Blueprint $table) {
$table->dropColumn('title_contact_person');
$table->dropColumn('initials_contact_person');
$table->dropColumn('middle_name_contact_person');
$table->dropColumn('job_title_contact_person');
$table->dropColumn('house_number');
$table->dropColumn('country');
$table->dropColumn('title_representative');
$table->dropColumn('initials_representative');
$table->dropColumn('first_name_representative');
$table->dropColumn('middle_name_representative');
$table->dropColumn('last_name_representative');
$table->dropColumn('email_representative');
$table->dropColumn('job_title_representative');
});
}
}

View File

@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsToContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
$table->string('firstname_cp')->after('city_cp')->nullable();
$table->string('middlename_cp')->after('firstname_cp')->nullable();
$table->string('job_title_cp')->after('middlename_cp')->nullable();
$table->string('email3_cp')->after('job_title_cp')->nullable();
$table->string('mobile_cp')->after('email3_cp')->nullable();
$table->string('house_number_cp')->after('mobile_cp')->nullable();
$table->string('firstname_cc')->after('city_cc')->nullable();
$table->string('middlename_cc')->after('firstname_cc')->nullable();
$table->string('job_title_cc')->after('middlename_cc')->nullable();
$table->string('email3_cc')->after('job_title_cc')->nullable();
$table->string('mobile_cc')->after('email3_cc')->nullable();
$table->string('house_number_cc')->after('mobile_cc')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropColumn('firstname_cp');
$table->dropColumn('middlename_cp');
$table->dropColumn('job_title_cp');
$table->dropColumn('email3_cp');
$table->dropColumn('mobile_cp');
$table->dropColumn('house_number_cp');
$table->dropColumn('firstname_cc');
$table->dropColumn('middlename_cc');
$table->dropColumn('job_title_cc');
$table->dropColumn('email3_cc');
$table->dropColumn('mobile_cc');
$table->dropColumn('house_number_cc');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSentToCourseNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('course_notifications', function (Blueprint $table) {
$table->boolean('sent')->after('users')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('course_notifications', function (Blueprint $table) {
$table->dropColumn('sent');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddApprovatedFieldToMemberChildrens extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('summaries', function (Blueprint $table) {
$table->timestamp('approved_at')->after('estimated_number_next_year')->nullable()->default(null);
$table->unsignedInteger('revisor_id')->after('estimated_number_next_year')->nullable();
$table->foreign('revisor_id')->references('id')->on('users');
});
Schema::table('contacts', function (Blueprint $table) {
$table->timestamp('approved_at')->after('house_number_cc')->nullable()->default(null);
$table->unsignedInteger('revisor_id')->after('house_number_cc')->nullable();
$table->foreign('revisor_id')->references('id')->on('users');
});
Schema::table('addresses', function (Blueprint $table) {
$table->timestamp('approved_at')->after('job_title_representative')->nullable()->default(null);
$table->unsignedInteger('revisor_id')->after('job_title_representative')->nullable();
$table->foreign('revisor_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('summaries', function (Blueprint $table) {
$table->dropColumn('approved_at');
$table->dropForeign('summaries_revisor_id_foreign');
});
Schema::table('contacts', function (Blueprint $table) {
$table->dropColumn('approved_at');
$table->dropForeign('contacts_revisor_id_foreign');
});
Schema::table('addresses', function (Blueprint $table) {
$table->dropColumn('approved_at');
$table->dropForeign('addresses_revisor_id_foreign');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateManagementLinksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('management_links', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('member_id');
$table->string('title')->nullable();
$table->text('url')->nullable();
$table->enum('target', ['blank', 'self']);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('management_links');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddLinkToFilterItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('filter_items', function (Blueprint $table) {
$table->string('link')->after('color')->nullable()->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('filter_items', function (Blueprint $table) {
$table->dropColumn('link');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use App\Repositories\Contact;
use Illuminate\Database\Migrations\Migration;
class RenameFunctionsInContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Contact::where('function', 'Bestuurders')
->update(['function' => 'Bestuurder']);
Contact::where('function', 'Klankbordgroepleden')
->update(['function' => 'Klankbordgroeplid']);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Contact::where('function', 'Bestuurder')
->update(['function' => 'Bestuurders']);
Contact::where('function', 'Klankbordgroeplid')
->update(['function' => 'Klankbordgroepleden']);
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddInfoCountryToMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('members', function (Blueprint $table) {
$table->string('info_country')->after('info_city')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('info_country');
});
}
}

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContributionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contributions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('member_id');
$table->integer('year');
$table->string('contribution')->nullable();
$table->unique(['member_id', 'year']);
$table->timestamps();
});
Schema::table('contributions', function (Blueprint $table) {
$table->foreign('member_id')->references('id')->on('members')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('summaries', function (Blueprint $table) {
$table->dropForeign('contributions_member_id_foreign');
});
Schema::dropIfExists('contributions');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddApprovatedFieldsToContributionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contributions', function (Blueprint $table) {
$table->unsignedInteger('revisor_id')->after('contribution')->nullable();
$table->timestamp('approved_at')->after('revisor_id')->nullable()->default(null);
$table->foreign('revisor_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contributions', function (Blueprint $table) {
$table->dropColumn('approved_at');
$table->dropForeign('contributions_revisor_id_foreign');
});
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DeleteRepresentativeFieldsFromAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('addresses', function (Blueprint $table) {
$table->dropColumn('title_representative');
$table->dropColumn('initials_representative');
$table->dropColumn('first_name_representative');
$table->dropColumn('middle_name_representative');
$table->dropColumn('last_name_representative');
$table->dropColumn('email_representative');
$table->dropColumn('job_title_representative');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('addresses', function (Blueprint $table) {
$table->string('title_representative')->after('country')->nullable();
$table->string('initials_representative')->after('title_representative')->nullable();
$table->string('first_name_representative')->after('initials_representative')->nullable();
$table->string('middle_name_representative')->after('first_name_representative')->nullable();
$table->string('last_name_representative')->after('middle_name_representative')->nullable();
$table->string('email_representative')->after('last_name_representative')->nullable();
$table->string('job_title_representative')->after('email_representative')->nullable();
});
}
}

View File

@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AlterTypeInMembersTable extends Migration
{
const MEMBER_TYPE_ENUM_FIRST = 'A';
const MEMBER_TYPE_ENUM_LAST = 'J';
const MEMBER_TYPE_VALUE_DEFAULT = self::MEMBER_TYPE_ENUM_FIRST;
const MEMBER_TYPE_VALUE_OLD = 'ggz';
const MEMBER_TYPE_POSITION_AFTER = 'branch_id';
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/**
* We currently drop and recreate the column instead of altering it due to a limitation in doctrine/dbal.
*
* @see https://github.com/laravel/framework/issues/1186
*/
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('type');
});
Schema::table('members', function (Blueprint $table) {
$enumChoices = range(self::MEMBER_TYPE_ENUM_FIRST, self::MEMBER_TYPE_ENUM_LAST);
$table->enum('type', $enumChoices)
->default(self::MEMBER_TYPE_VALUE_DEFAULT)
->after(self::MEMBER_TYPE_POSITION_AFTER);
});
DB::table('members')
->whereNull('type')
->update(['type' => self::MEMBER_TYPE_VALUE_DEFAULT]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->string('type')->change();
});
DB::table('members')->update(['type' => self::MEMBER_TYPE_VALUE_OLD]);
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DeleteSomeCcAndCpAddressesFieldsFromContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropColumn('address_cp');
$table->dropColumn('house_number_cp');
$table->dropColumn('postal_cp');
$table->dropColumn('city_cp');
$table->dropColumn('address_cc');
$table->dropColumn('house_number_cc');
$table->dropColumn('postal_cc');
$table->dropColumn('city_cc');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->string('address_cp')->nullable();
$table->string('house_number_cp')->after('mobile_cp')->nullable();
$table->string('postal_cp')->nullable();
$table->string('city_cp')->nullable();
$table->string('address_cc')->nullable();
$table->string('house_number_cc')->after('mobile_cc')->nullable();
$table->string('postal_cc')->nullable();
$table->string('city_cc')->nullable();
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAddressIdToContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
$table->unsignedInteger('address_id')->after('revisor_id')->nullable();
$table->foreign('address_id')->references('id')->on('addresses');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropForeign('contacts_address_id_foreign');
});
}
}

View File

@@ -0,0 +1,81 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DeleteAndRenameFieldsFromContactsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('contacts', function (Blueprint $table) {
// salutation and firstname are inverted because they filled salutation as firstname
// middlename and initials are inverted because they filled initials as middlename
$table->renameColumn('salutation_cp', 'firstname');
$table->renameColumn('firstname_cp', 'salutation');
$table->renameColumn('initials_cp', 'middlename');
$table->renameColumn('middlename_cp', 'initials');
$table->renameColumn('lastname_cp', 'lastname');
$table->renameColumn('email_cp', 'email');
$table->renameColumn('email2_cp', 'email2');
$table->renameColumn('phone_cp', 'phone');
$table->renameColumn('job_title_cp', 'job_title');
$table->renameColumn('email3_cp', 'email3');
$table->renameColumn('mobile_cp', 'mobile');
$table->dropColumn('salutation_cc');
$table->dropColumn('initials_cc');
$table->dropColumn('lastname_cc');
// $table->dropColumn('email_cc'); // rename to email2?
$table->dropColumn('email2_cc');
$table->dropColumn('email3_cc');
$table->dropColumn('phone_cc');
$table->dropColumn('firstname_cc');
$table->dropColumn('middlename_cc');
$table->dropColumn('job_title_cc');
$table->dropColumn('mobile_cc');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('contacts', function (Blueprint $table) {
$table->renameColumn('salutation', 'salutation_cp');
$table->renameColumn('initials', 'initials_cp');
$table->renameColumn('lastname', 'lastname_cp');
$table->renameColumn('email', 'email_cp');
$table->renameColumn('email2', 'email2_cp');
$table->renameColumn('phone', 'phone_cp');
$table->renameColumn('firstname', 'firstname_cp');
$table->renameColumn('middlename', 'middlename_cp');
$table->renameColumn('job_title', 'job_title_cp');
$table->renameColumn('email3', 'email3_cp');
$table->renameColumn('mobile', 'mobile_cp');
$table->string('salutation_cc')->nullable();
$table->string('initials_cc')->nullable();
$table->string('lastname_cc')->nullable();
// $table->string('email_cc')->nullable();
$table->string('email2_cc')->nullable();
$table->string('phone_cc')->nullable();
$table->string('firstname_cc')->nullable();
$table->string('middlename_cc')->nullable();
$table->string('job_title_cc')->nullable();
$table->string('email3_cc')->nullable();
$table->string('mobile_cc')->nullable();
});
}
}

View File

@@ -0,0 +1,58 @@
<?php
use App\Repositories\Role;
use App\Repositories\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
class AddSuperAdminEntryToRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('roles', function ($table) {
$table->unique('name', 'roles_name_unique');
});
$user = User::where('email', 'kees@ggzecademy.nl')->with(['roles'])->first();
// FIXME: move elsewhere, never run right now if things are set up properly
if (!is_null($user)) {
$super_admin_role = Role::create(['name' => 'super_admin', 'color' => 'black']);
$admin_role = Role::where('name', 'admin')->first();
$operator_role = Role::where('name', 'operator')->first();
$user_role = Role::where('name', 'user')->first();
$user->roles()->sync([
$super_admin_role->id,
$admin_role->id,
$operator_role->id,
$user_role->id
]);
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('roles', function ($table) {
$table->dropUnique('roles_name_unique');
});
// Delete all role_user records with super admin role_id
$admin_role = Role::where('name', 'super_admin')->first();
DB::table('role_user')->where('role_id', $admin_role->id)->delete();
// Delete super admin role
$admin_role->delete();
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddForMembersToLearningProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->boolean('for_members')->after('support_tickets_link')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->dropColumn('for_members');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MakeForMemberNullableOnLearningProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->integer('for_members')->unsigned()->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->integer('for_members')->unsigned()->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddThirdyPartTrainingToLearningProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->boolean('third_party_training')->after('for_members')->unsigned()->nullable()->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->dropColumn('third_party_training');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddValueToEnumTypeFieldInAddresses extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('addresses', function (Blueprint $table) {
DB::statement("ALTER TABLE addresses MODIFY COLUMN type ENUM('main', 'visiting', 'invoice', 'postal', 'other')");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('addresses', function (Blueprint $table) {
DB::statement("ALTER TABLE addresses MODIFY COLUMN type ENUM('main', 'visiting', 'invoice', 'other')");
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMemberUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('member_users', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('member_id');
$table->unsignedInteger('user_id');
$table->foreign('member_id')->references('id')->on('members');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('member_users');
}
}

View File

@@ -0,0 +1,73 @@
<?php
use App\Repositories\Member;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Webmozart\Assert\Assert;
class MigrateUserIdColumnFromMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Member::all() as $member) {
$member->users()->attach($member->user_id);
}
Schema::table('members', function (Blueprint $table) {
$table->dropForeign('members_user_id_foreign');
$table->dropColumn('user_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (!Schema::hasColumn('members', 'user_id')) {
Schema::table('members', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable()->after('id');
$table->foreign('user_id')->references('id')->on('users');
});
}
$memberUserAll = DB::table('member_users')
->select(['member_id', 'user_id'])
->get();
foreach ($memberUserAll as $memberUser) {
Assert::notNull($memberUser->user_id);
}
foreach ($memberUserAll as $memberUser) {
Member::findOrFail($memberUser->member_id)
->update(['user_id' => $memberUser->user_id]);
}
$amountMemberWithoutUser = DB::table('members')
->select('id')
->whereNull('user_id')
->count();
Assert::eq(
$amountMemberWithoutUser,
0,
sprintf(
'Found %d member(s) without an attached user, expected 0.',
$amountMemberWithoutUser,
),
);
Schema::table('members', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable(false)->change();
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class AddUniqueIndexToMemberUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('member_users', function (Blueprint $table) {
$table->unique(['member_id', 'user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('member_users', function (Blueprint $table) {
$table->dropForeign(['member_id']);
$table->dropForeign(['user_id']);
$table->dropUnique(['member_id', 'user_id']);
$table->foreign('member_id')->references('id')->on('members');
$table->foreign('user_id')->references('id')->on('users');
});
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterColumnsInMemberUsersTableToCascadeOnDelete extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('member_users', function (Blueprint $table) {
$table->dropForeign(['member_id']);
$table->foreign(['member_id'])
->references('id')
->on('members')
->cascadeOnDelete();
$table->dropForeign(['user_id']);
$table->foreign(['user_id'])
->references('id')
->on('users')
->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('member_users', function (Blueprint $table) {
$table->dropForeign(['member_id']);
$table->foreign(['member_id'])->references('id')->on('members');
$table->dropForeign(['user_id']);
$table->foreign(['user_id'])->references('id')->on('users');
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddVoorOpleidersToLearningProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->boolean('voor_opleiders')->default(false)->after('third_party_training');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('learning_products', function (Blueprint $table) {
$table->dropColumn('voor_opleiders');
});
}
}