*
* @param bool $verbose
* @param bool $action Whether to actually apply the update
+ * @param bool $install Is this the initial update during the installation?
* @param array $tables An array of the database tables
* @param array $definition An array of the definition tables
* @return string Empty string if the update is successful, error messages otherwise
*/
- public static function update($verbose, $action, array $tables = null, array $definition = null) {
- if ($action) {
+ public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) {
+ if ($action && !$install) {
Config::set('system', 'maintenance', 1);
- Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
+ Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DBM::date().' '.date('e')));
}
$errors = '';
}
if ($action) {
- Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
+ if (!$install) {
+ Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
+ }
// Ensure index conversion to unique removes duplicates
if ($is_unique && ($temp_name != $name)) {
}
}
- if ($action) {
+ if ($action && !$install) {
Config::set('system', 'maintenance', 0);
Config::set('system', 'maintenance_reason', '');
- }
- if ($errors) {
- Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
- } else {
- Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
+ if ($errors) {
+ Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
+ } else {
+ Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
+ }
}
return $errors;
]
];
$database["cache"] = [
- "comment" => "Used to store different data that doesn't to be stored for a long time",
+ "comment" => "Stores temporary data",
"fields" => [
- "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => ""],
- "v" => ["type" => "mediumtext", "comment" => ""],
- "expire_mode" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
- "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
+ "k" => ["type" => "varbinary(255)", "not null" => "1", "primary" => "1", "comment" => "cache key"],
+ "v" => ["type" => "mediumtext", "comment" => "cached serialized value"],
+ "expires" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache expiration"],
+ "updated" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "datetime of cache insertion"],
],
"indexes" => [
"PRIMARY" => ["k"],
- "expire_mode_updated" => ["expire_mode", "updated"],
+ "k_expires" => ["k", "expires"],
]
];
$database["challenge"] = [
"xmpp" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"attag" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
- "photo" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
- "thumb" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
- "micro" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "photo" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
+ "thumb" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
+ "micro" => ["type" => "varchar(255)", "default" => "", "comment" => ""],
"site-pubkey" => ["type" => "text", "comment" => ""],
"issued-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"dfrn-id" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"noscrape" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => ""],
"platform" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
+ "relay-subscribe" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Has the server subscribed to the relay system"],
+ "relay-scope" => ["type" => "varchar(10)", "not null" => "1", "default" => "", "comment" => "The scope of messages that the server wants to get"],
"created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
"last_poco_query" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
"last_contact" => ["type" => "datetime", "default" => NULL_DATE, "comment" => ""],
"nurl" => ["UNIQUE", "nurl(190)"],
]
];
+ $database["gserver-tag"] = [
+ "comment" => "Tags that the server has subscribed",
+ "fields" => [
+ "gserver-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["gserver" => "id"], "primary" => "1", "comment" => "The id of the gserver"],
+ "tag" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "primary" => "1", "comment" => "Tag that the server has subscribed"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["gserver-id", "tag"],
+ "tag" => ["tag"],
+ ]
+ ];
$database["hook"] = [
"comment" => "addon hook registry",
"fields" => [
"callback_url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"topic" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
- "push" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
- "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
+ "push" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Retrial counter"],
+ "last_update" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last successful trial"],
+ "next_try" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Next retrial date"],
+ "renewed" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Date of last subscription renewal"],
"secret" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
],
"indexes" => [
"PRIMARY" => ["id"],
+ "next_try" => ["next_try"],
]
];
$database["queue"] = [
"username" => ["username(32)"],
]
];
+ $database["user-item"] = [
+ "comment" => "User specific item data",
+ "fields" => [
+ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["item" => "id"], "comment" => "Item id"],
+ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"],
+ "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hidden marker"],
+ ],
+ "indexes" => [
+ "PRIMARY" => ["uid", "iid"],
+ ]
+ ];
$database["workerqueue"] = [
"comment" => "Background tasks queue entries",
"fields" => [
"pid" => ["pid"],
"parameter" => ["parameter(64)"],
"priority_created" => ["priority", "created"],
- "executed" => ["executed"],
+ "done_executed" => ["done", "executed"],
]
];
+ \Friendica\Core\Addon::callHooks('dbstructure_definition', $database);
+
return $database;
}
}