summaryrefslogtreecommitdiff
path: root/common/tables/members.php
blob: bf1240d6fee754349e4a55116f78fde3110787d9 (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
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace mcoop;
require_once("common/db_classes.php");

class MembersUpgrader extends BaseIncrementalTableUpgrader {
	function from_1_to_2() {
		//$this->conn->exec("ALTER TABLE members 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 = "members";
		$this->upgrade_method_names[2] = "from_1_to_2";
	}
}

$members_table_decl = new SimpleTableDecl(
	"members",
	array(
		"register_member" => "INSERT INTO members (username, email, last_updated_table_version, full_name, argon2_password_hash) VALUES (:username, :email, :version, :full_name, :argon2_phash)",
		"get_member_passhash_by_username" => "SELECT argon2_password_hash FROM members WHERE username = :username",
		"get_member_by_username" => "SELECT * FROM members WHERE username = ?",
		"get_member_by_email" => "SELECT * FROM members WHERE email = ?",
		"get_members_by_uname_or_email" => "SELECT * FROM members WHERE username = :username OR email = :email",
		"get_public_member_info_by_userid" => "SELECT userid, username, full_name FROM members WHERE userid=:userid"
	),
	"CREATE TABLE `members` (
`userid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` TEXT CHARACTER SET utf8 NOT NULL,
`email` TEXT CHARACTER SET utf8 NOT NULL,
`last_updated_table_version` INT NOT NULL,
`full_name` TEXT CHARACTER SET utf8,
`validation_code` CHAR(64) CHARACTER SET ascii,
`validated` BOOL DEFAULT false,
`full_member` BOOL DEFAULT false,
`argon2_password_hash` VARCHAR(256) CHARACTER SET ascii,
`reset_password_hash` VARCHAR(256) CHARACTER SET ascii,
`reset_requested` BOOL DEFAULT false,
UNIQUE KEY (`username`(256)),
UNIQUE KEY (`email`(256))
);",
	2,
	"\mcoop\MembersUpgrader"
);

?>