@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

New auto-patch type "DB"

Summary:
Instead of specifying "DB" type patches in code, use a JSON file in the autopatch directory.

Also move a few examples.

Closes T16305

Test Plan:
- `bin/storage upgrade` to existing install - these are listed as "new patches", but since invoking a db-type patch is `CREATE DATABASE IF NOT EXISTS`, nothing actually happens.

- `bin/storage upgrade` to a new setup - works cleanly.

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16305

Differential Revision: https://we.phorge.it/D26427

Aviv Eyal 7ef52dae fb37870b

+67 -21
+3
resources/sql/autopatches/00.application.0.db
··· 1 + { 2 + "name": "application" 3 + }
+4
resources/sql/autopatches/00.pastebin.0.db
··· 1 + { 2 + "name": "pastebin", 3 + "dead": true 4 + }
+3
resources/sql/autopatches/00.system.0.db
··· 1 + { 2 + "name": "system" 3 + }
+3
resources/sql/autopatches/20140129.dashboard.0.db
··· 1 + { 2 + "name": "dashboard" 3 + }
+3
resources/sql/autopatches/20140902.almanac.0.db
··· 1 + { 2 + "name": "almanac" 3 + }
+3
resources/sql/autopatches/20140910.fund.0.db
··· 1 + { 2 + "name": "fund" 3 + }
+3
resources/sql/autopatches/20150430.multimeter.0.db
··· 1 + { 2 + "name": "multimeter" 3 + }
+3
resources/sql/autopatches/20150601.spaces.0.db
··· 1 + { 2 + "name": "spaces" 3 + }
+3
resources/sql/autopatches/20150712.badges.0.db
··· 1 + { 2 + "name": "badges" 3 + }
+3
resources/sql/autopatches/20150721.phurl.0.db
··· 1 + { 2 + "name": "phurl" 3 + }
+3
resources/sql/autopatches/20160721.pack.0.db
··· 1 + { 2 + "name": "packages" 3 + }
+3
resources/sql/autopatches/20190718.paste.0.db
··· 1 + { 2 + "name": "paste" 3 + }
-14
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 66 66 'db.metamta' => array(), 67 67 'db.oauth_server' => array(), 68 68 'db.owners' => array(), 69 - 'db.pastebin' => array( 70 - 'dead' => true, 71 - ), 72 69 'db.phame' => array(), 73 70 'db.phriction' => array(), 74 71 'db.project' => array(), ··· 102 99 'db.policy' => array(), 103 100 'db.nuance' => array(), 104 101 'db.passphrase' => array(), 105 - 'db.dashboard' => array(), 106 - 'db.system' => array(), 107 - 'db.fund' => array(), 108 - 'db.almanac' => array(), 109 - 'db.multimeter' => array(), 110 - 'db.spaces' => array(), 111 - 'db.phurl' => array(), 112 - 'db.badges' => array(), 113 - 'db.packages' => array(), 114 - 'db.application' => array(), 115 - 'db.paste' => array(), 116 102 '0000.legacy.sql' => array( 117 103 'legacy' => 0, 118 104 ),
+30 -7
src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
··· 19 19 20 20 foreach ($patch_list as $patch) { 21 21 $matches = null; 22 - if (!preg_match('/\.(sql|php)$/', $patch, $matches)) { 22 + if (!preg_match('/\.(sql|php|db)$/', $patch, $matches)) { 23 23 throw new Exception( 24 24 pht( 25 - 'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.', 25 + 'Unknown patch "%s" in "%s", '. 26 + 'expected ".php" or ".sql" or ".db" suffix.', 26 27 $patch, 27 28 $directory)); 28 29 } ··· 31 32 $patch_full_path = rtrim($directory, '/').'/'.$patch; 32 33 33 34 $attributes = array(); 34 - if ($patch_type === 'php') { 35 - $attributes = $this->getPHPPatchAttributes( 36 - $patch, 37 - $patch_full_path); 35 + switch ($patch_type) { 36 + case 'php': 37 + $attributes = $this->getPHPPatchAttributes( 38 + $patch, 39 + $patch_full_path); 40 + $patch_name = $patch_full_path; 41 + break; 42 + 43 + case 'db': 44 + $attributes = $this->getDBPatchAttributes( 45 + $patch, 46 + $patch_full_path); 47 + $patch_name = $attributes['name']; 48 + break; 49 + 50 + default: 51 + $patch_name = $patch_full_path; 52 + break; 38 53 } 39 54 55 + 40 56 $patches[$patch] = array( 41 57 'type' => $patch_type, 42 - 'name' => $patch_full_path, 58 + 'name' => $patch_name, 43 59 ) + $attributes; 44 60 } 45 61 ··· 342 358 return $attributes; 343 359 } 344 360 361 + private function getDBPatchAttributes($patch_name, $full_path) { 362 + $content = Filesystem::readFile($full_path); 363 + // Should be a valid JSON 364 + $data = phutil_json_decode($content); 365 + 366 + return array_select_keys($data, array('name', 'after', 'dead')); 367 + } 345 368 }