first commit
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,33 @@
|
||||
<?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_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']);
|
||||
$table->index('path');
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user