Skip to content
Snippets Groups Projects
Commit 96cfcbad authored by Pedro Pablo Cardona Arroyave's avatar Pedro Pablo Cardona Arroyave
Browse files

Merge branch 'feature/combineUserAndProfiles' into 'main'

Tables users, authority and profiles were combined together.

See merge request idatt2106-v23-03/backend!26
parents 1036cd16 9d794798
No related branches found
No related tags found
No related merge requests found
CREATE TABLE users (
username VARCHAR(50) NOT NULL PRIMARY KEY,
password VARCHAR(500) NOT NULL,
enabled BOOLEAN NOT NULL
);
CREATE TABLE authorities (
username VARCHAR(50) NOT NULL,
authority VARCHAR(50) NOT NULL,
CONSTRAINT fk_authorities_users FOREIGN KEY (username) REFERENCES users (username)
);
CREATE UNIQUE INDEX ix_auth_username ON authorities (username, authority);
CREATE TABLE profiles (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
enabled BOOLEAN NOT NULL,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
authority VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL UNIQUE,
birthdate DATE NOT NULL,
creation_time TIMESTAMP NOT NULL DEFAULT current_timestamp,
group_id BIGINT NOT NULL,
FOREIGN KEY (group_id) REFERENCES groups (group_id),
CONSTRAINT fk_profile_user FOREIGN KEY (username) REFERENCES users (username)
FOREIGN KEY (group_id) REFERENCES groups (group_id)
);
CREATE UNIQUE INDEX ix_profiles_username ON profiles (username, id);
CREATE TABLE groups(
group_id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
group_name VARCHAR(50) NOT NULL,
......
INSERT INTO users (username, password, enabled)
VALUES
('john', '{noop}password123', true),
('jane', '{noop}password456', true),
('bob', '{noop}password789', true),
('alice', '{noop}password111', true),
('tom', '{noop}password222', true),
('sarah', '{noop}password333', true),
('david', '{noop}password444', true),
('emily', '{noop}password555', true),
('mike', '{noop}password666', true),
('olivia', '{noop}password777', true);
INSERT INTO groups (group_name, level, points)
VALUES
('Group A', 1, 100),
('Group B', 2, 250),
('Group C', 3, 500),
('Group D', 4, 750),
('Group E', 1, 200);
INSERT INTO users (username, password, enabled, first_name, last_name, authority, email, birthdate, group_id)
VALUES
('john', '{noop}password123', true, 'John', 'Doe', 'USER', 'john@example.com', '1990-01-01', 1),
('jane', '{noop}password456', true, 'Jane', 'Doe', 'USER', 'jane@example.com', '1992-02-02', 1),
('bob', '{noop}password789', true, 'Bob', 'Smith', 'USER', 'bob@example.com', '1995-03-03', 2),
('alice', '{noop}password111', true, 'Alice', 'Johnson', 'USER', 'alice@example.com', '1998-04-04', 2),
('tom', '{noop}password222', true, 'Tom', 'Brown', 'USER', 'tom@example.com', '2000-05-05', 3),
('sarah', '{noop}password333', true, 'Sarah', 'Lee', 'USER', 'sarah@example.com', '2002-06-06', 3),
('david', '{noop}password444', true, 'David', 'Wilson', 'USER', 'david@example.com', '2004-07-07', 4),
('emily', '{noop}password555', true, 'Emily', 'Davis', 'USER', 'emily@example.com', '2006-08-08', 4),
('mike', '{noop}password666', true, 'Mike', 'Taylor', 'USER', 'mike@example.com', '2008-09-09', 5),
('olivia', '{noop}password777', true, 'Olivia', 'Clark', 'USER', 'olivia@example.com', '2010-10-10', 5);
INSERT INTO authorities (username, authority)
VALUES
......@@ -24,14 +33,6 @@ VALUES
('mike', 'USER'),
('olivia', 'ADMIN');
INSERT INTO groups (group_name, level, points)
VALUES
('Group A', 1, 100),
('Group B', 2, 250),
('Group C', 3, 500),
('Group D', 4, 750),
('Group E', 1, 200);
INSERT INTO profiles (username, first_name, last_name,email, birthdate, group_id)
VALUES
('john','John','Smith','johnSmith@gmail.com','1998-05-07',1),
......
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