phase 6
This commit is contained in:
@@ -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,31 @@
|
||||
<?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('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->unique(['website_id', 'date', 'path']);
|
||||
$table->index(['website_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('page_daily_aggregates');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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::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');
|
||||
$table->index(['website_id', 'entry_page'], 'sess_entry_page_idx');
|
||||
$table->index(['website_id', 'exit_page'], 'sess_exit_page_idx');
|
||||
});
|
||||
|
||||
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');
|
||||
$table->dropIndex('sess_entry_page_idx');
|
||||
$table->dropIndex('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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user