update profile db
This commit is contained in:
parent
eb784514a0
commit
5f9eadae19
BIN
assets/images/users/9869519f5f02861e6471bb2219173462.webp
Normal file
BIN
assets/images/users/9869519f5f02861e6471bb2219173462.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@ -7,6 +7,23 @@ if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
|
||||
// Auto-migrate newly added columns
|
||||
try {
|
||||
$flagFile = sys_get_temp_dir() . '/.migrated_avatar_col_' . md5(__DIR__);
|
||||
if (!file_exists($flagFile)) {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SHOW COLUMNS FROM users LIKE 'avatar'");
|
||||
if ($stmt->rowCount() === 0) {
|
||||
$pdo->exec("ALTER TABLE users ADD COLUMN avatar varchar(255) DEFAULT NULL");
|
||||
}
|
||||
$stmt2 = $pdo->query("SHOW COLUMNS FROM branches LIKE 'avatar'");
|
||||
if ($stmt2->rowCount() === 0) {
|
||||
$pdo->exec("ALTER TABLE branches ADD COLUMN avatar varchar(255) DEFAULT NULL");
|
||||
}
|
||||
@file_put_contents($flagFile, '1');
|
||||
}
|
||||
} catch (\Throwable $e) {}
|
||||
|
||||
|
||||
|
||||
function get_settings(): array
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
try {
|
||||
$pdo = db();
|
||||
$pdo->exec("ALTER TABLE `users` ADD COLUMN `avatar` varchar(255) DEFAULT NULL;");
|
||||
echo "Added avatar\n";
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user