Skip to content
Snippets Groups Projects
Commit ac38ef7f authored by Federico Hurtado's avatar Federico Hurtado
Browse files

Update schema for activity tables.

parent 43c81e09
No related branches found
No related tags found
1 merge request!8Feature/activity logger
...@@ -13,12 +13,11 @@ CREATE TABLE IF NOT EXISTS users ( ...@@ -13,12 +13,11 @@ CREATE TABLE IF NOT EXISTS users (
FOREIGN KEY (roleID) REFERENCES rolesPermissions(roleID) FOREIGN KEY (roleID) REFERENCES rolesPermissions(roleID)
); );
-- Table to log login/logout information -- Table to log login information
CREATE TABLE IF NOT EXISTS userLoginLogout ( CREATE TABLE IF NOT EXISTS userLogin (
eventId INT AUTO_INCREMENT PRIMARY KEY, eventId INT AUTO_INCREMENT PRIMARY KEY,
eventTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, eventTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
userID INT NOT NULL, userID INT NOT NULL,
eventType VARCHAR(255) NOT NULL, -- successfulLogin, unsuccessfulLogin, logout
FOREIGN KEY (userID) REFERENCES users(userID) FOREIGN KEY (userID) REFERENCES users(userID)
); );
...@@ -120,8 +119,18 @@ CREATE TABLE IF NOT EXISTS peopleXInvolvement ( ...@@ -120,8 +119,18 @@ CREATE TABLE IF NOT EXISTS peopleXInvolvement (
FOREIGN KEY (involvementId) REFERENCES involvementLookup(involvementId) FOREIGN KEY (involvementId) REFERENCES involvementLookup(involvementId)
); );
CREATE TABLE IF NOT EXISTS changeLog (
logId INT PRIMARY KEY AUTO_INCREMENT,
changedTable VARCHAR(255) NOT NULL, -- e.g., "people" to specify the table updated
recordId INT NOT NULL, -- ID of the record that was updated
userId INT NOT NULL, -- User who made the change (foreign key to `users` table)
changeTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
changeType ENUM('INSERT', 'UPDATE', 'DELETE') NOT NULL,
changedColumns TEXT NOT NULL, -- Names of columns that were changed
oldValues TEXT, -- JSON format for previous values
newValues TEXT, -- JSON format for new values
FOREIGN KEY (userId) REFERENCES users(userID)
);
INSERT INTO countryLookup (countryId, name) INSERT INTO countryLookup (countryId, name)
VALUES (1, 'United States'); VALUES (1, 'United States');
-- I think there is already a people table that exists in our DB and
-- has data that does not include peopoleID
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment