summaryrefslogtreecommitdiff
path: root/common/tables/members.php
diff options
context:
space:
mode:
Diffstat (limited to 'common/tables/members.php')
-rw-r--r--common/tables/members.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/common/tables/members.php b/common/tables/members.php
new file mode 100644
index 0000000..bf1240d
--- /dev/null
+++ b/common/tables/members.php
@@ -0,0 +1,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"
+);
+
+?>