diff options
author | zotlabs <mike@macgirvin.com> | 2018-11-14 16:40:30 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-11-14 16:40:30 -0800 |
commit | bf013ecf00c710d6056890a6994eedd096121841 (patch) | |
tree | 68e83c694c766dcf867eabe87fffd96af5f4848e /Zotlabs/Update/_1226.php | |
parent | cfc43f6dea22c4c23ed485a7b321de76515f584d (diff) | |
download | volse-hubzilla-bf013ecf00c710d6056890a6994eedd096121841.tar.gz volse-hubzilla-bf013ecf00c710d6056890a6994eedd096121841.tar.bz2 volse-hubzilla-bf013ecf00c710d6056890a6994eedd096121841.zip |
db updates for zot6
Diffstat (limited to 'Zotlabs/Update/_1226.php')
-rw-r--r-- | Zotlabs/Update/_1226.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Zotlabs/Update/_1226.php b/Zotlabs/Update/_1226.php new file mode 100644 index 000000000..6e5a0e319 --- /dev/null +++ b/Zotlabs/Update/_1226.php @@ -0,0 +1,78 @@ +<?php + +namespace Zotlabs\Update; + +use Zotlabs\Lib\Libzot; + +class _1226 { + + function run() { + + q("START TRANSACTION"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE channel ADD channel_portable_id text NOT NULL DEFAULT '' "); + $r2 = q("create index \"channel_portable_id_idx\" on channel (\"channel_portable_id\")"); + + $r = ($r1 && $r2); + } + else { + $r = q("ALTER TABLE `channel` ADD `channel_portable_id` char(191) NOT NULL DEFAULT '' , + ADD INDEX `channel_portable_id` (`channel_portable_id`)"); + } + + if($r) { + q("COMMIT"); + self::upgrade(); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + } + + + static function upgrade() { + + $r = q("select * from channel where channel_portable_id = '' "); + + if($r) { + foreach($r as $rv) { + + $zhash = Libzot::make_xchan_hash($rv['channel_guid'],$rv['channel_pubkey']); + q("update channel set channel_portable_id = '%s' where channel_id = %d", + dbesc($zhash), + intval($rv['channel_id']) + ); + $x = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($rv['channel_hash']) + ); + if($x) { + $rec = $x[0]; + $rec['xchan_hash'] = $zhash; + $rec['xchan_guid_sig'] = 'sha256.' . $rec['xchan_guid_sig']; + $rec['xchan_network'] = 'zot6'; + + xchan_store_lowlevel($rec); + } + $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' limit 1", + dbesc($rv['channel_hash']), + dbesc(z_root()) + ); + if($x) { + $rec = $x[0]; + $rec['hubloc_hash'] = $zhash; + $rec['hubloc_guid_sig'] = 'sha256.' . $rec['hubloc_guid_sig']; + $rec['hubloc_network'] = 'zot6'; + $rec['hubloc_url_sig'] = 'sha256.' . $rec['hubloc_url_sig']; + $rec['hubloc_callback'] = z_root() . '/zot'; + $rec['hubloc_id_url'] = channel_url($rv); + $rec['hubloc_site_id'] = Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')); + hubloc_store_lowlevel($rec); + } + } + } + } +} + + |