-- ------------------------------------------
-- Friendica 2023.09-dev (Giant Rhubarb)
--- DB_UPDATE_VERSION 1524
+-- DB_UPDATE_VERSION 1525
-- ------------------------------------------
`profile-name` varchar(255) COMMENT 'Deprecated',
`is-default` boolean COMMENT 'Deprecated',
`hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
- `name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
+ `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Unused in favor of user.username',
`pdesc` varchar(255) COMMENT 'Deprecated',
`dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
| profile-name | Deprecated | varchar(255) | YES | | NULL | |
| is-default | Deprecated | boolean | YES | | NULL | |
| hide-friends | Hide friend list from viewers of this profile | boolean | NO | | 0 | |
-| name | | varchar(255) | NO | | | |
+| name | Unused in favor of user.username | varchar(255) | NO | | | |
| pdesc | Deprecated | varchar(255) | YES | | NULL | |
| dob | Day of birth | varchar(32) | NO | | 0000-00-00 | |
| address | | varchar(255) | NO | | | |
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1524);
+ define('DB_UPDATE_VERSION', 1525);
}
return [
"profile-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
"is-default" => ["type" => "boolean", "comment" => "Deprecated"],
"hide-friends" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide friend list from viewers of this profile"],
- "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Unused in favor of user.username"],
"pdesc" => ["type" => "varchar(255)", "comment" => "Deprecated"],
"dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
"address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
return Update::SUCCESS;
}
+
+function update_1525(): int
+{
+ // Use expected value for user.username
+ if (!DBA::e('UPDATE `user` u
+ JOIN `profile` p
+ ON p.`uid` = u.`uid`
+ SET u.`username` = p.`name`')) {
+ return Update::FAILED;
+ }
+
+ // Blank out deprecated field profile.name to avoid future confusion
+ if (!DBA::e('UPDATE `profile` p
+ SET p.`name` = ""')) {
+ return Update::FAILED;
+ }
+
+ // Update users' self-contact name if needed
+ if (!DBA::e('UPDATE `contact` c
+ JOIN `user` u
+ ON u.`uid` = c.`uid` AND c.`self` = 1
+ SET c.`name` = u.`username`')) {
+ return Update::FAILED;
+ }
+
+ return Update::SUCCESS;
+}