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 | |
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')
-rw-r--r-- | Zotlabs/Update/_1226.php | 78 | ||||
-rw-r--r-- | Zotlabs/Update/_1227.php | 30 | ||||
-rw-r--r-- | Zotlabs/Update/_1228.php | 37 |
3 files changed, 145 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); + } + } + } + } +} + + diff --git a/Zotlabs/Update/_1227.php b/Zotlabs/Update/_1227.php new file mode 100644 index 000000000..b5dbb2286 --- /dev/null +++ b/Zotlabs/Update/_1227.php @@ -0,0 +1,30 @@ +<?php + +namespace Zotlabs\Update; + + +class _1227 { + + function run() { + + q("START TRANSACTION"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r = q("ALTER TABLE dreport ADD dreport_name text NOT NULL DEFAULT '' "); + } + else { + $r = q("ALTER TABLE `dreport` ADD `dreport_name` char(191) NOT NULL DEFAULT ''"); + } + + if($r) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + } + +} + + diff --git a/Zotlabs/Update/_1228.php b/Zotlabs/Update/_1228.php new file mode 100644 index 000000000..b9ba1d86f --- /dev/null +++ b/Zotlabs/Update/_1228.php @@ -0,0 +1,37 @@ +<?php + +namespace Zotlabs\Update; + + +class _1228 { + + function run() { + + q("START TRANSACTION"); + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE item ADD uuid text NOT NULL DEFAULT '' "); + $r2 = q("create index \"uuid_idx\" on channel (\"uuid\")"); + $r3 = q("ALTER TABLE item add summary TEXT NOT NULL"); + + $r = ($r1 && $r2 && $r3); + } + else { + $r1 = q("ALTER TABLE `item` ADD `uuid` char(191) NOT NULL DEFAULT '' , + ADD INDEX `uuid` (`uuid`)"); + $r2 = q("ALTER TABLE `item` ADD `summary` mediumtext NOT NULL"); + $r = ($r1 && $r2); + } + + if($r) { + q("COMMIT"); + self::upgrade(); + return UPDATE_SUCCESS; + } + + q("ROLLBACK"); + return UPDATE_FAILED; + } + +} + |