Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('full_name')->nullable();
$table->string('email', 191)->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('profile_photo_path', 2048)->nullable();
$table->text('about')->nullable();
$table->string('about_short', 150)->nullable();
$table->text('motivation')->nullable();
$table->date('date_of_birth')->nullable();
$table->string('website')->nullable();
$table->string('phone', 20)->nullable();
$table->boolean('phone_public')->default(0);
$table->rememberToken();
$table->foreignId('current_team_id')->nullable();
$table->integer('cyclos_id')->unique()->nullable();
$table->string('cyclos_salt', 32)->nullable();
$table->string('cyclos_skills', 500)->nullable();
$table->integer('limit_min')->nullable();
$table->integer('limit_max')->nullable();
$table->string('comment', 500)->nullable();
$table->string('lang_preference', 6)->nullable();
$table->timestamps();
$table->datetime('inactive_at')->nullable();
$table->datetime('last_login_at')->nullable();
$table->string('last_login_ip')->nullable();
$table->softDeletes();
});
}
/**
* 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,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Laravel\Fortify\Fortify;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->text('two_factor_secret')
->after('password')
->nullable();
$table->text('two_factor_recovery_codes')
->after('two_factor_secret')
->nullable();
if (Fortify::confirmsTwoFactorAuthentication()) {
$table->timestamp('two_factor_confirmed_at')
->after('two_factor_recovery_codes')
->nullable();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(array_merge([
'two_factor_secret',
'two_factor_recovery_codes',
], Fortify::confirmsTwoFactorAuthentication() ? [
'two_factor_confirmed_at',
] : []));
});
}
};

View File

@@ -0,0 +1,36 @@
<?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->string('uuid')->unique();
$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,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProfilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('profiles', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->date('date_of_birth')->nullable();
$table->text('content')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('profiles');
}
}

View File

@@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrganizationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('organizations', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('full_name')->nullable();
$table->string('email', 191)->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->string('profile_photo_path', 2048)->nullable();
$table->text('about')->nullable();
$table->string('about_short', 150)->nullable();
$table->text('motivation')->nullable();
$table->string('website')->nullable();
$table->string('phone', 20)->nullable();
$table->boolean('phone_public')->default(0);
$table->integer('cyclos_id')->unique()->nullable();
$table->string('cyclos_salt', 32)->nullable();
$table->string('cyclos_skills', 500)->nullable();
$table->integer('limit_min')->nullable();
$table->integer('limit_max')->nullable();
$table->string('comment', 500)->nullable();
$table->string('lang_preference', 6)->nullable();
$table->timestamps();
$table->datetime('inactive_at')->nullable();
$table->datetime('last_login_at')->nullable();
$table->string('last_login_ip')->nullable();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('organizations');
}
}

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accounts', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->integer('limit_min')->nullable();
$table->integer('limit_max')->nullable();
$table->string('accountable_type');
$table->unsignedBigInteger('accountable_id');
$table->integer('cyclos_id')->unique()->nullable();
$table->timestamps();
$table->datetime('inactive_at')->nullable();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('accounts');
}
}

View File

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

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSociablesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sociables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('social_id');
$table->string('sociable_type');
$table->unsignedBigInteger('sociable_id');
$table->string('user_on_social');
$table->string('server_of_social')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sociables');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->id();
$table->string('path');
$table->unsignedBigInteger('position')->nullable();
$table->string('caption')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('images');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('imageables', function (Blueprint $table) {
$table->id();
$table->integer("image_id");
$table->integer('imageable_id');
$table->string('imageable_type');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('imageables');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCommentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->text('content');
$table->string('commentable_type');
$table->bigInteger('commentable_id');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('comments');
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBlogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('parent_blog_id');
$table->string('locale', 3);
$table->string('title');
$table->text('content');
$table->unsignedBigInteger('user_id');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('blogs');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionTypesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transaction_types', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->unique();
$table->string('label', 200)->unique();
$table->string('icon', 20)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transaction_types');
}
}

View File

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

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('from_account_id');
$table->unsignedBigInteger('to_account_id');
$table->unsignedBigInteger('creator_user_id')->nullable();
$table->boolean('from_authorised_by_user_id')->default(false);
$table->timestamp('from_authorisation_time')->nullable();
$table->boolean('to_authorised_by_user_id')->default(false);
$table->timestamp('to_authorisation_time')->nullable();
$table->integer('amount');
$table->dateTime('programmed_time')->nullable();
$table->text('description');
$table->string('from_reference')->nullable();;
$table->string('to_reference')->nullable();;
$table->unsignedBigInteger('transaction_type_id')->nullable();
$table->unsignedBigInteger('transaction_status_id')->nullable();
$table->unsignedBigInteger('cancelled_by_user_id')->nullable();
$table->timestamp('cancelled_time')->nullable();
$table->unsignedBigInteger('advertisement_id')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transactions');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSessionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sessions');
}
}

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,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('organization_user', function (Blueprint $table) {
$table->id();
$table->integer('organization_id')->unsigned;
$table->integer('user_id')->unsigned;
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('organization_user');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('countries', function (Blueprint $table) {
$table->id();
$table->string('code', 16)->unique();
$table->string('flag', 16);
$table->string('phonecode', 8)->unique();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('countries');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('country_locales', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('country_id')->index();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->string('name', 255);
$table->string('alias', 255)->nullable();
$table->string('locale', 6)->index();
$table->unique(['country_id','locale'], 'uniq_country_id_locale');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('country_locales');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('country_languages', function (Blueprint $table) {
$table->id();
$table->integer('country_id');
$table->string('code', 16);
$table->unique(array('country_id','code'));
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('country_languages');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('divisions', function (Blueprint $table) {
$table->id();
$table->bigInteger('country_id')->unsigned()->nullable()->index();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('divisions');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('division_locales', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('division_id')->index();
$table->foreign('division_id')->references('id')->on('divisions')->onDelete('cascade');
$table->string('name', 255);
$table->string('alias', 255)->nullable();
$table->string('locale', 6)->index();
$table->unique(['division_id','locale'], 'uniq_division_id_locale');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('division_locales');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cities', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('country_id')->index();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->unsignedBigInteger('division_id')->nullable()->index();
$table->foreign('division_id')->references('id')->on('divisions')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cities');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('city_locales', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('city_id')->index();
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
$table->string('name', 255);
$table->string('alias', 255)->nullable();
$table->string('locale', 6)->index();
$table->unique(['city_id','locale'], 'uniq_city_id_locale');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('city_locales');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('districts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('city_id')->index();
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('districts');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('district_locales', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('district_id')->index();
$table->foreign('district_id')->references('id')->on('districts')->onDelete('cascade');
$table->string('name', 255);
$table->string('alias', 255)->nullable();
$table->string('locale', 6)->index();
$table->unique(['district_id','locale'], 'uniq_district_id_locale');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('district_locales');
}
};

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('locations', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->unsignedBigInteger('country_id')->nullable();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->unsignedBigInteger('division_id')->nullable();
$table->foreign('division_id')->references('id')->on('divisions')->onDelete('cascade');
$table->unsignedBigInteger('city_id')->nullable();
$table->foreign('city_id')->references('id')->on('cities')->onDelete('cascade');
$table->unsignedBigInteger('district_id')->nullable();
$table->foreign('district_id')->references('id')->on('districts')->onDelete('cascade');
$table->unsignedBigInteger('locatable_id'); // Setup one-to-many polymorph relationship
$table->string('locatable_type'); // Setup one-to-many polymorph relationship
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('locations');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLanguagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('languages', function (Blueprint $table) {
$table->id();
// $table->unsignedBigInteger('user_id');
// $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('name');
$table->string('lang_code', 6);
$table->string('flag', 16)->comment('Country Emoji');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('languages');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('languagables', function (Blueprint $table) {
$table->id();
$table->integer('language_id');
$table->integer('competence');
$table->string('languagable_type');
$table->unsignedBigInteger('languagable_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('languagables');
}
};

View File

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

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('causer', 'causer');
$table->json('properties')->nullable();
$table->timestamps();
$table->index('log_name');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
}

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddEventColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->string('event')->nullable()->after('subject_type');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('event');
});
}
}

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddBatchUuidColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->uuid('batch_uuid')->nullable()->after('properties');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('batch_uuid');
});
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->integer('postable_id'); // Make author polymorph: user / organization / other
$table->string('postable_type'); // Make author polymorph: user / organization / other
$table->integer('category_id')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('post_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('post_id')->constrained()->onDelete('cascade');
$table->string('locale', 6)->index();
$table->string('slug')->unique();
$table->string('title')->nullable();
$table->text('excerpt')->nullable();
$table->longtext('content')->nullable();
$table->integer('status')->unsigned()->default(1);
$table->integer('updated_by_user_id')->unsigned()->nullable();
$table->dateTime('from')->nullable();
$table->dateTime('till')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('post_translations');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('type'); // For easier identification of this category
$table->integer('categoryable_id')->nullable(); // Link the category type to another model: city / organization / other (polymorph)
$table->string('categoryable_type')->nullable(); // Link the category type to another model: city / organization / other (polymorph)
$table->unsignedBigInteger('parent_id')->nullable(); // Create nested multilevel categories: id of parent category
$table->string('color')->nullable()->comment('css class');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('category_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')->constrained()->onDelete('cascade');
$table->string('locale', 6)->index();
$table->string('slug')->unique();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('category_translations');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->morphs('model');
$table->uuid('uuid')->nullable()->unique();
$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('generated_conversions');
$table->json('responsive_images');
$table->unsignedInteger('order_column')->nullable()->index();
$table->nullableTimestamps();
});
}
};

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('meetings', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('post_id')->unique(); // one-to-one relationship
$table->foreign('post_id')->nullable()->references('id')->on('posts')->onDelete('cascade');
$table->string('venue', 150)->nullable();
$table->string('address')->nullable(); // TODO: refactor into location model in later stage
$table->integer('meetingable_id')->nullable(); // Make organizer polymorph: user / organization / other
$table->string('meetingable_type')->nullable(); // Make organizer polymorph: user / organization / other
$table->integer('status')->unsigned()->default(1);
$table->dateTime('from')->nullable();
$table->dateTime('till')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('meetings');
}
};

View File

@@ -0,0 +1,77 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTaggableTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$connection = config('taggable.connection');
$taggableTagsTable = config('taggable.tables.taggable_tags', 'taggable_tags');
$taggableTaggablesTable = config('taggable.tables.taggable_taggables', 'taggable_taggables');
$charset = Schema::connection($connection)->getConnection()->getConfig('charset') ?? 'utf8mb4';
$driver = Schema::connection($connection)->getConnection()->getConfig('driver');
switch ($driver) {
case 'pgsql':
$collation = null;
break;
case 'sqlite':
case 'sqlsrv':
default:
$collation = $charset .'_bin';
}
if (!Schema::connection($connection)->hasTable($taggableTagsTable)) {
Schema::connection($connection)->create($taggableTagsTable, static function(Blueprint $table) use ($collation) {
$table->bigIncrements('tag_id');
$table->string('name');
$table->string('normalized')->unique()->collation($collation);
$table->timestamps();
$table->index('normalized');
});
}
if (!Schema::connection($connection)->hasTable($taggableTaggablesTable)) {
Schema::connection($connection)->create($taggableTaggablesTable, static function(Blueprint $table) {
$table->unsignedBigInteger('tag_id');
$table->unsignedBigInteger('taggable_id');
$table->string('taggable_type');
$table->timestamps();
$table->unique(['tag_id', 'taggable_id', 'taggable_type']);
$table->index(['tag_id', 'taggable_id'], 'i_taggable_fwd');
$table->index(['taggable_id', 'tag_id'], 'i_taggable_rev');
$table->index('taggable_type', 'i_taggable_type');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$connection = config('taggable.connection');
$taggableTagsTable = config('taggable.tables.taggable_tags', 'taggable_tags');
$taggableTaggablesTable = config('taggable.tables.taggable_taggables', 'taggable_taggables');
if (Schema::connection($connection)->hasTable($taggableTagsTable)) {
Schema::connection($connection)->drop($taggableTagsTable);
}
if (Schema::connection($connection)->hasTable($taggableTaggablesTable)) {
Schema::connection($connection)->drop($taggableTaggablesTable);
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('taggable_locales', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('taggable_tag_id'); // Foreign key column
$table->string('locale', 6);
$table->string('comment', 500)->nullable();
$table->unsignedBigInteger('updated_by_user')->nullable();
$table->timestamps();
$table->unique(['taggable_tag_id', 'locale']);
$table->foreign('taggable_tag_id')->references('tag_id')->on('taggable_tags')->onDelete('cascade');
$table->index('locale');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('taggable_locales');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('taggable_contexts', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('updated_by_user')->nullable();
$table->timestamps();
$table->foreign('updated_by_user')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('taggable_contexts');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('taggable_locale_context', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tag_id')->unique(); // Foreign key column
$table->unsignedBigInteger('context_id'); // Foreign key column
$table->foreign('tag_id')->references('tag_id')->on('taggable_tags')->onDelete('cascade'); // Many-to-many relation
$table->foreign('context_id')->references('id')->on('taggable_contexts')->onDelete('cascade'); // Many-to-many relation
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('taggable_locale_context');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('taggable_tags', function (Blueprint $table) {
$table->dropUnique('taggable_tags_normalized_unique'); // Drop original package constraint as multiple languages can use the same words with different context
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('taggable_tags', function (Blueprint $table) {
$table->unique('normalized'); // Restore original package constraint
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->foreignId('love_reacter_id')->nullable();
$table
->foreign('love_reacter_id')
->references('id')
->on('love_reacters');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['love_reacter_id']);
$table->dropColumn('love_reacter_id');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->foreignId('love_reactant_id')->nullable();
$table
->foreign('love_reactant_id')
->references('id')
->on('love_reactants');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['love_reactant_id']);
$table->dropColumn('love_reactant_id');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->foreignId('love_reacter_id')->nullable();
$table
->foreign('love_reacter_id')
->references('id')
->on('love_reacters');
});
}
public function down(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->dropForeign(['love_reacter_id']);
$table->dropColumn('love_reacter_id');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->foreignId('love_reactant_id')->nullable();
$table
->foreign('love_reactant_id')
->references('id')
->on('love_reactants');
});
}
public function down(): void
{
Schema::table('organizations', function (Blueprint $table) {
$table->dropForeign(['love_reactant_id']);
$table->dropColumn('love_reactant_id');
});
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('personal_access_tokens', function (Blueprint $table) {
$table->timestamp('expires_at')->nullable()->after('last_used_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('personal_access_tokens', function (Blueprint $table) {
//
});
}
};

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('banks', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('full_name');
$table->string('email', 191)->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('profile_photo_path', 2048)->nullable();
$table->text('about')->nullable();
$table->string('about_short', 150)->nullable();
$table->text('motivation')->nullable();
$table->string('website')->nullable();
$table->string('phone', 20)->nullable();
$table->boolean('phone_public')->default(0);
$table->integer('cyclos_id')->unique()->nullable();
$table->string('cyclos_salt', 32)->nullable();
$table->tinyInteger('level')->unsigned()->default(1);
$table->integer('limit_min')->nullable();
$table->integer('limit_max')->nullable();
$table->string('comment', 500)->nullable();
$table->string('lang_preference', 6)->nullable();
$table->timestamps();
$table->datetime('inactive_at')->nullable();
$table->datetime('last_login_at')->nullable();
$table->string('last_login_ip')->nullable();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('banks');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('bank_user', function (Blueprint $table) {
$table->id();
$table->integer('bank_id')->unsigned;
$table->integer('user_id')->unsigned;
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('bank_user');
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('banks', function (Blueprint $table) {
$table->foreignId('love_reacter_id')->nullable();
$table
->foreign('love_reacter_id')
->references('id')
->on('love_reacters');
});
}
public function down(): void
{
Schema::table('banks', function (Blueprint $table) {
$table->dropForeign(['love_reacter_id']);
$table->dropColumn('love_reacter_id');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Laravel Love.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('banks', function (Blueprint $table) {
$table->foreignId('love_reactant_id')->nullable();
$table
->foreign('love_reactant_id')
->references('id')
->on('love_reactants');
});
}
public function down(): void
{
Schema::table('banks', function (Blueprint $table) {
$table->dropForeign(['love_reactant_id']);
$table->dropColumn('love_reactant_id');
});
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Models\Conversation;
return new class extends Migration
{
/*** Run the migrations */
public function up(): void
{
$usesUuid = WireChat::usesUuid();
Schema::create((new Conversation)->getTable(), function (Blueprint $table) use ($usesUuid) {
if ($usesUuid) {
$table->uuid('id')->primary();
} else {
$table->id();
}
$table->string('type')->comment('Private is 1-1 , group or channel');
$table->timestamp('disappearing_started_at')->nullable();
$table->integer('disappearing_duration')->nullable();
$table->index('type');
$table->timestamps();
});
}
/*** Reverse the migrations */
public function down(): void
{
Schema::dropIfExists((new Conversation)->getTable());
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Models\Attachment;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create((new Attachment)->getTable(), function (Blueprint $table) {
$table->id();
$table->morphs('attachable');
$table->string('file_path');
$table->string('file_name');
$table->string('original_name');
$table->string('url');
$table->string('mime_type');
$table->timestamps();
$table->index(['attachable_id', 'attachable_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new Attachment)->getTable());
}
};

View File

@@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Models\Conversation;
use Namu\WireChat\Models\Message;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$usesUuid = WireChat::usesUuid();
Schema::create((new Message)->getTable(), function (Blueprint $table) use ($usesUuid) {
$table->id();
if ($usesUuid) {
$table->uuid('conversation_id');
} else {
$table->unsignedBigInteger('conversation_id');
}
$table->foreign('conversation_id')->references('id')->on((new Conversation)->getTable())->cascadeOnDelete();
$table->unsignedBigInteger('sendable_id');
$table->string('sendable_type');
$table->unsignedBigInteger('reply_id')->nullable();
$table->foreign('reply_id')->references('id')->on((new Message)->getTable())->nullOnDelete();
$table->text('body')->nullable();
$table->string('type')->default('text');
$table->timestamp('kept_at')->nullable()->comment('filled when a message is kept from disappearing');
$table->softDeletes();
$table->timestamps();
// Indexes for optimization
$table->index(['conversation_id']);
$table->index(['sendable_id', 'sendable_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new Message)->getTable());
}
};

View File

@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Models\Conversation;
use Namu\WireChat\Models\Participant;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$usesUuid = WireChat::usesUuid();
Schema::create((new Participant)->getTable(), function (Blueprint $table) use ($usesUuid) {
$table->id();
// Foreign key for conversation
if ($usesUuid) {
$table->uuid('conversation_id');
} else {
$table->unsignedBigInteger('conversation_id');
}
$table->foreign('conversation_id')->references('id')->on((new Conversation)->getTable())->cascadeOnDelete();
$table->string('role');
$table->unsignedBigInteger('participantable_id');
$table->string('participantable_type');
// Timestamps for tracking participant activity
$table->timestamp('exited_at')->nullable()->index();
$table->timestamp('last_active_at')->nullable();
$table->timestamp('conversation_cleared_at')->nullable()->index();
$table->timestamp('conversation_deleted_at')->nullable()->index();
$table->timestamp('conversation_read_at')->nullable()->index();
$table->softDeletes();
$table->timestamps();
// Unique constraint on conversation_id, participantable_id, and participantable_type
$table->unique(['conversation_id', 'participantable_id', 'participantable_type'], 'conv_part_id_type_unique');
$table->index(['role']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new Participant)->getTable());
}
};

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Models\Action;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create((new Action)->getTable(), function (Blueprint $table) {
$table->id();
// Actionable (the entity being acted upon)
$table->unsignedBigInteger('actionable_id');
$table->string('actionable_type');
// Actor (the one performing the action
$table->unsignedBigInteger('actor_id');
$table->string('actor_type');
// Type of action (e.g., delete, archive)
$table->string('type');
$table->string('data')->nullable()->comment('Some additional information about the action');
$table->timestamps();
$table->index(['actionable_id', 'actionable_type']);
$table->index(['actor_id', 'actor_type']);
$table->index('type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new Action)->getTable());
}
};

View File

@@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Namu\WireChat\Facades\WireChat;
use Namu\WireChat\Models\Conversation;
use Namu\WireChat\Models\Group;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$usesUuid = WireChat::usesUuid();
Schema::create((new Group)->getTable(), function (Blueprint $table) use ($usesUuid) {
$table->id();
// Foreign key for conversation
if ($usesUuid) {
$table->uuid('conversation_id');
} else {
$table->unsignedBigInteger('conversation_id');
}
$table->string('name')->nullable();
$table->text('description')->nullable();
$table->string('avatar_url')->nullable();
$table->string('type')->default('private');
// Permissions
$table->boolean('allow_members_to_send_messages')->default(true);
$table->boolean('allow_members_to_add_others')->default(true);
$table->boolean('allow_members_to_edit_group_info')->default(false);
$table->boolean('admins_must_approve_new_members')->default(false)->comment('when turned on, admins must approve anyone who wants to join group');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists((new Group)->getTable());
}
};

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admins', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('full_name');
$table->string('email', 191)->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('profile_photo_path', 2048)->nullable();
$table->text('about')->nullable();
$table->string('about_short', 150)->nullable();
$table->text('motivation')->nullable();
$table->string('website')->nullable();
$table->string('phone', 20)->nullable();
$table->boolean('phone_public')->default(0);
$table->integer('cyclos_id')->unique()->nullable();
$table->string('cyclos_salt', 32)->nullable();
$table->integer('limit_min')->nullable();
$table->integer('limit_max')->nullable();
$table->string('comment', 500)->nullable();
$table->string('lang_preference', 6)->nullable();
$table->timestamps();
$table->datetime('inactive_at')->nullable();
$table->datetime('last_login_at')->nullable();
$table->string('last_login_ip')->nullable();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admins');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admin_user', function (Blueprint $table) {
$table->id();
$table->integer('admin_id')->unsigned;
$table->integer('user_id')->unsigned;
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admin_user');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admin_bank', function (Blueprint $table) {
$table->id();
$table->integer('admin_id')->unsigned;
$table->integer('bank_id')->unsigned;
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admin_bank');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMessageSettingsTable extends Migration
{
public function up()
{
Schema::create('message_settings', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('message_settingable_id');
$table->string('message_settingable_type');
$table->boolean('system_message')->default(true);
$table->boolean('payment_received')->default(true);
$table->boolean('star_received')->default(true);
$table->boolean('local_newsletter')->default(true);
$table->boolean('general_newsletter')->default(true);
$table->boolean('personal_chat')->default(true);
$table->boolean('group_chat')->default(true);
$table->integer('chat_unread_delay')->default(timebank_config('messenger.default_unread_mail_delay'));
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('message_settings');
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('bank_clients', function (Blueprint $table) {
$table->id();
$table->foreignId('bank_id')->constrained()->cascadeOnDelete();
$table->morphs('client'); // creates client_id and client_type columns
$table->string('relationship_type')->default('local'); // can be 'local' or 'specialization name', etc.
$table->timestamps();
// Ensure one bank per client
$table->unique(['client_id', 'client_type', 'relationship_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('bank_clients');
}
};

View File

@@ -0,0 +1,136 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$teams = config('permission.teams');
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
throw_if(empty($tableNames), new Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.'));
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), new Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.'));
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
// $table->engine('InnoDB');
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
};

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
// Disable foreign key checks
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
// Drop Messenger tables if they exist
Schema::dropIfExists('bot_actions');
Schema::dropIfExists('bots');
Schema::dropIfExists('call_participants');
Schema::dropIfExists('calls');
Schema::dropIfExists('friend_drivers');
Schema::dropIfExists('friends');
Schema::dropIfExists('group_invitations');
Schema::dropIfExists('invite_codes');
Schema::dropIfExists('message_edits');
Schema::dropIfExists('message_reactions');
Schema::dropIfExists('message_reads');
Schema::dropIfExists('messages');
Schema::dropIfExists('participants');
Schema::dropIfExists('pending_calls');
Schema::dropIfExists('threads');
Schema::dropIfExists('thread_invites');
Schema::dropIfExists('thread_settings');
Schema::dropIfExists('thread_stickies');
Schema::dropIfExists('thread_types');
Schema::dropIfExists('thread_unread');
Schema::dropIfExists('thread_user_settings');
// Add any other Messenger tables you find in the migrations
}
public function down(): void
{
// No down method, as this is a destructive migration
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->unsignedBigInteger('author_id')->nullable()->after('category_id');
$table->string('author_model')->nullable()->after('author_id');
$table->index(['author_id', 'author_model']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->dropIndex(['author_id', 'author_model']);
$table->dropColumn(['author_id', 'author_model']);
});
}
};

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('mailings', function (Blueprint $table) {
$table->id();
$table->string('title', 255);
$table->enum('type', ['local_newsletter', 'general_newsletter', 'system_message']);
$table->string('subject', 255);
$table->json('content_blocks')->nullable(); // Array of selected post IDs and their order
$table->datetime('scheduled_at')->nullable();
$table->datetime('sent_at')->nullable();
$table->enum('status', ['draft', 'scheduled', 'sending', 'sent', 'cancelled'])->default('draft');
$table->integer('recipients_count')->default(0);
$table->integer('sent_count')->default(0);
$table->integer('failed_count')->default(0);
$table->integer('bounced_count')->default(0);
// Polymorphic relationship for created_by
$table->unsignedBigInteger('created_by_id');
$table->string('created_by_type');
$table->index(['created_by_id', 'created_by_type']);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('mailings');
}
};

View File

@@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// First, convert existing subject strings to JSON format
$mailings = DB::table('mailings')->get();
foreach ($mailings as $mailing) {
if ($mailing->subject && !$this->isJson($mailing->subject)) {
// Convert existing string subject to JSON with base language
$subjectJson = [
timebank_config('base_language', 'en') => $mailing->subject
];
DB::table('mailings')
->where('id', $mailing->id)
->update(['subject' => json_encode($subjectJson)]);
}
}
// Then modify the column type
Schema::table('mailings', function (Blueprint $table) {
$table->json('subject')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Convert JSON subjects back to strings (base language only)
$mailings = DB::table('mailings')->get();
foreach ($mailings as $mailing) {
if ($mailing->subject && $this->isJson($mailing->subject)) {
$subjectArray = json_decode($mailing->subject, true);
$baseLanguage = timebank_config('base_language', 'en');
$subjectString = $subjectArray[$baseLanguage] ?? array_values($subjectArray)[0] ?? '';
DB::table('mailings')
->where('id', $mailing->id)
->update(['subject' => $subjectString]);
}
}
Schema::table('mailings', function (Blueprint $table) {
$table->string('subject', 255)->change();
});
}
/**
* Check if a string is valid JSON
*/
private function isJson($string): bool
{
json_decode($string);
return json_last_error() === JSON_ERROR_NONE;
}
};

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->boolean('filter_by_location')->default(false)->after('type');
$table->unsignedBigInteger('location_country_id')->nullable()->after('filter_by_location');
$table->unsignedBigInteger('location_division_id')->nullable()->after('location_country_id');
$table->unsignedBigInteger('location_city_id')->nullable()->after('location_division_id');
$table->unsignedBigInteger('location_district_id')->nullable()->after('location_city_id');
// Add foreign key constraints
$table->foreign('location_country_id')->references('id')->on('countries')->onDelete('set null');
$table->foreign('location_division_id')->references('id')->on('divisions')->onDelete('set null');
$table->foreign('location_city_id')->references('id')->on('cities')->onDelete('set null');
$table->foreign('location_district_id')->references('id')->on('districts')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->dropForeign(['location_country_id']);
$table->dropForeign(['location_division_id']);
$table->dropForeign(['location_city_id']);
$table->dropForeign(['location_district_id']);
$table->dropColumn([
'filter_by_location',
'location_country_id',
'location_division_id',
'location_city_id',
'location_district_id'
]);
});
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->boolean('filter_by_profile_type')->default(false)->after('filter_by_location');
$table->json('selected_profile_types')->nullable()->after('filter_by_profile_type')->comment('Array of profile types: User, Organization, Bank, Admin');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->dropColumn([
'filter_by_profile_type',
'selected_profile_types'
]);
});
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('mailing_bounces', function (Blueprint $table) {
$table->id();
$table->string('email')->index();
$table->string('bounce_type')->nullable(); // hard, soft, complaint
$table->text('bounce_reason')->nullable();
$table->foreignId('mailing_id')->nullable()->constrained()->nullOnDelete();
$table->timestamp('bounced_at');
$table->boolean('is_suppressed')->default(false);
$table->timestamps();
$table->unique(['email', 'mailing_id']);
});
}
public function down()
{
Schema::dropIfExists('mailing_bounces');
}
};

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('mailings', function (Blueprint $table) {
// Add updated_by_user_id column
$table->unsignedBigInteger('updated_by_user_id')->nullable()->after('status');
$table->foreign('updated_by_user_id')->references('id')->on('users')->onDelete('set null');
// Drop old created_by columns
$table->dropColumn(['created_by_id', 'created_by_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mailings', function (Blueprint $table) {
// Restore created_by columns
$table->unsignedBigInteger('created_by_id')->nullable();
$table->string('created_by_type')->nullable();
// Drop updated_by_user_id
$table->dropForeign(['updated_by_user_id']);
$table->dropColumn('updated_by_user_id');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->dropColumn('bounced_count');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mailings', function (Blueprint $table) {
$table->integer('bounced_count')->default(0);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->unsignedBigInteger('love_reactant_id')->nullable()->after('id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->dropColumn('love_reactant_id');
});
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('meetings', function (Blueprint $table) {
$table->integer('price')->nullable()->after('address');
$table->unsignedBigInteger('transaction_type_id')->nullable()->after('price');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('meetings', function (Blueprint $table) {
$table->dropForeign(['transaction_type_id']);
$table->dropColumn(['price', 'transaction_type_id']);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('meetings', function (Blueprint $table) {
$table->integer('based_on_quantity')->nullable()->after('price');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('meetings', function (Blueprint $table) {
$table->dropColumn('based_on_quantity');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('terms_accepted_at')->nullable()->after('last_login_ip');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('terms_accepted_at');
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('terms_accepted_at');
$table->json('principles_terms_accepted')->nullable()->after('last_login_ip');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('principles_terms_accepted');
$table->timestamp('terms_accepted_at')->nullable()->after('last_login_ip');
});
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('system_settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->timestamps();
});
// Insert default maintenance mode setting
DB::table('system_settings')->insert([
'key' => 'maintenance_mode',
'value' => 'false',
'created_at' => now(),
'updated_at' => now(),
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('system_settings');
}
};

View File

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

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('sessions', function (Blueprint $table) {
$table->string('guard', 50)->default('web')->after('user_id')->index();
});
// Update existing sessions to have 'web' as default guard
DB::statement("UPDATE sessions SET guard = 'web' WHERE guard IS NULL OR guard = ''");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('sessions', function (Blueprint $table) {
$table->dropColumn('guard');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('calls', function (Blueprint $table) {
$table->id();
$table->morphs('callable');
$table->unsignedBigInteger('tag_id')->nullable();
$table->foreign('tag_id')->references('tag_id')->on('taggable_tags')->nullOnDelete();
$table->unsignedBigInteger('location_id')->nullable();
$table->foreign('location_id')->references('id')->on('locations')->nullOnDelete();
$table->dateTime('from');
$table->dateTime('till')->nullable();
$table->timestamps();
$table->softDeletes();
});
Schema::create('call_translations', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('call_id');
$table->foreign('call_id')->references('id')->on('calls')->cascadeOnDelete();
$table->string('locale', 5);
$table->text('content')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('call_translations');
Schema::dropIfExists('calls');
}
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('locations', function (Blueprint $table) {
$table->unsignedBigInteger('locatable_id')->nullable()->change();
$table->string('locatable_type')->nullable()->change();
});
}
public function down(): void
{
Schema::table('locations', function (Blueprint $table) {
$table->unsignedBigInteger('locatable_id')->nullable(false)->change();
$table->string('locatable_type')->nullable(false)->change();
});
}
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (Schema::hasColumn('call_translations', 'title')) {
Schema::table('call_translations', function (Blueprint $table) {
$table->dropColumn('title');
});
}
}
public function down(): void
{
Schema::table('call_translations', function (Blueprint $table) {
$table->string('title')->after('locale');
});
}
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('calls', function (Blueprint $table) {
$table->unsignedBigInteger('love_reactant_id')->nullable()->after('id');
});
}
public function down(): void
{
Schema::table('calls', function (Blueprint $table) {
$table->dropColumn('love_reactant_id');
});
}
};

View File

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

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if (Schema::hasColumn('calls', 'is_private')) {
Schema::table('calls', function (Blueprint $table) {
$table->renameColumn('is_private', 'is_public');
});
// Invert existing values: was private (1 = hidden), now public (1 = visible)
DB::table('calls')->update(['is_public' => DB::raw('NOT is_public')]);
}
}
public function down(): void
{
DB::table('calls')->update(['is_public' => DB::raw('NOT is_public')]);
Schema::table('calls', function (Blueprint $table) {
$table->renameColumn('is_public', 'is_private');
});
}
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('call_translations', function (Blueprint $table) {
$table->softDeletes();
});
}
public function down(): void
{
Schema::table('call_translations', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('message_settings', function (Blueprint $table) {
$table->boolean('call_expiry')->default(true)->after('group_chat');
});
}
public function down(): void
{
Schema::table('message_settings', function (Blueprint $table) {
$table->dropColumn('call_expiry');
});
}
};

View File

@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
if (!DB::table('transaction_types')->where('id', 7)->exists()) {
DB::table('transaction_types')->insert([
'id' => 7,
'name' => 'Rounding correction',
'label' => 'Rounding correction: corrects balance drift from decimal-to-time format conversion',
'icon' => 'wrench',
'created_at' => null,
'updated_at' => null,
]);
}
}
public function down(): void
{
DB::table('transaction_types')->where('id', 7)->delete();
}
};

0
database/migrations/backup/.gitignore vendored Normal file
View File

View File

@@ -0,0 +1,141 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$teams = config('permission.teams');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
}

View File

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