Rename sessions to _sessions, drop legacy migrations table
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3633,6 +3633,8 @@ class Manifest
|
||||
// Commands that should skip code quality checks
|
||||
$migration_commands = [
|
||||
'migrate',
|
||||
'migrate:begin',
|
||||
'migrate:commit',
|
||||
'migrate:fresh',
|
||||
'migrate:install',
|
||||
'migrate:refresh',
|
||||
@@ -3652,26 +3654,21 @@ class Manifest
|
||||
/**
|
||||
* Verify database has been provisioned before running code quality checks
|
||||
*
|
||||
* Checks that required framework tables (_manifest, _session) exist.
|
||||
* If not, throws a fatal error instructing the user to run migrations.
|
||||
* Checks that:
|
||||
* 1. The _migrations table exists (created by Laravel migrate)
|
||||
* 2. At least one migration has been applied
|
||||
*
|
||||
* This prevents confusing code quality errors when the real issue is
|
||||
* that migrations haven't been run yet.
|
||||
*/
|
||||
protected static function __verify_database_provisioned(): void
|
||||
{
|
||||
$required_tables = ['_manifest', '_session'];
|
||||
$missing_tables = [];
|
||||
$migrations_table = config('database.migrations', 'migrations');
|
||||
|
||||
foreach ($required_tables as $table) {
|
||||
if (!\Illuminate\Support\Facades\Schema::hasTable($table)) {
|
||||
$missing_tables[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missing_tables)) {
|
||||
$tables_list = implode(', ', $missing_tables);
|
||||
// Check if migrations table exists
|
||||
if (!\Illuminate\Support\Facades\Schema::hasTable($migrations_table)) {
|
||||
throw new \RuntimeException(
|
||||
"Database not provisioned - required tables missing: {$tables_list}\n\n" .
|
||||
"Database not provisioned - migrations table '{$migrations_table}' does not exist.\n\n" .
|
||||
"Run migrations before continuing:\n" .
|
||||
" php artisan migrate\n\n" .
|
||||
"If this is a fresh installation, you may also need to:\n" .
|
||||
@@ -3680,6 +3677,16 @@ class Manifest
|
||||
" 3. Run: php artisan migrate"
|
||||
);
|
||||
}
|
||||
|
||||
// Check if at least one migration has been applied
|
||||
$result = \Illuminate\Support\Facades\DB::select("SELECT COUNT(*) as cnt FROM `{$migrations_table}`");
|
||||
if ($result[0]->cnt === 0) {
|
||||
throw new \RuntimeException(
|
||||
"Database not provisioned - no migrations have been applied.\n\n" .
|
||||
"Run migrations before continuing:\n" .
|
||||
" php artisan migrate"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,7 +101,7 @@ class Session extends Rsx_System_Model_Abstract
|
||||
* The table associated with the model
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sessions';
|
||||
protected $table = '_sessions';
|
||||
|
||||
/**
|
||||
* The attributes that should be cast
|
||||
|
||||
@@ -36,7 +36,7 @@ class Session_Cleanup_Service extends Rsx_Service_Abstract
|
||||
{
|
||||
// Logged-in sessions: older than 365 days
|
||||
$logged_in_cutoff = now()->subDays(365);
|
||||
$logged_in_deleted = DB::table('sessions')
|
||||
$logged_in_deleted = DB::table('_sessions')
|
||||
->whereNotNull('login_user_id')
|
||||
->where('last_active', '<', $logged_in_cutoff)
|
||||
->delete();
|
||||
@@ -45,7 +45,7 @@ class Session_Cleanup_Service extends Rsx_Service_Abstract
|
||||
|
||||
// Anonymous sessions: older than 14 days
|
||||
$anonymous_cutoff = now()->subDays(14);
|
||||
$anonymous_deleted = DB::table('sessions')
|
||||
$anonymous_deleted = DB::table('_sessions')
|
||||
->whereNull('login_user_id')
|
||||
->where('last_active', '<', $anonymous_cutoff)
|
||||
->delete();
|
||||
|
||||
Reference in New Issue
Block a user