Basic tenant structure

This commit is contained in:
2026-01-31 20:07:41 +01:00
parent 825af15962
commit 3570f442f5
35 changed files with 634 additions and 144 deletions

View File

@@ -0,0 +1,106 @@
<?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('user_roles', function (Blueprint $table) {
$table->string('slug')->unique()->primary();
$table->string('name');
$table->timestamps();
});
Schema::create('eating_habits', function (Blueprint $table) {
$table->string('slug')->unique()->primary();
$table->string('name');
$table->timestamps();
});
Schema::create('swimming_permissions', function (Blueprint $table) {
$table->string('slug')->unique()->primary();
$table->string('name');
$table->timestamps();
});
Schema::create('first_aid_permissions', function (Blueprint $table) {
$table->string('slug')->unique()->primary();
$table->string('name');
$table->string('description');
$table->timestamps();
});
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('tenant');
$table->string('user_role');
$table->string('username')->unique();
$table->string('password')->nullable();
$table->string('firstname');
$table->string('nickname')->nullable();
$table->string('lastname');
$table->foreignId('local_group_id')->references('id')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate();
$table->string('membership_id')->nullable();
$table->string('address_1')->nullable();
$table->string('address_2')->nullable();
$table->string('postcode')->nullable();
$table->string('city')->nullable();
$table->string('email')->nullable();
$table->string('phone')->nullable();
$table->date('birthday')->nullable();
$table->string('medications')->nullable();
$table->string('allergies')->nullable();
$table->string('intolerances')->nullable();
$table->string('eating_habits')->nullable();
$table->string('swimming_permission')->nullable();
$table->string('first_aid_permission')->nullable();
$table->string('bank_account_iban')->nullable();
$table->string('activation_token')->nullable();
$table->boolean('activated')->default(false);
$table->foreign('tenant')->references('slug')->on('tenants')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreign('user_role')->references('slug')->on('user_roles')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreign('swimming_permission')->references('slug')->on('swimming_permissions')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreign('eating_habits')->references('slug')->on('eating_habits')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreign('first_aid_permission')->references('slug')->on('first_aid_permissions')->cascadeOnDelete()->cascadeOnUpdate();
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
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->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
Schema::dropIfExists('user_roles');
Schema::dropIfExists('eating_habits');
Schema::dropIfExists('swimming_permissions');
Schema::dropIfExists('first_aid_permissions');
}
};