fix: Add last_login column to users table

- Create migration AddLastLoginToUsers to add last_login column
- Revert UserModel to use last_login column in queries
- Proper solution: add missing column instead of removing from code
This commit is contained in:
1sonhador committed 2025-10-15 14:27:23 +01:00
1 parent 57f9a715c2
commit 4656a0877b
2 files changed
+28 -2

No files matched your search

@@ -0,0 +1,24 @@
<?php
namespace App\Core\Database\Migrations;
use App\Core\Database\Migration;
class AddLastLoginToUsers extends Migration
{
public function up(): void
{
// Adicionar coluna last_login
$this->addColumn('users', 'last_login', function($table) {
$table->timestamp('last_login')->nullable();
});
// Criar índice para performance
$this->addIndex('users', 'idx_last_login', ['last_login']);
}
public function down(): void
{
$this->dropIndex('users', 'idx_last_login');
$this->dropColumn('users', 'last_login');
}
}
+4 -2
View File
@@ -284,7 +284,8 @@ class UserModel
u.role,
u.is_active,
u.created_at,
u.updated_at
u.updated_at,
u.last_login
FROM users u
WHERE u.id > 0";
@@ -373,7 +374,8 @@ class UserModel
u.role,
u.is_active,
u.created_at,
u.updated_at
u.updated_at,
u.last_login
FROM users u
WHERE u.id = ?";