phase 8 and 9

This commit is contained in:
Stefanescu Mihai
2026-03-19 18:42:19 +02:00
parent d75cabfeec
commit 82ebb697f3
94 changed files with 4498 additions and 749 deletions
@@ -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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -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
{
public function up(): void
{
Schema::create('funnels', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->json('steps'); // [{type: "pageview"|"event", value: "/checkout", label: "Checkout Page"}, ...]
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('funnels');
}
};
@@ -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::create('segments', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->json('filters'); // [{field: "country", operator: "=", value: "DE"}, {field: "device_type", operator: "=", value: "mobile"}]
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('segments');
}
};
@@ -0,0 +1,27 @@
<?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('dashboard_widgets', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->string('title');
$table->string('widget_type'); // metric, chart, top_pages, top_sources, events, conversions
$table->json('config')->nullable(); // {metric: "page_views", chart_type: "line", limit: 5, ...}
$table->unsignedSmallInteger('sort_order')->default(0);
$table->string('size', 10)->default('half'); // full, half, third
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('dashboard_widgets');
}
};
@@ -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
{
public function up(): void
{
Schema::create('alerts', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('metric'); // page_views, visitors, sessions, bounce_rate, goal_conversions
$table->string('condition'); // above, below, change_up, change_down
$table->decimal('threshold', 12, 2);
$table->string('period')->default('daily'); // daily, hourly
$table->string('channel')->default('email'); // email, in_app, both
$table->boolean('is_active')->default(true);
$table->timestamp('last_triggered_at')->nullable();
$table->timestamps();
});
Schema::create('alert_notifications', function (Blueprint $table) {
$table->id();
$table->foreignId('alert_id')->constrained()->cascadeOnDelete();
$table->decimal('value', 12, 2);
$table->text('message');
$table->boolean('is_read')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('alert_notifications');
Schema::dropIfExists('alerts');
}
};
@@ -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
{
public function up(): void
{
Schema::create('annotations', function (Blueprint $table) {
$table->id();
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->date('date');
$table->string('text');
$table->string('category')->default('general'); // general, deployment, campaign, incident
$table->timestamps();
$table->index(['website_id', 'date']);
});
}
public function down(): void
{
Schema::dropIfExists('annotations');
}
};