mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 03:32:15 +01:00
Migrated endpoints from user to member; Renamed membership to member
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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
|
||||
{
|
||||
Schema::table('project_members', function (Blueprint $table): void {
|
||||
$table->foreignUuid('member_id')
|
||||
->nullable()
|
||||
->constrained('organization_user')
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
});
|
||||
DB::statement('
|
||||
update project_members
|
||||
set member_id = organization_user.id
|
||||
from projects
|
||||
join organization_user on organization_user.organization_id = projects.organization_id
|
||||
where projects.id = project_members.project_id and project_members.user_id = organization_user.user_id
|
||||
');
|
||||
Schema::table('project_members', function (Blueprint $table): void {
|
||||
$table->uuid('member_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('project_members', function (Blueprint $table): void {
|
||||
$table->dropForeign(['member_id']);
|
||||
$table->dropColumn('member_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Schema::table('time_entries', function (Blueprint $table): void {
|
||||
$table->foreignUuid('member_id')
|
||||
->nullable()
|
||||
->constrained('organization_user')
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
});
|
||||
DB::statement('
|
||||
update time_entries
|
||||
set member_id = organization_user.id
|
||||
from organization_user
|
||||
where time_entries.organization_id = organization_user.organization_id and
|
||||
time_entries.user_id = organization_user.user_id
|
||||
');
|
||||
Schema::table('time_entries', function (Blueprint $table): void {
|
||||
$table->uuid('member_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('time_entries', function (Blueprint $table): void {
|
||||
$table->dropForeign(['member_id']);
|
||||
$table->dropColumn('member_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::rename('organization_user', 'members');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::rename('members', 'organization_user');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user