This commit is contained in:
2023-11-14 09:40:05 +10:00
parent c432b32d08
commit 7d9b6793d3
323 changed files with 907 additions and 65589 deletions

View File

@@ -1,31 +0,0 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Event>
*/
class ArticleFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$publishDate = Carbon::parse($this->faker->dateTimeBetween('-1 month', '+1 month'));
return [
'title' => $this->faker->sentence(),
'slug' => $this->faker->slug(),
'publish_at' => $publishDate,
'content' => $this->faker->paragraphs(3, true),
'user_id' => $this->faker->uuid(),
'hero' => $this->faker->uuid(),
];
}
}

View File

@@ -1,40 +0,0 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Event>
*/
class EventFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$startDate = Carbon::parse($this->faker->dateTimeBetween('now', '+1 year'));
$endDate = Carbon::parse($this->faker->dateTimeBetween($startDate, '+1 year'));
$publishDate = Carbon::parse($this->faker->dateTimeBetween('-1 month', '+1 month'));
return [
'title' => $this->faker->sentence(),
'location' => $this->faker->randomElement(['online', 'physical']),
'address' => $this->faker->address(),
'start_at' => $startDate,
'end_at' => $endDate,
'publish_at' => $publishDate,
'status' => $this->faker->randomElement(['draft', 'soon', 'open', 'closed', 'cancelled']),
'registration_type' => $this->faker->randomElement(['none', 'email', 'link', 'message']),
'registration_data' => $this->faker->sentence(),
'hero' => $this->faker->uuid(),
'content' => $this->faker->paragraphs(3, true),
'price' => $this->faker->numberBetween(0, 150),
'ages' => $this->faker->regexify('\d+(\+|\-\d+)?'),
];
}
}

View File

@@ -1,28 +0,0 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Event>
*/
class MediaFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'title' => $this->faker->sentence(),
'name' => storage_path('app/public/') . $this->faker->slug() . '.' . $this->faker->fileExtension(),
'mime_type' => $this->faker->mimeType(),
'user_id' => $this->faker->uuid(),
'size' => $this->faker->numberBetween(1000, 1000000),
];
}
}

View File

@@ -3,6 +3,7 @@
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
@@ -10,6 +11,8 @@ use Illuminate\Support\Str;
*/
class UserFactory extends Factory
{
protected static ?string $password;
/**
* Define the model's default state.
*
@@ -17,23 +20,12 @@ class UserFactory extends Factory
*/
public function definition(): array
{
$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\CustomInternetProvider($faker));
$first_name = $faker->firstName();
$last_name = $faker->lastName();
$display_name = $first_name . ' ' . $last_name;
return [
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $faker->safeEmail(),
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'phone' => $faker->phoneNumber(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'display_name' => $display_name,
];
}

View File

@@ -12,15 +12,11 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('username')->unique();
$table->string('password')->nullable();
$table->boolean('enabled')->default(true);
$table->string('first_name');
$table->string('last_name');
$table->string('email');
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('phone')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});

View File

@@ -1,28 +0,0 @@
<?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('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_resets');
}
};

View File

@@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->uuidMorphs('tokenable');
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();

View File

@@ -1,33 +0,0 @@
<?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('posts', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('slug', 255)->unique();
$table->string('title', 255);
$table->timestamp('publish_at')->nullable()->useCurrent();
$table->uuid('user_id');
$table->uuid('hero');
$table->text('content');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('posts');
}
};

View File

@@ -1,33 +0,0 @@
<?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('media', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('user_id');
$table->string('title');
$table->string('name');
$table->string('mime');
$table->string('permission')->nullable();
$table->bigInteger('size');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('media');
}
};

View File

@@ -1,31 +0,0 @@
<?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('permissions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('permission');
$table->uuid('user_id');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('permissions');
}
};

View File

@@ -1,38 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('title');
$table->string('location');
$table->string('address')->nullable();
$table->timestamp('start_at')->useCurrent();
$table->timestamp('end_at')->useCurrent();
$table->timestamp('publish_at')->useCurrent()->nullable();
$table->string('status')->default('draft');
$table->string('registration_type');
$table->string('registration_data')->nullable();
$table->uuid('hero');
$table->text('content')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('events');
}
};

View File

@@ -1,29 +0,0 @@
<?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('subscriptions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('email');
$table->timestamp('confirmed_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subscriptions');
}
};

View File

@@ -1,32 +0,0 @@
<?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('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.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};

View File

@@ -1,33 +0,0 @@
<?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_codes', function (Blueprint $table) {
$table->id();
$table->char('code', 6)->unique();
$table->string('action');
$table->string('data')->nullable();
$table->uuid('user_id');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_codes');
}
};

View File

@@ -1,43 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->create('audits', function (Blueprint $table) {
$morphPrefix = Config::get('audit.user.morph_prefix', 'user');
$table->bigIncrements('id');
$table->string($morphPrefix . '_type')->nullable();
$table->uuid($morphPrefix . '_id')->nullable();
$table->string('event');
$table->uuidMorphs('auditable');
$table->text('old_values')->nullable();
$table->text('new_values')->nullable();
$table->text('url')->nullable();
$table->ipAddress('ip_address')->nullable();
$table->string('user_agent', 1023)->nullable();
$table->string('tags')->nullable();
$table->timestamps();
$table->index([$morphPrefix . '_id', $morphPrefix . '_type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::connection(config('audit.drivers.database.connection', config('database.default')))->drop('audits');
}
};

View File

@@ -1,35 +0,0 @@
<?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_logins', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('user_id');
$table->string('token');
$table->timestamp('login')->nullable();
$table->timestamp('logout')->nullable();
$table->ipAddress('ip_address')->nullable();
$table->string('user_agent', 1023)->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_logins');
}
};

View File

@@ -1,31 +0,0 @@
<?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('analytics', function (Blueprint $table) {
$table->id();
$table->string('type');
$table->string('attribute');
$table->text('useragent');
$table->string('ip');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('analytics');
}
};

View File

@@ -1,31 +0,0 @@
<?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('attachments', function (Blueprint $table) {
$table->id();
$table->uuid('media_id');
$table->uuidMorphs('attachable');
$table->timestamps();
$table->foreign('media_id')->references('id')->on('media')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('attachments');
}
};

View File

@@ -1,28 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->string('price')->default("");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('price');
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->string('ages')->default("");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('ages');
});
}
};

View File

@@ -1,55 +0,0 @@
<?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
{
DB::table('media')->whereNull('mime')->update(['mime' => '']);
DB::table('media')->whereNull('permission')->update(['permission' => '']);
Schema::table('media', function (Blueprint $table) {
$table->string('storage')->default("cdn");
$table->string('description')->default("");
$table->string('status')->default("");
$table->string('dimensions')->default("");
$table->text('variants');
$table->bigInteger('size')->default(0)->change();
$table->string('permission')->default("")->nullable(false)->change();
$table->string('mime')->default("")->nullable(false)->change();
});
Schema::table('media', function(Blueprint $table) {
$table->renameColumn('mime', 'mime_type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('media', function (Blueprint $table) {
$table->bigInteger('size')->change();
$table->string('mime_type')->nullable(true)->change();
$table->string('permission')->nullable(true)->change();
$table->renameColumn('mime_type', 'mime');
$table->dropColumn('status');
$table->dropColumn('dimensions');
$table->dropColumn('variants');
$table->dropColumn('description');
$table->dropColumn('storage');
});
}
};

View File

@@ -1,31 +0,0 @@
<?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
{
DB::table('users')->whereNull('phone')->update(['phone' => '']);
Schema::table('users', function (Blueprint $table) {
$table->string('phone')->default("")->nullable(false)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('phone')->nullable(true)->change();
});
}
};

View File

@@ -1,36 +0,0 @@
<?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
{
Schema::table('users', function (Blueprint $table) {
$table->string('display_name')->default("");
});
// Update existing rows with display_name
DB::table('users')->select('id', 'username')->orderBy('id')->chunk(100, function ($users) {
foreach ($users as $user) {
DB::table('users')->where('id', $user->id)->update(['display_name' => $user->username]);
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('display_name');
});
}
};

View File

@@ -1,29 +0,0 @@
<?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::dropIfExists('subscriptions');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('email');
$table->timestamp('confirmed_at')->nullable();
$table->timestamps();
});
}
};

View File

@@ -1,31 +0,0 @@
<?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
{
Schema::rename('posts', 'articles');
// Update permissions to use articles instead of posts
DB::table('permissions')->select('id', 'permission')->where('permission', 'admin/posts')->update(['permission' => 'admin/articles']);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::rename('articles', 'posts');
// Update permissions to use posts instead of articles
DB::table('permissions')->select('id', 'permission')->where('permission', 'admin/articles')->update(['permission' => 'admin/posts']);
}
};

View File

@@ -1,72 +0,0 @@
<?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
{
Schema::table('analytics', function (Blueprint $table) {
$table->bigInteger('session')->nullable(false);
$table->string('attribute')->default('')->change();
});
DB::table('analytics')
->where('type', 'pageview')
->update(['type' => 'apirequest']);
// Set first session
$session = 0;
do {
$rows = DB::table('analytics')
->whereNull('session')
->orWhere('session', 0)
->orderBy('created_at', 'asc')
->limit(1)
->get();
if($rows->isEmpty()) {
break;
}
$sessionRow = $rows->first();
DB::table('analytics')->where('id', $sessionRow->id)->update(['session' => ++$session]);
$lastSessionUpdate = $sessionRow->created_at;
do {
$sameSessionRows = DB::table('analytics')
->whereNull('session')
->orWhere('session', 0)
->where('useragent', $sessionRow->useragent)
->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('30 minutes', strtotime($lastSessionUpdate))))
->orderBy('created_at', 'desc')
->get();
if($sameSessionRows->isEmpty()) {
break;
}
$ids = $sameSessionRows->pluck('id')->toArray();
DB::table('analytics')->whereIn('id', $ids)->update(['session' => $session]);
$lastSessionUpdate = $sameSessionRows->first()->created_at;
} while(true);
} while(true);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('analytics', function (Blueprint $table) {
$table->dropColumn('session');
});
}
};

View File

@@ -1,31 +0,0 @@
<?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
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('username');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('username')->unique();
});
DB::table('users')->update(['username' => DB::raw('display_name')]);
}
};

View File

@@ -1,29 +0,0 @@
<?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('shortlinks', function (Blueprint $table) {
$table->id();
$table->string('code', 4)->unique();
$table->string('url');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('shortlinks');
}
};

View File

@@ -1,28 +0,0 @@
<?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('shortlinks', function (Blueprint $table) {
$table->bigInteger('used')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('shortlinks', function (Blueprint $table) {
$table->dropColumn('used');
});
}
};

View File

@@ -1,30 +0,0 @@
<?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->string('first_name')->default('')->change();
$table->string('last_name')->default('')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('first_name')->nullable(false)->change();
$table->string('last_name')->nullable(false)->change();
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->string('location_url')->default('');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('location_url');
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('attachments', function (Blueprint $table) {
$table->boolean('private')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('attachments', function (Blueprint $table) {
$table->dropColumn('private');
});
}
};

View File

@@ -1,32 +0,0 @@
<?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('event_users', function (Blueprint $table) {
$table->id();
$table->uuid('event_id');
$table->uuid('user_id');
$table->timestamps();
$table->foreign('event_id')->references('id')->on('events')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('event_users');
}
};

View File

@@ -1,24 +0,0 @@
<?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::rename('password_resets', 'password_reset_tokens');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::rename('password_reset_tokens', 'password_resets');
}
};

View File

@@ -1,116 +0,0 @@
<?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
{
Schema::create('analytics_sessions', function (Blueprint $table) {
$table->id();
$table->text('useragent');
$table->string('ip');
$table->timestamps();
$table->timestamp('ended_at')->nullable();
});
Schema::create('analytics_requests', function (Blueprint $table) {
$table->id();
$table->bigInteger('session_id')->unsigned();
$table->string('type');
$table->string('path');
$table->timestamps();
$table->foreign('session_id')->references('id')->on('analytics_sessions')->onDelete('cascade');
});
// Migrate old analytics table
$analytics = DB::table('analytics')
->select(
'session',
DB::raw('MAX(useragent) as useragent'),
DB::raw('MAX(ip) as ip'),
DB::raw('MIN(created_at) as created_at'),
DB::raw('MIN(updated_at) as updated_at'))
->groupBy('session')
->get();
foreach ($analytics as $sessionItem) {
$ip = $sessionItem->ip;
$useragent = $sessionItem->useragent;
$session_id = $sessionItem->session;
$created_at = $sessionItem->created_at;
$updated_at = $sessionItem->updated_at;
// Create a new row in analytics_sessions
$new_session_id = DB::table('analytics_sessions')->insertGetId([
'id' => $session_id,
'useragent' => $useragent,
'ip' => $ip,
'created_at' => $created_at,
'updated_at' => $updated_at
]);
$requests = DB::table('analytics')->where('session', $session_id)->select('type', 'attribute', 'created_at', 'updated_at')->get();
$ended_at = $sessionItem->created_at;
foreach($requests as $requestItem) {
if($ended_at < $requestItem->created_at) {
$ended_at = $requestItem->created_at;
}
DB::table('analytics_requests')->insert([
'session_id' => $new_session_id,
'type' => $requestItem->type,
'path' => $requestItem->attribute,
'created_at' => $requestItem->created_at,
'updated_at' => $requestItem->updated_at,
]);
}
DB::table('analytics_sessions')->where('id', $new_session_id)->update(['ended_at' => $ended_at]);
}
Schema::dropIfExists('analytics');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::create('analytics', function (Blueprint $table) {
$table->id();
$table->bigInteger('session')->nullable(false);
$table->string('type');
$table->string('attribute')->default('');
$table->text('useragent');
$table->string('ip');
$table->timestamps();
});
$sessions = DB::table('analytics_sessions')->get();
foreach ($sessions as $session) {
$requests = DB::table('analytics_requests')->where('session_id', $session->id)->get();
foreach($requests as $request) {
DB::table('analytics')->insert([
'session' => $session->id,
'type' => $request->type,
'attribute' => $request->path,
'ip' => $session->ip,
'useragent' => $session->useragent,
'created_at' => $request->created_at,
'updated_at' => $request->updated_at,
]);
}
}
Schema::dropIfExists('analytics_requests');
Schema::dropIfExists('analytics_sessions');
}
};

View File

@@ -1,28 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->timestamp('open_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('open_at');
});
}
};

View File

@@ -1,32 +0,0 @@
<?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('galleries', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('media_id');
$table->uuidMorphs('addendum');
$table->timestamps();
$table->foreign('media_id')->references('id')->on('media')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('galleries');
}
};

View File

@@ -1,36 +0,0 @@
<?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('attachments', function (Blueprint $table) {
$table->renameColumn('attachable_type', 'addendum_type');
});
Schema::table('attachments', function (Blueprint $table) {
$table->renameColumn('attachable_id', 'addendum_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('attachments', function (Blueprint $table) {
$table->renameColumn('addendum_type', 'attachable_type');
});
Schema::table('attachments', function (Blueprint $table) {
$table->renameColumn('addendum_id', 'attachable_id');
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('analytics_sessions', function (Blueprint $table) {
$table->text('useragent')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('analytics_sessions', function (Blueprint $table) {
$table->text('useragent')->change();
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('media', function (Blueprint $table) {
$table->string('thumbnail')->default('');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('media', function (Blueprint $table) {
$table->dropColumn('thumbnail');
});
}
};

View File

@@ -1,36 +0,0 @@
<?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('media_jobs', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->timestamps();
$table->uuid('user_id')->nullable();
$table->uuid('media_id')->nullable(); // Add a foreign key for the media model
$table->string('status');
$table->string('status_text');
$table->text('data');
$table->integer('progress')->default(0); // Add a column for job progress
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('media_id')->references('id')->on('media')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('media_jobs');
}
};

View File

@@ -1,37 +0,0 @@
<?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
{
// Delete rows where the status is not 'OK'
DB::table('media')->where('status', '<>', 'OK')->delete();
// Remove the 'status' column from the 'media' table
Schema::table('media', function (Blueprint $table) {
$table->dropColumn('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Add the 'status' column back with a default value of an empty string
Schema::table('media', function (Blueprint $table) {
$table->string('status')->default('');
});
// Update the 'status' column of all rows to 'OK'
DB::table('media')->update(['status' => 'OK']);
}
};

View File

@@ -1,28 +0,0 @@
<?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('analytics_requests', function (Blueprint $table) {
$table->text('path')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('analytics_requests', function (Blueprint $table) {
$table->string('path')->change();
});
}
};

View File

@@ -1,30 +0,0 @@
<?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('events', function (Blueprint $table) {
$table->text('location_url')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->string('location_url')->change();
});
}
};

View File

@@ -1,28 +0,0 @@
<?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('media_jobs', function (Blueprint $table) {
$table->integer('progress_max')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('media_jobs', function (Blueprint $table) {
$table->dropColumn('progress_max');
});
}
};

View File

@@ -1,44 +0,0 @@
<?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('media', function (Blueprint $table) {
$table->renameColumn('permission', 'security_data');
});
Schema::table('media', function (Blueprint $table) {
$table->string('security_type')->default("");
});
DB::table('media')
->where('security_data', '!=', '')
->update(['security_type' => 'permission']);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('media')
->where('security_type', '!=', 'permission')
->update(['security_data' => '']);
Schema::table('media', function (Blueprint $table) {
$table->renameColumn('security_data', 'permission');
});
Schema::table('media', function (Blueprint $table) {
$table->dropColumn('security_type');
});
}
};

View File

@@ -3,10 +3,7 @@
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
@@ -15,16 +12,11 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
\App\Models\User::factory(40)->create();
// \App\Models\User::factory(10)->create();
\App\Models\User::factory()->create([
'display_name' => 'James Collins',
'first_name' => 'James',
'last_name' => 'Collins',
'email' => 'james@stemmechanics.com.au',
'email_verified_at' => Carbon::now(),
'phone' => '0400 130 190',
'password' => Hash::make('password@12')
]);
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
}
}