-
Notifications
You must be signed in to change notification settings - Fork 0
/
userRegisterTable.sql
52 lines (40 loc) · 1.71 KB
/
userRegisterTable.sql
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
48
49
50
DROP USER 'test'@'%';
CREATE USER 'test'@'%' IDENTIFIED BY 'qwert_1337';
DROP DATABASE hashedpotatoes;
CREATE DATABASE hashedpotatoes CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE hashedpotatoes;
CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(50) UNIQUE,
firstname VARCHAR(50) UNIQUE,
lastname VARCHAR(50) UNIQUE,
password VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
profilepicture VARCHAR(255) NOT NULL
);
GRANT SELECT ON hashedpotatoes.users TO 'test'@'%' WITH GRANT OPTION;
GRANT INSERT ON hashedpotatoes.users TO 'test'@'%' WITH GRANT OPTION;
GRANT DELETE ON hashedpotatoes.users TO 'test'@'%' WITH GRANT OPTION;
GRANT UPDATE ON hashedpotatoes.users TO 'test'@'%' WITH GRANT OPTION;
CREATE TABLE hashedpotatoes.passwordentrys (
idpasswordEntrys INT NOT NULL AUTO_INCREMENT,
name VARCHAR(45) NOT NULL,
password VARCHAR(255) NOT NULL,
url VARCHAR(255) NULL,
userid INT NULL,
PRIMARY KEY (idpasswordEntrys),
INDEX userid_idx (userid ASC) ,
CONSTRAINT userid
FOREIGN KEY (userid)
REFERENCES hashedpotatoes.users (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
GRANT SELECT ON hashedpotatoes.passwordentrys TO 'test'@'%' WITH GRANT OPTION;
GRANT INSERT ON hashedpotatoes.passwordentrys TO 'test'@'%' WITH GRANT OPTION;
GRANT DELETE ON hashedpotatoes.passwordentrys TO 'test'@'%' WITH GRANT OPTION;
GRANT UPDATE ON hashedpotatoes.passwordentrys TO 'test'@'%' WITH GRANT OPTION;
ALTER TABLE `hashedpotatoes`.`passwordentrys`
ADD COLUMN `username` VARCHAR(45) NULL AFTER `userid`;
ALTER TABLE `hashedpotatoes`.`passwordentrys`
ADD COLUMN `keyy` BLOB(255) NULL AFTER `username`;