Refactor loan and user management components and backend routes
- Updated LoanTable component to fetch loan data from new API endpoint and display notes. - Enhanced UserTable component to include additional user fields (first name, last name, email, admin status) and updated input handling. - Modified fetcher utility to use new user data API endpoint. - Adjusted login functionality to point to the new admin login endpoint and handle unauthorized access. - Refactored user actions utility to align with updated API endpoints for user management. - Updated backend routes for user and loan data management to reflect new structure and naming conventions. - Revised SQL schema and mock data to accommodate new fields and constraints. - Changed Docker configuration to use the new database name.
This commit is contained in:
@@ -17,7 +17,7 @@ CREATE TABLE users (
|
||||
CREATE TABLE loans (
|
||||
id int NOT NULL AUTO_INCREMENT,
|
||||
username varchar(100) NOT NULL,
|
||||
loan_code int NOT NULL UNIQUE,
|
||||
loan_code Char(6) NOT NULL UNIQUE,
|
||||
start_date timestamp NOT NULL,
|
||||
end_date timestamp NOT NULL,
|
||||
take_date timestamp NULL DEFAULT NULL,
|
||||
@@ -28,10 +28,7 @@ CREATE TABLE loans (
|
||||
deleted bool NOT NULL DEFAULT false,
|
||||
note varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT fk_loans_username
|
||||
FOREIGN KEY (username) REFERENCES users(username)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT
|
||||
CHECK (loan_code REGEXP '^[0-9]{6}$')
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE items (
|
||||
@@ -47,15 +44,11 @@ CREATE TABLE items (
|
||||
);
|
||||
|
||||
CREATE TABLE apiKeys (
|
||||
id int NOT NULL AUTO_INCREMENT,
|
||||
id INT NOT NULL AUTO_INCREMENT,
|
||||
api_key CHAR(15) NOT NULL UNIQUE,
|
||||
username VARCHAR(100) NOT NULL,
|
||||
last_used_at timestamp DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
entry_created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
entry_name VARCHAR(100) NOT NULL,
|
||||
last_used_at TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
entry_created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT chk_api_key_len CHECK (CHAR_LENGTH(api_key) = 15),
|
||||
CONSTRAINT fk_apikeys_username
|
||||
FOREIGN KEY (username) REFERENCES users(username)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT
|
||||
CHECK (api_key REGEXP '^[0-9]{15}$')
|
||||
) ENGINE=InnoDB;
|
||||
Reference in New Issue
Block a user