[Database 1525] Deprecate profile.name in favor of user.username
This commit is contained in:
parent
e31d90eadb
commit
38f04616d2
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2023.09-dev (Giant Rhubarb)
|
-- Friendica 2023.09-dev (Giant Rhubarb)
|
||||||
-- DB_UPDATE_VERSION 1524
|
-- DB_UPDATE_VERSION 1525
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -1586,7 +1586,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
|
||||||
`profile-name` varchar(255) COMMENT 'Deprecated',
|
`profile-name` varchar(255) COMMENT 'Deprecated',
|
||||||
`is-default` boolean COMMENT 'Deprecated',
|
`is-default` boolean COMMENT 'Deprecated',
|
||||||
`hide-friends` boolean NOT NULL DEFAULT '0' COMMENT 'Hide friend list from viewers of this profile',
|
`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',
|
`pdesc` varchar(255) COMMENT 'Deprecated',
|
||||||
`dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
|
`dob` varchar(32) NOT NULL DEFAULT '0000-00-00' COMMENT 'Day of birth',
|
||||||
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
|
|
@ -13,7 +13,7 @@ Fields
|
||||||
| profile-name | Deprecated | varchar(255) | YES | | NULL | |
|
| profile-name | Deprecated | varchar(255) | YES | | NULL | |
|
||||||
| is-default | Deprecated | boolean | YES | | NULL | |
|
| is-default | Deprecated | boolean | YES | | NULL | |
|
||||||
| hide-friends | Hide friend list from viewers of this profile | boolean | NO | | 0 | |
|
| 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 | |
|
| pdesc | Deprecated | varchar(255) | YES | | NULL | |
|
||||||
| dob | Day of birth | varchar(32) | NO | | 0000-00-00 | |
|
| dob | Day of birth | varchar(32) | NO | | 0000-00-00 | |
|
||||||
| address | | varchar(255) | NO | | | |
|
| address | | varchar(255) | NO | | | |
|
||||||
|
|
|
@ -56,7 +56,7 @@ use Friendica\Database\DBA;
|
||||||
|
|
||||||
// This file is required several times during the test in DbaDefinition which justifies this condition
|
// This file is required several times during the test in DbaDefinition which justifies this condition
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1524);
|
define('DB_UPDATE_VERSION', 1525);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1583,7 +1583,7 @@ return [
|
||||||
"profile-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
|
"profile-name" => ["type" => "varchar(255)", "comment" => "Deprecated"],
|
||||||
"is-default" => ["type" => "boolean", "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"],
|
"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"],
|
"pdesc" => ["type" => "varchar(255)", "comment" => "Deprecated"],
|
||||||
"dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
|
"dob" => ["type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00", "comment" => "Day of birth"],
|
||||||
"address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"address" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
|
|
27
update.php
27
update.php
|
@ -1349,3 +1349,30 @@ function update_1524(): int
|
||||||
|
|
||||||
return Update::SUCCESS;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user