change coords to double in database

This commit is contained in:
Mike Macgirvin 2024-04-17 09:04:59 +10:00
parent ab31908123
commit e41d7e2601
5 changed files with 60 additions and 5 deletions

View file

@ -27,7 +27,7 @@ use Code\Lib\Url;
*/
const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1277;
const DB_UPDATE_VERSION = 1278;
const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '13.3';

View file

@ -617,8 +617,8 @@ CREATE TABLE IF NOT EXISTS `item` (
`item_delayed` tinyint NOT NULL DEFAULT 0 ,
`item_pending_remove` tinyint NOT NULL DEFAULT 0 ,
`item_blocked` tinyint NOT NULL DEFAULT 0 ,
`lat` float NOT NULL DEFAULT '0',
`lon` float NOT NULL DEFAULT '0',
`lat` double NOT NULL DEFAULT '0',
`lon` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `parent` (`parent`),
KEY `created` (`created`),

View file

@ -631,8 +631,8 @@ CREATE TABLE "item" (
"item_delayed" smallint NOT NULL DEFAULT '0',
"item_pending_remove" smallint NOT NULL DEFAULT '0',
"item_blocked" smallint NOT NULL DEFAULT '0',
"lat" float NOT NULL DEFAULT '0',
"lon" float NOT NULL DEFAULT '0',
"lat" double NOT NULL DEFAULT '0',
"lon" double NOT NULL DEFAULT '0',
"item_search_vector" tsvector,
PRIMARY KEY ("id")
);

View file

@ -908,6 +908,11 @@ class Libzot
$px = 1;
}
if (! empty($arr['did'])) {
// see if this system supports did and if this channel has been migrated already.
// If not, migrate it.
}
$x = xchan_store_lowlevel(
[
'xchan_hash' => $xchan_hash,
@ -3029,8 +3034,10 @@ class Libzot
// Communication details
$ret['id'] = $e['xchan_guid'];
$ret['id_sig'] = self::sign($e['xchan_guid'], $e['channel_prvkey']);
$ret['did'] = Channel::getDidResolver($e);
$primary = new Primary([
'address' => $e['xchan_addr'],

48
src/Update/_1278.php Normal file
View file

@ -0,0 +1,48 @@
<?php
namespace Code\Update;
class _1278
{
public function run()
{
q("START TRANSACTION");
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$r1 = q("ALTER TABLE item ALTER COLUMN lat TYPE DOUBLE");
$r2 = q("ALTER TABLE item ALTER COLUMN lon TYPE DOUBLE");
$r = ($r1 && $r2);
}
else {
$r = q("ALTER TABLE `item`
CHANGE `lat` `lat` DOUBLE NOT NULL DEFAULT '0',
CHANGE `lon` `lon` DOUBLE NOT NULL DEFAULT '0'"
);
}
if ($r) {
q("COMMIT");
return UPDATE_SUCCESS;
}
q("ROLLBACK");
return UPDATE_FAILED;
}
public function verify()
{
$columns = db_columns('item');
if (in_array('lat', $columns) && in_array('lon', $columns)) {
return true;
}
return false;
}
}