-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration_add_reset_token.php
More file actions
38 lines (33 loc) · 1.13 KB
/
migration_add_reset_token.php
File metadata and controls
38 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// migration_add_reset_token.php
require_once __DIR__ . '/config/db_control.php';
try {
$pdo = getControlDB();
echo "Connected to database.\n";
// Add reset_token_hash column
try {
$pdo->exec("ALTER TABLE users ADD COLUMN reset_token_hash VARCHAR(64) NULL AFTER status");
echo "Added reset_token_hash column.\n";
} catch (PDOException $e) {
if (strpos($e->getMessage(), 'Duplicate column') !== false) {
echo "Column reset_token_hash already exists.\n";
} else {
throw $e;
}
}
// Add reset_token_expires_at column
try {
$pdo->exec("ALTER TABLE users ADD COLUMN reset_token_expires_at DATETIME NULL AFTER reset_token_hash");
echo "Added reset_token_expires_at column.\n";
} catch (PDOException $e) {
if (strpos($e->getMessage(), 'Duplicate column') !== false) {
echo "Column reset_token_expires_at already exists.\n";
} else {
throw $e;
}
}
echo "Migration completed successfully.\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}