summaryrefslogtreecommitdiff
path: root/common/tables/dividend_credits.php
blob: 2f80ec03ec25b306713c36821cc25a320f915e2d (plain)
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 mcoop;
require_once("common/db_classes.php");

class DividendCreditsUpgrader extends BaseIncrementalTableUpgrader {
	function from_1_to_2() {
		//$this->conn->exec("ALTER TABLE dividend_ ADD COLUMN (test BOOL)");
		// No actual changes in this one, it was just to make sure the upgrader paths were working
	}

	function __construct($conn) {
		$this->conn = $conn;
		$this->table_name = "dividend_credits";
		//$this->upgrade_method_names[2] = "from_1_to_2";
	}
}

$dividend_credits_table_decl = new SimpleTableDecl(
	"dividend_credits",
	array(
		"dividend_credits_ensure" => "INSERT IGNORE INTO dividend_credits (userid, year, credits, last_updated_table_version) VALUES (:userid, :year, 0, :table_ver)",
		"add_to_dividend_credits" => "UPDATE dividend_credits SET credits=credits + :amount WHERE userid=:userid AND year=:year",
		"remove_from_dividend_credits" => "UPDATE dividend_credits SET credits=credits - :amount WHERE userid=:userid AND year=:year",
		"set_dividend_credits" => "UPDATE dividend_credits SET credits=:amount WHERE userid=:userid AND year=:year"
	),
	"CREATE TABLE `dividend_credits` (
`userid` INT NOT NULL,
`year` INT NOT NULL,
`credits` BIGINT NOT NULL,
`last_updated_table_version` INT NOT NULL,
PRIMARY KEY (`userid`, `year`)
);",
	1,
	"\mcoop\DividendCreditsUpgrader"
);