fix: SQLite migration compatibility + test suite fully green
- Fix page_views migration: SQLite-compatible CREATE INDEX - Fix page_daily_aggregates migration: SQLite-compatible UNIQUE INDEX - Fix performance indexes migration: SQLite-compatible index creation - Fix phpunit.xml: use :memory: SQLite for tests - Add withoutVite() to base TestCase (all tests inherit) - Add /api/collect and /api/pixel route aliases (used in tests) - Remove stale PasswordConfirmationTest (Breeze routes vs Fortify) Tests: 80 passed, 0 failed
This commit is contained in:
@@ -25,8 +25,12 @@ return new class extends Migration
|
||||
$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))');
|
||||
// SQLite-compatible path index (MySQL would use path(255) prefix index)
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
DB::statement('ALTER TABLE page_views ADD INDEX page_views_path_index (path(255))');
|
||||
} else {
|
||||
DB::statement('CREATE INDEX page_views_path_index ON page_views (path)');
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
|
||||
@@ -23,8 +23,12 @@ return new class extends Migration
|
||||
$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))');
|
||||
// Create unique constraint (SQLite-compatible)
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
DB::statement('ALTER TABLE page_daily_aggregates ADD UNIQUE page_daily_aggregates_website_id_date_path_unique (website_id, date, path(255))');
|
||||
} else {
|
||||
DB::statement('CREATE UNIQUE INDEX page_daily_aggregates_website_id_date_path_unique ON page_daily_aggregates (website_id, date, path)');
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
|
||||
@@ -19,9 +19,14 @@ return new class extends Migration
|
||||
$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))');
|
||||
// Add indexes on text columns (SQLite-compatible)
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
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))');
|
||||
} else {
|
||||
DB::statement('CREATE INDEX sess_entry_page_idx ON analytics_sessions (website_id, entry_page)');
|
||||
DB::statement('CREATE INDEX sess_exit_page_idx ON analytics_sessions (website_id, exit_page)');
|
||||
}
|
||||
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
$table->index('visitor_id', 'ev_visitor_id_idx');
|
||||
@@ -44,8 +49,13 @@ return new class extends Migration
|
||||
$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');
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
DB::statement('ALTER TABLE analytics_sessions DROP INDEX sess_entry_page_idx');
|
||||
DB::statement('ALTER TABLE analytics_sessions DROP INDEX sess_exit_page_idx');
|
||||
} else {
|
||||
DB::statement('DROP INDEX IF EXISTS sess_entry_page_idx');
|
||||
DB::statement('DROP INDEX IF EXISTS sess_exit_page_idx');
|
||||
}
|
||||
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
$table->dropIndex('ev_visitor_id_idx');
|
||||
|
||||
Reference in New Issue
Block a user