aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Update/_1256.php
blob: db953711712719e9151e1d7c3a17a5c74834d72b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Zotlabs\Update;

class _1256 {

	function run() {

		dbq("START TRANSACTION");

		$r1 = dbq("TRUNCATE TABLE updates");

		if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
			$r2a = dbq("ALTER TABLE updates add ud_update numeric(1) NOT NULL DEFAULT '0'");
			$r2b = dbq("CREATE INDEX ud_update ON updates (ud_update)");

			$r2 = ($r2a && $r2b);
		}

		if(ACTIVE_DBTYPE == DBTYPE_MYSQL) {
			$r2 = dbq("ALTER TABLE updates add ud_update tinyint(1) NOT NULL DEFAULT '',
				KEY ud_update (ud_update)"
			);
		}

		if($r1 && $r2) {
			dbq("COMMIT");
			return UPDATE_SUCCESS;
		}

		q("ROLLBACK");
		return UPDATE_FAILED;

	}

}