Add laravel pulse to track site data

This commit is contained in:
DariusIII
2023-12-08 19:27:03 +01:00
parent f5f0e76120
commit 9b0b0c861e
6 changed files with 669 additions and 104 deletions
+5
View File
@@ -2,7 +2,9 @@
namespace App\Providers;
use App\Models\User;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@@ -15,6 +17,9 @@ class AppServiceProvider extends ServiceProvider
Paginator::useBootstrapFive();
$smarty = app('smarty.view');
view()->share('smarty', $smarty);
Gate::define('viewPulse', function (User $user) {
return $user->hasRole('Admin');
});
}
/**
+2 -1
View File
@@ -73,6 +73,7 @@
"kevinlebrun/colors.php": "^1.0",
"laravel/framework": "^10.32",
"laravel/horizon": "^5.21",
"laravel/pulse": "^1.0@beta",
"laravel/sanctum": "^3.3",
"laravel/scout": "^9.0",
"laravel/telescope": "^4.17",
@@ -126,11 +127,11 @@
"ergebnis/composer-normalize": "^2.30",
"friendsofphp/php-cs-fixer": "^3.38",
"jubeki/laravel-code-style": "^2.0",
"larastan/larastan": "^2.7",
"laravel/pint": "^1.6",
"laravel/sail": "^1.21",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.6",
"php-coveralls/php-coveralls": "^2.0",
"phpunit/phpunit": "^10.0",
"rector/rector": "^0.18.0"
Generated
+314 -103
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "05c927a3a635d1fa6e4ef1cc4b016dbb",
"content-hash": "c39ce73b3e28c76524fdad2bc55016a4",
"packages": [
{
"name": "aharen/omdbapi",
@@ -1867,6 +1867,58 @@
],
"time": "2022-12-15T16:57:16+00:00"
},
{
"name": "doctrine/sql-formatter",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/sql-formatter.git",
"reference": "25a06c7bf4c6b8218f47928654252863ffc890a5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/sql-formatter/zipball/25a06c7bf4c6b8218f47928654252863ffc890a5",
"reference": "25a06c7bf4c6b8218f47928654252863ffc890a5",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4"
},
"bin": [
"bin/sql-formatter"
],
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\SqlFormatter\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeremy Dorn",
"email": "jeremy@jeremydorn.com",
"homepage": "https://jeremydorn.com/"
}
],
"description": "a PHP SQL highlighting library",
"homepage": "https://github.com/doctrine/sql-formatter/",
"keywords": [
"highlight",
"sql"
],
"support": {
"issues": "https://github.com/doctrine/sql-formatter/issues",
"source": "https://github.com/doctrine/sql-formatter/tree/1.1.3"
},
"time": "2022-05-23T21:33:49+00:00"
},
{
"name": "dragonmantank/cron-expression",
"version": "v3.3.3",
@@ -4051,6 +4103,91 @@
},
"time": "2023-10-27T13:53:59+00:00"
},
{
"name": "laravel/pulse",
"version": "v1.0.0-beta5",
"source": {
"type": "git",
"url": "https://github.com/laravel/pulse.git",
"reference": "27055078f4cf3ad771e4fa23ec6da50a170c5d1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pulse/zipball/27055078f4cf3ad771e4fa23ec6da50a170c5d1d",
"reference": "27055078f4cf3ad771e4fa23ec6da50a170c5d1d",
"shasum": ""
},
"require": {
"doctrine/sql-formatter": "^1.1",
"guzzlehttp/promises": "^1.0 || ^2.0",
"illuminate/auth": "^10.21",
"illuminate/cache": "^10.21",
"illuminate/config": "^10.21",
"illuminate/console": "^10.21",
"illuminate/contracts": "^10.21",
"illuminate/database": "^10.21",
"illuminate/events": "^10.21",
"illuminate/http": "^10.21",
"illuminate/queue": "^10.21",
"illuminate/redis": "^10.21",
"illuminate/routing": "^10.21",
"illuminate/support": "^10.21",
"illuminate/view": "^10.21",
"livewire/livewire": "^3.02",
"nesbot/carbon": "^2.67",
"php": "^8.1"
},
"conflict": {
"nunomaduro/collision": "<7.7.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.7",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.2",
"phpstan/phpstan": "^1.11",
"predis/predis": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"laravel": {
"providers": [
"Laravel\\Pulse\\PulseServiceProvider"
],
"aliases": {
"Pulse": "Laravel\\Pulse\\Facades\\Pulse"
}
}
},
"autoload": {
"psr-4": {
"Laravel\\Pulse\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"homepage": "https://github.com/laravel/pulse",
"keywords": [
"laravel"
],
"support": {
"issues": "https://github.com/laravel/pulse/issues",
"source": "https://github.com/laravel/pulse"
},
"time": "2023-12-05T22:49:00+00:00"
},
{
"name": "laravel/sanctum",
"version": "v3.3.2",
@@ -5054,6 +5191,80 @@
],
"time": "2023-10-17T14:13:20+00:00"
},
{
"name": "livewire/livewire",
"version": "v3.2.6",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "ecded08cdc4b36bbb4b26bcc7f7a171ea2e4368c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/ecded08cdc4b36bbb4b26bcc7f7a171ea2e4368c",
"reference": "ecded08cdc4b36bbb4b26bcc7f7a171ea2e4368c",
"shasum": ""
},
"require": {
"illuminate/database": "^10.0",
"illuminate/support": "^10.0",
"illuminate/validation": "^10.0",
"league/mime-type-detection": "^1.9",
"php": "^8.1",
"symfony/http-kernel": "^6.2"
},
"require-dev": {
"calebporzio/sushi": "^2.1",
"laravel/framework": "^10.0",
"laravel/prompts": "^0.1.6",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "^8.0",
"orchestra/testbench-dusk": "^8.0",
"phpunit/phpunit": "^9.0",
"psy/psysh": "@stable"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Livewire\\LivewireServiceProvider"
],
"aliases": {
"Livewire": "Livewire\\Livewire"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Livewire\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Caleb Porzio",
"email": "calebporzio@gmail.com"
}
],
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v3.2.6"
},
"funding": [
{
"url": "https://github.com/livewire",
"type": "github"
}
],
"time": "2023-12-04T21:20:19+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "2.4.0",
@@ -15704,6 +15915,107 @@
},
"time": "2023-09-26T02:20:38+00:00"
},
{
"name": "larastan/larastan",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/larastan/larastan.git",
"reference": "a2610d46b9999cf558d9900ccb641962d1442f55"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/larastan/larastan/zipball/a2610d46b9999cf558d9900ccb641962d1442f55",
"reference": "a2610d46b9999cf558d9900ccb641962d1442f55",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/console": "^9.52.16 || ^10.28.0",
"illuminate/container": "^9.52.16 || ^10.28.0",
"illuminate/contracts": "^9.52.16 || ^10.28.0",
"illuminate/database": "^9.52.16 || ^10.28.0",
"illuminate/http": "^9.52.16 || ^10.28.0",
"illuminate/pipeline": "^9.52.16 || ^10.28.0",
"illuminate/support": "^9.52.16 || ^10.28.0",
"php": "^8.0.2",
"phpmyadmin/sql-parser": "^5.8.2",
"phpstan/phpstan": "^1.10.41"
},
"require-dev": {
"nikic/php-parser": "^4.17.1",
"orchestra/canvas": "^7.11.1 || ^8.11.0",
"orchestra/testbench": "^7.33.0 || ^8.13.0",
"phpunit/phpunit": "^9.6.13"
},
"suggest": {
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"autoload": {
"psr-4": {
"Larastan\\Larastan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Can Vural",
"email": "can9119@gmail.com"
},
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
"keywords": [
"PHPStan",
"code analyse",
"code analysis",
"larastan",
"laravel",
"package",
"php",
"static analysis"
],
"support": {
"issues": "https://github.com/larastan/larastan/issues",
"source": "https://github.com/larastan/larastan/tree/v2.7.0"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/enunomaduro",
"type": "custom"
},
{
"url": "https://github.com/canvural",
"type": "github"
},
{
"url": "https://github.com/nunomaduro",
"type": "github"
},
{
"url": "https://www.patreon.com/nunomaduro",
"type": "patreon"
}
],
"time": "2023-12-04T19:21:38+00:00"
},
{
"name": "laravel/pint",
"version": "v1.13.7",
@@ -16135,108 +16447,6 @@
],
"time": "2023-10-11T15:45:01+00:00"
},
{
"name": "nunomaduro/larastan",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/larastan/larastan.git",
"reference": "a2610d46b9999cf558d9900ccb641962d1442f55"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/larastan/larastan/zipball/a2610d46b9999cf558d9900ccb641962d1442f55",
"reference": "a2610d46b9999cf558d9900ccb641962d1442f55",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/console": "^9.52.16 || ^10.28.0",
"illuminate/container": "^9.52.16 || ^10.28.0",
"illuminate/contracts": "^9.52.16 || ^10.28.0",
"illuminate/database": "^9.52.16 || ^10.28.0",
"illuminate/http": "^9.52.16 || ^10.28.0",
"illuminate/pipeline": "^9.52.16 || ^10.28.0",
"illuminate/support": "^9.52.16 || ^10.28.0",
"php": "^8.0.2",
"phpmyadmin/sql-parser": "^5.8.2",
"phpstan/phpstan": "^1.10.41"
},
"require-dev": {
"nikic/php-parser": "^4.17.1",
"orchestra/canvas": "^7.11.1 || ^8.11.0",
"orchestra/testbench": "^7.33.0 || ^8.13.0",
"phpunit/phpunit": "^9.6.13"
},
"suggest": {
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"autoload": {
"psr-4": {
"Larastan\\Larastan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Can Vural",
"email": "can9119@gmail.com"
},
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
"keywords": [
"PHPStan",
"code analyse",
"code analysis",
"larastan",
"laravel",
"package",
"php",
"static analysis"
],
"support": {
"issues": "https://github.com/larastan/larastan/issues",
"source": "https://github.com/larastan/larastan/tree/v2.7.0"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/enunomaduro",
"type": "custom"
},
{
"url": "https://github.com/canvural",
"type": "github"
},
{
"url": "https://github.com/nunomaduro",
"type": "github"
},
{
"url": "https://www.patreon.com/nunomaduro",
"type": "patreon"
}
],
"abandoned": "larastan/larastan",
"time": "2023-12-04T19:21:38+00:00"
},
{
"name": "phar-io/manifest",
"version": "2.0.3",
@@ -18492,6 +18702,7 @@
"anhskohbo/no-captcha": 20,
"b3rs3rk/steamfront": 20,
"joshpinkney/tv-maze-php-api": 20,
"laravel/pulse": 10,
"revlenuwe/gearer": 20
},
"prefer-stable": true,
+227
View File
@@ -0,0 +1,227 @@
<?php
use Laravel\Pulse\Http\Middleware\Authorize;
use Laravel\Pulse\Recorders;
return [
/*
|--------------------------------------------------------------------------
| Pulse Domain
|--------------------------------------------------------------------------
|
| This is the subdomain which the Pulse dashboard will be accessible from.
| When set to null, the dashboard will reside under the same domain as
| the application. Remember to configure your DNS entries correctly.
|
*/
'domain' => env('PULSE_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Pulse Path
|--------------------------------------------------------------------------
|
| This is the path which the Pulse dashboard will be accessible from. Feel
| free to change this path to anything you'd like. Note that this won't
| affect the path of the internal API that is never exposed to users.
|
*/
'path' => env('PULSE_PATH', 'pulse'),
/*
|--------------------------------------------------------------------------
| Pulse Master Switch
|--------------------------------------------------------------------------
|
| This configuration option may be used to completely disable all Pulse
| data recorders regardless of their individual configurations. This
| provides a single option to quickly disable all Pulse recording.
|
*/
'enabled' => env('PULSE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Pulse Storage Driver
|--------------------------------------------------------------------------
|
| This configuration option determines which storage driver will be used
| while storing entries from Pulse's recorders. In addition, you also
| may provide any options to configure the selected storage driver.
|
*/
'storage' => [
'driver' => env('PULSE_STORAGE_DRIVER', 'database'),
'database' => [
'connection' => env('PULSE_DB_CONNECTION', null),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Pulse Ingest Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the ingest driver that will be used
| to capture entries from Pulse's recorders. Ingest drivers are great to
| free up your request workers quickly by offloading the data storage.
|
*/
'ingest' => [
'driver' => env('PULSE_INGEST_DRIVER', 'storage'),
'trim_lottery' => [1, 1_000],
'redis' => [
'connection' => env('PULSE_REDIS_CONNECTION'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Pulse Cache Driver
|--------------------------------------------------------------------------
|
| This configuration option determines the cache driver that will be used
| for various tasks, including caching dashboard results, establishing
| locks for events that should only occur on one server and signals.
|
*/
'cache' => env('PULSE_CACHE_DRIVER'),
/*
|--------------------------------------------------------------------------
| Pulse Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Pulse route, giving you the
| chance to add your own middleware to this list or change any of the
| existing middleware. Of course, reasonable defaults are provided.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Pulse Recorders
|--------------------------------------------------------------------------
|
| The following array lists the "recorders" that will be registered with
| Pulse, along with their configuration. Recorders gather application
| event data from requests and tasks to pass to your ingest driver.
|
*/
'recorders' => [
Recorders\CacheInteractions::class => [
'enabled' => env('PULSE_CACHE_INTERACTIONS_ENABLED', true),
'sample_rate' => env('PULSE_CACHE_INTERACTIONS_SAMPLE_RATE', 1),
'ignore' => [
'/^laravel:pulse:/', // Internal Pulse keys...
'/^illuminate:/', // Internal Laravel keys...
'/^telescope:/', // Internal Telescope keys...
'/^nova/', // Internal Nova keys...
'/^.+@.+\|(?:(?:\d+\.\d+\.\d+\.\d+)|[0-9a-fA-F:]+)(?::timer)?$/', // Breeze / Jetstream authentication rate limiting...
'/^[a-zA-Z0-9]{40}$/', // Session IDs...
],
'groups' => [
'/^job-exceptions:.*/' => 'job-exceptions:*',
// '/:\d+/' => ':*',
],
],
Recorders\Exceptions::class => [
'enabled' => env('PULSE_EXCEPTIONS_ENABLED', true),
'sample_rate' => env('PULSE_EXCEPTIONS_SAMPLE_RATE', 1),
'location' => env('PULSE_EXCEPTIONS_LOCATION', true),
'ignore' => [
// '/^Package\\\\Exceptions\\\\/',
],
],
Recorders\Queues::class => [
'enabled' => env('PULSE_QUEUES_ENABLED', true),
'sample_rate' => env('PULSE_QUEUES_SAMPLE_RATE', 1),
'ignore' => [
// '/^Package\\\\Jobs\\\\/',
],
],
Recorders\Servers::class => [
'server_name' => env('PULSE_SERVER_NAME', gethostname()),
'directories' => explode(':', env('PULSE_SERVER_DIRECTORIES', '/')),
],
Recorders\SlowJobs::class => [
'enabled' => env('PULSE_SLOW_JOBS_ENABLED', true),
'sample_rate' => env('PULSE_SLOW_JOBS_SAMPLE_RATE', 1),
'threshold' => env('PULSE_SLOW_JOBS_THRESHOLD', 1000),
'ignore' => [
// '/^Package\\\\Jobs\\\\/',
],
],
Recorders\SlowOutgoingRequests::class => [
'enabled' => env('PULSE_SLOW_OUTGOING_REQUESTS_ENABLED', true),
'sample_rate' => env('PULSE_SLOW_OUTGOING_REQUESTS_SAMPLE_RATE', 1),
'threshold' => env('PULSE_SLOW_OUTGOING_REQUESTS_THRESHOLD', 1000),
'ignore' => [
// '#^http://127\.0\.0\.1:13714#', // Inertia SSR...
],
'groups' => [
// '#^https://api\.github\.com/repos/.*$#' => 'api.github.com/repos/*',
// '#^https?://([^/]*).*$#' => '\1',
// '#/\d+#' => '/*',
],
],
Recorders\SlowQueries::class => [
'enabled' => env('PULSE_SLOW_QUERIES_ENABLED', true),
'sample_rate' => env('PULSE_SLOW_QUERIES_SAMPLE_RATE', 1),
'threshold' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000),
'location' => env('PULSE_SLOW_QUERIES_LOCATION', true),
'ignore' => [
'/(["`])pulse_[\w]+?\1/', // Pulse tables...
],
],
Recorders\SlowRequests::class => [
'enabled' => env('PULSE_SLOW_REQUESTS_ENABLED', true),
'sample_rate' => env('PULSE_SLOW_REQUESTS_SAMPLE_RATE', 1),
'threshold' => env('PULSE_SLOW_REQUESTS_THRESHOLD', 1000),
'ignore' => [
'#^/pulse$#', // Pulse dashboard...
],
],
Recorders\UserJobs::class => [
'enabled' => env('PULSE_USER_JOBS_ENABLED', true),
'sample_rate' => env('PULSE_USER_JOBS_SAMPLE_RATE', 1),
'ignore' => [
// '/^Package\\\\Jobs\\\\/',
],
],
Recorders\UserRequests::class => [
'enabled' => env('PULSE_USER_REQUESTS_ENABLED', true),
'sample_rate' => env('PULSE_USER_REQUESTS_SAMPLE_RATE', 1),
'ignore' => [
'#^/pulse$#', // Pulse dashboard...
],
],
],
];
@@ -0,0 +1,92 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return Config::get('pulse.storage.database.connection');
}
/**
* Run the migrations.
*/
public function up(): void
{
$connection = DB::connection($this->getConnection());
Schema::create('pulse_values', function (Blueprint $table) use ($connection) {
$table->id();
$table->unsignedInteger('timestamp');
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
$table->text('value');
$table->index('timestamp'); // For trimming...
$table->index('type'); // For fast lookups and purging...
$table->unique(['type', 'key_hash']); // For data integrity and upserts...
});
Schema::create('pulse_entries', function (Blueprint $table) use ($connection) {
$table->id();
$table->unsignedInteger('timestamp');
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
$table->bigInteger('value')->nullable();
$table->index('timestamp'); // For trimming...
$table->index('type'); // For purging...
$table->index('key_hash'); // For mapping...
$table->index(['timestamp', 'type', 'key_hash', 'value']); // For aggregate queries...
});
Schema::create('pulse_aggregates', function (Blueprint $table) use ($connection) {
$table->id();
$table->unsignedInteger('bucket');
$table->unsignedMediumInteger('period');
$table->string('type');
$table->text('key');
match ($driver = $connection->getDriverName()) {
'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'),
'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'),
default => throw new RuntimeException("Unsupported database driver [{$driver}]."),
};
$table->string('aggregate');
$table->decimal('value', 20, 2);
$table->unsignedInteger('count')->nullable();
$table->unique(['bucket', 'period', 'type', 'aggregate', 'key_hash']); // Force "on duplicate update"...
$table->index(['period', 'bucket']); // For trimming...
$table->index('type'); // For purging...
$table->index(['period', 'type', 'aggregate', 'bucket']); // For aggregate queries...
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pulse_values');
Schema::dropIfExists('pulse_entries');
Schema::dropIfExists('pulse_aggregates');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name')->nullable()->after('username');
});
\App\Models\User::query()->update(['name' => \DB::raw('username')]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['name']);
});
}
};