first commit from hostslim
This commit is contained in:
@@ -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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$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');
|
||||
}
|
||||
};
|
||||
@@ -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.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
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.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -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(): void
|
||||
{
|
||||
Schema::create('websites', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('domain');
|
||||
$table->string('tracking_id')->unique();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->json('settings')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('domain');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('websites');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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('visitors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('uid', 64)->index();
|
||||
$table->timestamp('first_seen_at');
|
||||
$table->timestamp('last_seen_at');
|
||||
$table->string('device_type', 20)->nullable();
|
||||
$table->string('browser', 50)->nullable();
|
||||
$table->string('browser_version', 20)->nullable();
|
||||
$table->string('os', 50)->nullable();
|
||||
$table->string('os_version', 20)->nullable();
|
||||
$table->string('screen_resolution', 20)->nullable();
|
||||
$table->string('language', 10)->nullable();
|
||||
$table->string('country', 2)->nullable();
|
||||
$table->string('region', 100)->nullable();
|
||||
$table->string('city', 100)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['website_id', 'uid']);
|
||||
$table->index('country');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('visitors');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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('analytics_sessions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('visitor_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('uid', 64)->unique();
|
||||
$table->timestamp('started_at');
|
||||
$table->timestamp('ended_at')->nullable();
|
||||
$table->unsignedInteger('duration')->default(0);
|
||||
$table->boolean('is_bounce')->default(true);
|
||||
$table->text('entry_page')->nullable();
|
||||
$table->text('exit_page')->nullable();
|
||||
$table->unsignedSmallInteger('pages_count')->default(0);
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->string('referrer_url')->nullable();
|
||||
$table->string('referrer_domain', 255)->nullable();
|
||||
$table->string('utm_source', 255)->nullable();
|
||||
$table->string('utm_medium', 255)->nullable();
|
||||
$table->string('utm_campaign', 255)->nullable();
|
||||
$table->string('utm_term', 255)->nullable();
|
||||
$table->string('utm_content', 255)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'started_at']);
|
||||
$table->index('referrer_domain');
|
||||
$table->index('utm_source');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('analytics_sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('page_views', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('visitor_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('analytics_session_id')->constrained()->cascadeOnDelete();
|
||||
$table->text('url');
|
||||
$table->string('path', 2048);
|
||||
$table->string('title', 512)->nullable();
|
||||
$table->string('referrer', 2048)->nullable();
|
||||
$table->unsignedInteger('time_on_page')->nullable();
|
||||
$table->timestamp('viewed_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'viewed_at']);
|
||||
});
|
||||
|
||||
// Index only the first 255 characters of path to avoid key length issues
|
||||
DB::statement('ALTER TABLE page_views ADD INDEX page_views_path_index (path(255))');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('page_views');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('visitor_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('analytics_session_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('category')->nullable();
|
||||
$table->string('action')->nullable();
|
||||
$table->string('label')->nullable();
|
||||
$table->decimal('value', 15, 4)->nullable();
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamp('occurred_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'name', 'occurred_at']);
|
||||
$table->index(['website_id', 'occurred_at']);
|
||||
$table->index('category');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
};
|
||||
@@ -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(): void
|
||||
{
|
||||
Schema::create('goals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('type', 30);
|
||||
$table->json('conditions');
|
||||
$table->decimal('default_value', 15, 4)->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'is_active']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('goals');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('goal_conversions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('goal_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('visitor_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('analytics_session_id')->constrained()->cascadeOnDelete();
|
||||
$table->decimal('value', 15, 4)->nullable();
|
||||
$table->timestamp('converted_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'converted_at']);
|
||||
$table->index(['goal_id', 'converted_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('goal_conversions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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->text('two_factor_secret')
|
||||
->after('password')
|
||||
->nullable();
|
||||
|
||||
$table->text('two_factor_recovery_codes')
|
||||
->after('two_factor_secret')
|
||||
->nullable();
|
||||
|
||||
$table->timestamp('two_factor_confirmed_at')
|
||||
->after('two_factor_recovery_codes')
|
||||
->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_confirmed_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('daily_aggregates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->date('date');
|
||||
$table->unsignedInteger('visitors')->default(0);
|
||||
$table->unsignedInteger('sessions')->default(0);
|
||||
$table->unsignedInteger('page_views')->default(0);
|
||||
$table->unsignedInteger('bounce_count')->default(0);
|
||||
$table->unsignedBigInteger('total_duration')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['website_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('daily_aggregates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('page_daily_aggregates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('website_id')->constrained()->cascadeOnDelete();
|
||||
$table->date('date');
|
||||
$table->string('path', 2048);
|
||||
$table->unsignedInteger('views')->default(0);
|
||||
$table->unsignedInteger('unique_views')->default(0);
|
||||
$table->unsignedBigInteger('total_time_on_page')->default(0);
|
||||
$table->unsignedInteger('bounces')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['website_id', 'date']);
|
||||
});
|
||||
|
||||
// Create unique constraint with prefix length on path to avoid key length issues
|
||||
DB::statement('ALTER TABLE page_daily_aggregates ADD UNIQUE page_daily_aggregates_website_id_date_path_unique (website_id, date, path(255))');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('page_daily_aggregates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('page_views', function (Blueprint $table) {
|
||||
$table->index('visitor_id', 'pv_visitor_id_idx');
|
||||
$table->index('analytics_session_id', 'pv_session_id_idx');
|
||||
});
|
||||
|
||||
Schema::table('analytics_sessions', function (Blueprint $table) {
|
||||
$table->index('visitor_id', 'sess_visitor_id_idx');
|
||||
$table->index(['website_id', 'is_bounce', 'started_at'], 'sess_bounce_lookup_idx');
|
||||
});
|
||||
|
||||
// Add indexes with prefix length on TEXT columns to avoid key length issues
|
||||
DB::statement('ALTER TABLE analytics_sessions ADD INDEX sess_entry_page_idx (website_id, entry_page(255))');
|
||||
DB::statement('ALTER TABLE analytics_sessions ADD INDEX sess_exit_page_idx (website_id, exit_page(255))');
|
||||
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
$table->index('visitor_id', 'ev_visitor_id_idx');
|
||||
});
|
||||
|
||||
Schema::table('goal_conversions', function (Blueprint $table) {
|
||||
$table->index('visitor_id', 'gc_visitor_id_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('page_views', function (Blueprint $table) {
|
||||
$table->dropIndex('pv_visitor_id_idx');
|
||||
$table->dropIndex('pv_session_id_idx');
|
||||
});
|
||||
|
||||
Schema::table('analytics_sessions', function (Blueprint $table) {
|
||||
$table->dropIndex('sess_visitor_id_idx');
|
||||
$table->dropIndex('sess_bounce_lookup_idx');
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE analytics_sessions DROP INDEX sess_entry_page_idx');
|
||||
DB::statement('ALTER TABLE analytics_sessions DROP INDEX sess_exit_page_idx');
|
||||
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
$table->dropIndex('ev_visitor_id_idx');
|
||||
});
|
||||
|
||||
Schema::table('goal_conversions', function (Blueprint $table) {
|
||||
$table->dropIndex('gc_visitor_id_idx');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user