Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more basic initial data needed to run the app #663

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/test.db.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ENV POSTGRES_DB phpreport
COPY sql/schema.sql /docker-entrypoint-initdb.d/1.sql
COPY sql/uniqueConstraints.sql /docker-entrypoint-initdb.d/2.sql
COPY sql/otherConstraints.sql /docker-entrypoint-initdb.d/3.sql
COPY sql/initialData.sql /docker-entrypoint-initdb.d/4.sql
COPY sql/update/all.sql /docker-entrypoint-initdb.d/5.sql
COPY sql/update/all.sql /docker-entrypoint-initdb.d/4.sql
COPY sql/initialData.sql /docker-entrypoint-initdb.d/5.sql
21 changes: 15 additions & 6 deletions sql/initialData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,27 @@

INSERT INTO user_group VALUES (1, 'staff');
INSERT INTO user_group VALUES (2, 'admin');
INSERT INTO user_group VALUES (3,'manager');

-- advance two steps the sequence which generates group ids
SELECT nextval(pg_get_serial_sequence('user_group', 'id'));
SELECT nextval(pg_get_serial_sequence('user_group', 'id'));

SELECT nextval(pg_get_serial_sequence('user_group', 'id'));
--
-- Data for Name: usr; Type: TABLE DATA; Schema: public; Owner: phpreport
--

INSERT INTO usr VALUES (1, md5('user'), 'user');
INSERT INTO usr VALUES (2, md5('admin'), 'admin');
INSERT INTO usr VALUES (3, md5('manager'), 'manager');
INSERT INTO usr VALUES (4, md5('phpreport'), 'phpreport-test');


-- advance two steps the sequence which generates user ids
SELECT nextval(pg_get_serial_sequence('usr', 'id'));
SELECT nextval(pg_get_serial_sequence('usr', 'id'));
SELECT nextval(pg_get_serial_sequence('usr', 'id'));
SELECT nextval(pg_get_serial_sequence('usr', 'id'));

--
-- Data for Name: belongs; Type: TABLE DATA; Schema: public; Owner: phpreport
Expand All @@ -35,7 +41,10 @@ SELECT nextval(pg_get_serial_sequence('usr', 'id'));
INSERT INTO belongs VALUES (1, 1);
INSERT INTO belongs VALUES (1, 2);
INSERT INTO belongs VALUES (2, 2);

INSERT INTO belongs VALUES (1, 3);
INSERT INTO belongs VALUES (3, 3);
INSERT INTO belongs VALUES (1, 4);
INSERT INTO belongs VALUES (2, 4);
--
-- Data for Name: area; Type: TABLE DATA; Schema: public; Owner: phpreport
--
Expand All @@ -45,8 +54,8 @@ INSERT INTO area VALUES (1, 'internal');
-- advance one step the sequence which generates area ids
SELECT nextval(pg_get_serial_sequence('area', 'id'));

--
-- Data for Name: project; Type: TABLE DATA; Schema: public; Owner: phpreport
--
INSERT INTO sector VALUES (1, 'tech');
SELECT nextval(pg_get_serial_sequence('sector', 'id'));

INSERT INTO project (description, areaid) VALUES ('Holidays', 1);
INSERT INTO customer (name, type, sectorid) VALUES ('Internal', 'Small', 1);
INSERT INTO project (description, areaid, customerid) VALUES ('Holidays', 1, 1);
22 changes: 0 additions & 22 deletions sql/update/all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,6 @@ alter table template add constraint includes
foreign key (task_storyId)
references task_story (id) ;

--
-- Add new manager user group to the user_group table
-- Restricts access to default staff profile
--

INSERT INTO user_group VALUES (3,'manager');
SELECT nextval(pg_get_serial_sequence('user_group', 'id'));
--
-- Add admin user to the manager group
--

INSERT INTO belongs VALUES (3, 2);

--
-- Create manager user and give proper permissions (staff and manager)
--

INSERT INTO usr VALUES (3, md5('manager'), 'manager');
SELECT nextval(pg_get_serial_sequence('usr', 'id'));
INSERT INTO belongs VALUES (1, 3);
INSERT INTO belongs VALUES (3, 3);

--
-- New table for user goals templates.
--
Expand Down