@tamu-dor/famis-db 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/change.txt +123 -0
- package/changes.md +405 -0
- package/docs/assets/anchor.js +350 -0
- package/docs/assets/bass-addons.css +12 -0
- package/docs/assets/bass.css +544 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
- package/docs/assets/fonts/LICENSE.txt +93 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
- package/docs/assets/fonts/source-code-pro.css +23 -0
- package/docs/assets/github.css +123 -0
- package/docs/assets/site.js +168 -0
- package/docs/assets/split.css +15 -0
- package/docs/assets/split.js +782 -0
- package/docs/assets/style.css +147 -0
- package/docs/index.html +3737 -0
- package/docs.md +591 -0
- package/famisDb.pdf +0 -0
- package/index.js +1497 -0
- package/package.json +25 -0
- package/readme.md +38 -0
- package/readme.wiki +332 -0
- package/schemas/00-initial-data.sql +116 -0
- package/schemas/migrations/201906101221.sql +29 -0
- package/schemas/migrations/201907081530.sql +51 -0
- package/schemas/migrations/201908230849.sql +40 -0
- package/schemas/migrations/201910031358.sql +73 -0
- package/schemas/migrations/20191024.sql +38 -0
- package/schemas/migrations/201911060915.sql +3 -0
- package/schemas/migrations/202001221335.sql +58 -0
- package/schemas/migrations/202003041114.sql +53 -0
- package/schemas/migrations/202003261143.sql +47 -0
- package/schemas/migrations/202004201456.sql +3 -0
- package/schemas/migrations/20200722.sql +92 -0
- package/schemas/migrations/202007281124.sql +17 -0
- package/schemas/migrations/20200729.sql +76 -0
- package/schemas/migrations/20200806-FCF.sql +72 -0
- package/schemas/migrations/20200806-IMAC.sql +60 -0
- package/schemas/migrations/20200811.sql +46 -0
- package/schemas/migrations/20200813.sql +36 -0
- package/schemas/migrations/202010210924.sql +66 -0
- package/schemas/migrations/202010211558.sql +20 -0
- package/schemas/migrations/202011130651.sql +4 -0
- package/schemas/migrations/202011130951.sql +17 -0
- package/schemas/migrations/202101201051.sql +33 -0
- package/schemas/migrations/postponed-202004221221.sql +66 -0
- package/schemas/schema.sql +155 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
BEGIN TRANSACTION;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Add a "last seen" date for each account, which is set upon insert. Create a
|
|
5
|
+
"current" view with only accounts present in the latest feed (and have it
|
|
6
|
+
displace the "accounts" name for ease of transition). Deleted accounts may
|
|
7
|
+
simply disappear from the feed!
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
ALTER TABLE accounts RENAME TO accounts_all;
|
|
11
|
+
-- Add the column and set it to "yesterday" for existing data. (Twice as fast
|
|
12
|
+
-- as adding it and setting existing data with an UPDATE -- the ALTER TABLE
|
|
13
|
+
-- statement will modify all rows.)
|
|
14
|
+
ALTER TABLE accounts_all ADD COLUMN last_seen date DEFAULT CURRENT_DATE - 1;
|
|
15
|
+
-- Now set the intended default for future INSERTs.
|
|
16
|
+
ALTER TABLE accounts_all ALTER COLUMN last_seen SET DEFAULT CURRENT_DATE;
|
|
17
|
+
CREATE INDEX accounts_last_seen ON public.accounts_all (last_seen);
|
|
18
|
+
|
|
19
|
+
-- View for "current" accounts (those present in the latest feed). Deleted
|
|
20
|
+
-- accounts often simply disappear; we don't want to bill those, but may need
|
|
21
|
+
-- them for historical reference. Use MAX rather than CURRENT_DATE in case we
|
|
22
|
+
-- ever have a problem with the feed and don't update for a couple days.
|
|
23
|
+
CREATE VIEW accounts AS
|
|
24
|
+
SELECT * FROM accounts_all
|
|
25
|
+
WHERE last_seen = (SELECT MAX(last_seen) FROM accounts_all);
|
|
26
|
+
|
|
27
|
+
ALTER VIEW accounts OWNER TO dba;
|
|
28
|
+
|
|
29
|
+
-- Move the parser user's privileges from the table to the view.
|
|
30
|
+
GRANT SELECT, INSERT, UPDATE ON accounts TO famisparser;
|
|
31
|
+
REVOKE ALL PRIVILEGES ON accounts_all FROM famisparser;
|
|
32
|
+
-- The app user may need access to historical accounts as well, so grant it
|
|
33
|
+
-- access to the view, and leave its existing SELECT on the full table.
|
|
34
|
+
GRANT SELECT ON accounts TO famis;
|
|
35
|
+
|
|
36
|
+
COMMIT;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
BEGIN TRANSACTION;
|
|
2
|
+
DO $$
|
|
3
|
+
DECLARE
|
|
4
|
+
core_id integer;
|
|
5
|
+
user_id integer;
|
|
6
|
+
core_name CONSTANT varchar := 'Comparative Medicine Program';
|
|
7
|
+
BEGIN
|
|
8
|
+
IF NOT EXISTS (
|
|
9
|
+
SELECT 1 FROM public.cores WHERE facility = core_name
|
|
10
|
+
) THEN
|
|
11
|
+
INSERT INTO public.cores (facility, contact, "contactEmail",
|
|
12
|
+
"systemId", enabled, "coreEmail", "coreAddress")
|
|
13
|
+
VALUES (core_name, 'Melanie Martin', 'mlmartin@tamu.edu', 2,
|
|
14
|
+
TRUE, 'cmp-business@tamu.edu',
|
|
15
|
+
'972 Agronomy Rd
|
|
16
|
+
College Station, TX 77843
|
|
17
|
+
Mail Stop: 4473');
|
|
18
|
+
ELSE
|
|
19
|
+
UPDATE public.cores SET
|
|
20
|
+
contact = 'Melanie Martin',
|
|
21
|
+
"contactEmail" = 'mlmartin@tamu.edu',
|
|
22
|
+
"systemId" = 2,
|
|
23
|
+
enabled = TRUE,
|
|
24
|
+
"coreEmail" = 'cmp-business@tamu.edu',
|
|
25
|
+
"coreAddress" = '972 Agronomy Rd
|
|
26
|
+
College Station, TX 77843
|
|
27
|
+
Mail Stop: 4473'
|
|
28
|
+
WHERE facility = core_name;
|
|
29
|
+
END IF;
|
|
30
|
+
-- assign id to variable; STRICT requires exactly one row be found
|
|
31
|
+
SELECT id INTO STRICT core_id FROM public.cores WHERE facility = core_name;
|
|
32
|
+
|
|
33
|
+
IF NOT EXISTS (
|
|
34
|
+
SELECT 1 FROM public.core_accounts WHERE "coreId" = core_id
|
|
35
|
+
) THEN
|
|
36
|
+
INSERT INTO public.core_accounts ("coreId", account, effective)
|
|
37
|
+
VALUES (core_id, '0227059000000', '2020-05-01');
|
|
38
|
+
ELSE
|
|
39
|
+
UPDATE public.core_accounts SET account = '0227059000000', effective = '2020-05-01'
|
|
40
|
+
WHERE "coreId" = core_id AND effective = (SELECT MAX(effective)
|
|
41
|
+
FROM public.core_accounts WHERE "coreId" = core_id);
|
|
42
|
+
END IF;
|
|
43
|
+
|
|
44
|
+
-- there are unique constraints on users.userId and user_cores.(coreId + userId)
|
|
45
|
+
INSERT INTO public.users ("userId") VALUES ('8b347a0cc89d9c8a620fa25a0a6b6fda')
|
|
46
|
+
ON CONFLICT DO NOTHING;
|
|
47
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
48
|
+
WHERE "userId" = '8b347a0cc89d9c8a620fa25a0a6b6fda';
|
|
49
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
50
|
+
ON CONFLICT DO NOTHING;
|
|
51
|
+
|
|
52
|
+
INSERT INTO public.users ("userId") VALUES ('8ff2c26efcbf088ff73e864cb4303a1f')
|
|
53
|
+
ON CONFLICT DO NOTHING;
|
|
54
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
55
|
+
WHERE "userId" = '8ff2c26efcbf088ff73e864cb4303a1f';
|
|
56
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
57
|
+
ON CONFLICT DO NOTHING;
|
|
58
|
+
|
|
59
|
+
INSERT INTO public.users ("userId") VALUES ('b9d0c007a8149152334cddb1a318dd0d')
|
|
60
|
+
ON CONFLICT DO NOTHING;
|
|
61
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
62
|
+
WHERE "userId" = 'b9d0c007a8149152334cddb1a318dd0d';
|
|
63
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
64
|
+
ON CONFLICT DO NOTHING;
|
|
65
|
+
END $$ ;
|
|
66
|
+
COMMIT;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
BEGIN TRANSACTION;
|
|
2
|
+
DO $$
|
|
3
|
+
DECLARE
|
|
4
|
+
core_id integer;
|
|
5
|
+
user_id integer;
|
|
6
|
+
core_name CONSTANT varchar := 'Rodent Pre-clinical Phenotyping Core';
|
|
7
|
+
BEGIN
|
|
8
|
+
IF NOT EXISTS (
|
|
9
|
+
SELECT 1 FROM public.cores WHERE facility = core_name
|
|
10
|
+
) THEN
|
|
11
|
+
RAISE NOTICE 'Core does not exist.';
|
|
12
|
+
ELSE
|
|
13
|
+
UPDATE public.cores SET
|
|
14
|
+
contact = 'Marcy Bundick',
|
|
15
|
+
"contactEmail" = 'bundick@tamu.edu',
|
|
16
|
+
"coreEmail" = 'bundick@tamu.edu'
|
|
17
|
+
WHERE facility = core_name;
|
|
18
|
+
END IF;
|
|
19
|
+
END $$ ;
|
|
20
|
+
COMMIT;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
BEGIN TRANSACTION;
|
|
2
|
+
DO $$
|
|
3
|
+
DECLARE
|
|
4
|
+
core_id integer;
|
|
5
|
+
core_name CONSTANT varchar := 'Comparative Medicine Program';
|
|
6
|
+
BEGIN
|
|
7
|
+
IF EXISTS (
|
|
8
|
+
SELECT 1 FROM public.cores WHERE facility = core_name
|
|
9
|
+
) THEN
|
|
10
|
+
SELECT id INTO STRICT core_id FROM public.cores WHERE facility = core_name;
|
|
11
|
+
UPDATE public.cores SET
|
|
12
|
+
"from_email" = 'mosaic@vpr.tamu.edu',
|
|
13
|
+
"invoice_email" = 'vpr-business@tamu.edu'
|
|
14
|
+
WHERE id = core_id;
|
|
15
|
+
END IF;
|
|
16
|
+
END $$ ;
|
|
17
|
+
COMMIT;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
-- Remove Natalie Perdue
|
|
2
|
+
-- Add Tribbie Grimm and Tyson Gleitz
|
|
3
|
+
|
|
4
|
+
BEGIN TRANSACTION;
|
|
5
|
+
DO $$
|
|
6
|
+
DECLARE
|
|
7
|
+
core_id integer;
|
|
8
|
+
user_id integer;
|
|
9
|
+
core_name CONSTANT varchar := 'Comparative Medicine Program';
|
|
10
|
+
BEGIN
|
|
11
|
+
SELECT id INTO STRICT core_id FROM public.cores WHERE facility = core_name;
|
|
12
|
+
|
|
13
|
+
-- there are unique constraints on users.userId and user_cores.(coreId + userId)
|
|
14
|
+
INSERT INTO public.users ("userId") VALUES ('eb103f26b6289d896a3118e550b0c422')
|
|
15
|
+
ON CONFLICT DO NOTHING;
|
|
16
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
17
|
+
WHERE "userId" = 'eb103f26b6289d896a3118e550b0c422';
|
|
18
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
19
|
+
ON CONFLICT DO NOTHING;
|
|
20
|
+
|
|
21
|
+
INSERT INTO public.users ("userId") VALUES ('91b1221071c7dae4faf3feee14ab858f')
|
|
22
|
+
ON CONFLICT DO NOTHING;
|
|
23
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
24
|
+
WHERE "userId" = '91b1221071c7dae4faf3feee14ab858f';
|
|
25
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
26
|
+
ON CONFLICT DO NOTHING;
|
|
27
|
+
|
|
28
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
29
|
+
WHERE "userId" = 'b9d0c007a8149152334cddb1a318dd0d';
|
|
30
|
+
DELETE FROM public.user_cores WHERE "coreId" = core_id AND "userId" = user_id;
|
|
31
|
+
UPDATE public.users SET deleted = CURRENT_TIMESTAMP WHERE "userId" = 'b9d0c007a8149152334cddb1a318dd0d';
|
|
32
|
+
END $$ ;
|
|
33
|
+
COMMIT;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
BEGIN TRANSACTION;
|
|
2
|
+
DO $$
|
|
3
|
+
DECLARE
|
|
4
|
+
core_id integer;
|
|
5
|
+
user_id integer;
|
|
6
|
+
account_number CONSTANT varchar := '0227102000000';
|
|
7
|
+
core_name CONSTANT varchar := 'Protein Chemistry Laboratory';
|
|
8
|
+
BEGIN
|
|
9
|
+
IF NOT EXISTS (
|
|
10
|
+
SELECT 1 FROM public.cores WHERE facility = core_name
|
|
11
|
+
) THEN
|
|
12
|
+
INSERT INTO public.cores (facility, contact, "contactEmail", "systemId",
|
|
13
|
+
enabled, "coreEmail" /* no phone or address supplied */)
|
|
14
|
+
VALUES (core_name, 'Shelly Pasket', 'spasket@tamu.edu', 2,
|
|
15
|
+
TRUE, null);
|
|
16
|
+
ELSE
|
|
17
|
+
SELECT id INTO STRICT core_id FROM public.cores WHERE facility = core_name;
|
|
18
|
+
UPDATE public.cores SET
|
|
19
|
+
"facility" = core_name,
|
|
20
|
+
"contact" = 'Shelly Pasket',
|
|
21
|
+
"contactEmail" = 'spasket@tamu.edu',
|
|
22
|
+
"systemId" = 2,
|
|
23
|
+
"enabled" = 'TRUE',
|
|
24
|
+
"deleted" = NULL,
|
|
25
|
+
"coreEmail" = NULL,
|
|
26
|
+
"corePhone" = NULL,
|
|
27
|
+
"coreAddress" = NULL
|
|
28
|
+
WHERE id = core_id;
|
|
29
|
+
END IF;
|
|
30
|
+
-- assign id to variable; STRICT requires exactly one row be found
|
|
31
|
+
SELECT id INTO STRICT core_id FROM public.cores WHERE facility = core_name;
|
|
32
|
+
|
|
33
|
+
IF NOT EXISTS (
|
|
34
|
+
SELECT 1 FROM public.core_accounts WHERE "coreId" = core_id
|
|
35
|
+
) THEN
|
|
36
|
+
INSERT INTO public.core_accounts ("coreId", account, effective)
|
|
37
|
+
VALUES (core_id, account_number, '2019-09-01');
|
|
38
|
+
ELSE
|
|
39
|
+
UPDATE public.core_accounts SET account = account_number, effective = '2019-09-01'
|
|
40
|
+
WHERE "coreId" = core_id AND effective = (SELECT MAX(effective)
|
|
41
|
+
FROM public.core_accounts WHERE "coreId" = core_id);
|
|
42
|
+
END IF;
|
|
43
|
+
|
|
44
|
+
-- there are unique constraints on users.userId and user_cores.(coreId + userId)
|
|
45
|
+
INSERT INTO public.users ("userId") VALUES ('c8ae172ea6c8779b64d563086510aeea')
|
|
46
|
+
ON CONFLICT DO NOTHING;
|
|
47
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
48
|
+
WHERE "userId" = 'c8ae172ea6c8779b64d563086510aeea';
|
|
49
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
50
|
+
ON CONFLICT DO NOTHING;
|
|
51
|
+
|
|
52
|
+
INSERT INTO public.users ("userId") VALUES ('ce3d00a77cdeb880b5213daf95f83ec1')
|
|
53
|
+
ON CONFLICT DO NOTHING;
|
|
54
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
55
|
+
WHERE "userId" = 'ce3d00a77cdeb880b5213daf95f83ec1';
|
|
56
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
57
|
+
ON CONFLICT DO NOTHING;
|
|
58
|
+
|
|
59
|
+
INSERT INTO public.users ("userId") VALUES ('72f3ee7aa427b0fef432f2658def0270')
|
|
60
|
+
ON CONFLICT DO NOTHING;
|
|
61
|
+
SELECT id INTO STRICT user_id FROM public.users
|
|
62
|
+
WHERE "userId" = '72f3ee7aa427b0fef432f2658def0270';
|
|
63
|
+
INSERT INTO public.user_cores ("coreId", "userId", email) VALUES (core_id, user_id, TRUE)
|
|
64
|
+
ON CONFLICT DO NOTHING;
|
|
65
|
+
END $$ ;
|
|
66
|
+
COMMIT;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
-- Tables used by famis-db, and thus ilabs-billing and invoice-server. Does
|
|
2
|
+
-- not include tables which are updated daily from feeds; see the dumpparser
|
|
3
|
+
-- repos for those (abr_rules, account_balances, accounts, alt_bank, customers,
|
|
4
|
+
-- departments, subcode_edits, and view_funds).
|
|
5
|
+
--
|
|
6
|
+
-- Exception: ownership and grants for departments are included here, since the
|
|
7
|
+
-- departments feed is used in both MySQL and PostgreSQL. Its schema file (in
|
|
8
|
+
-- dumpparser) contains a comment describing the necessary permissions but does
|
|
9
|
+
-- not grant them to any specific user.
|
|
10
|
+
|
|
11
|
+
CREATE TABLE public.system (
|
|
12
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
13
|
+
name character varying(255),
|
|
14
|
+
due text,
|
|
15
|
+
fein character varying(255),
|
|
16
|
+
agency character varying(255),
|
|
17
|
+
"checkAddress" text,
|
|
18
|
+
credit boolean DEFAULT FALSE NOT NULL,
|
|
19
|
+
"creditUrl" text,
|
|
20
|
+
"creditFee" text,
|
|
21
|
+
part character varying(2),
|
|
22
|
+
abbrev character varying(10),
|
|
23
|
+
PRIMARY KEY("id")
|
|
24
|
+
);
|
|
25
|
+
CREATE INDEX "system_part" ON "public"."system" USING btree ("part");
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
-- Allow only one expense code per revenue code
|
|
29
|
+
-- Expense codes do not need to be unique
|
|
30
|
+
CREATE TABLE public.codes (
|
|
31
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
32
|
+
revenue character varying(5),
|
|
33
|
+
expense character varying(5),
|
|
34
|
+
sales boolean DEFAULT FALSE NOT NULL,
|
|
35
|
+
PRIMARY KEY("id"),
|
|
36
|
+
UNIQUE("revenue")
|
|
37
|
+
);
|
|
38
|
+
CREATE INDEX "codes_expense" ON "public"."codes" USING btree ("expense");
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
CREATE TABLE public.cores (
|
|
42
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
43
|
+
facility character varying(255),
|
|
44
|
+
contact character varying(255),
|
|
45
|
+
"contactEmail" character varying(255),
|
|
46
|
+
"coreEmail" character varying(255),
|
|
47
|
+
"corePhone" character varying(255),
|
|
48
|
+
"coreAddress" text,
|
|
49
|
+
"systemId" integer,
|
|
50
|
+
"enabled" boolean DEFAULT FALSE NOT NULL,
|
|
51
|
+
deleted timestamp with time zone,
|
|
52
|
+
from_email character varying(255) NULL,
|
|
53
|
+
invoice_email character varying(255) NULL,
|
|
54
|
+
PRIMARY KEY("id"),
|
|
55
|
+
FOREIGN KEY ("systemId") REFERENCES public.system(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
56
|
+
);
|
|
57
|
+
CREATE INDEX "cores_account" ON "public"."cores" USING btree ("account");
|
|
58
|
+
CREATE INDEX "cores_systemId" ON "public"."cores" USING btree ("systemId");
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
CREATE TABLE public.core_accounts (
|
|
62
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
63
|
+
"coreId" integer NOT NULL,
|
|
64
|
+
account character varying(13) NOT NULL,
|
|
65
|
+
effective date NOT NULL,
|
|
66
|
+
PRIMARY KEY(id),
|
|
67
|
+
FOREIGN KEY("coreId") REFERENCES public.cores(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
68
|
+
);
|
|
69
|
+
CREATE INDEX core_accounts_core_id ON public.core_accounts USING btree ("coreId");
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
CREATE TABLE public.invoices (
|
|
73
|
+
uid character varying(29) NOT NULL,
|
|
74
|
+
"number" character varying(255) NOT NULL,
|
|
75
|
+
lab text,
|
|
76
|
+
"totalAmount" money NOT NULL,
|
|
77
|
+
"date" date NOT NULL,
|
|
78
|
+
"postedDate" date,
|
|
79
|
+
data jsonb NOT NULL,
|
|
80
|
+
replace_data jsonb DEFAULT NULL,
|
|
81
|
+
invoiced boolean DEFAULT FALSE NOT NULL,
|
|
82
|
+
emailed boolean DEFAULT FALSE NOT NULL,
|
|
83
|
+
type character varying(100) NOT NULL,
|
|
84
|
+
"famisInvoiceNumber" character varying(10) NOT NULL,
|
|
85
|
+
deleted timestamp with time zone,
|
|
86
|
+
"customerAccount" character varying(13) NOT NULL,
|
|
87
|
+
"sellingAccount" character varying(13) NOT NULL,
|
|
88
|
+
fingerprint character(10),
|
|
89
|
+
PRIMARY KEY("uid"),
|
|
90
|
+
UNIQUE("famisInvoiceNumber")
|
|
91
|
+
);
|
|
92
|
+
COMMENT ON COLUMN public.invoices.number IS 'iLabs generated invoice number';
|
|
93
|
+
CREATE INDEX "invoices_customerAccount" ON "public"."invoices" USING btree ("customerAccount");
|
|
94
|
+
CREATE INDEX "invoices_number" ON "public"."invoices" USING btree ("number");
|
|
95
|
+
CREATE INDEX "invoices_sellingAccount" ON "public"."invoices" USING btree ("sellingAccount");
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
CREATE TABLE public.users (
|
|
99
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
100
|
+
"userId" character varying(100) NOT NULL,
|
|
101
|
+
admin boolean DEFAULT FALSE NOT NULL,
|
|
102
|
+
role boolean DEFAULT FALSE NOT NULL,
|
|
103
|
+
"roleName" character varying(255),
|
|
104
|
+
"roleEmail" character varying(255),
|
|
105
|
+
deleted timestamp with time zone,
|
|
106
|
+
PRIMARY KEY("id"),
|
|
107
|
+
UNIQUE ("userId")
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
CREATE TABLE public.user_cores (
|
|
112
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
113
|
+
"coreId" integer NOT NULL,
|
|
114
|
+
"userId" integer NOT NULL,
|
|
115
|
+
email boolean DEFAULT FALSE NOT NULL,
|
|
116
|
+
PRIMARY KEY("id"),
|
|
117
|
+
FOREIGN KEY ("coreId") REFERENCES public.cores(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
118
|
+
FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
119
|
+
);
|
|
120
|
+
CREATE INDEX "user_cores_coreId" ON public.user_cores USING btree ("coreId");
|
|
121
|
+
CREATE INDEX "user_cores_userId" ON public.user_cores USING btree ("userId");
|
|
122
|
+
CREATE UNIQUE INDEX "user_cores_coreId_userId" ON user_cores ("coreId", "userId");
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
CREATE TABLE public.user_systems (
|
|
126
|
+
id integer GENERATED ALWAYS AS IDENTITY,
|
|
127
|
+
"systemId" integer NOT NULL,
|
|
128
|
+
"userId" integer NOT NULL,
|
|
129
|
+
email boolean DEFAULT FALSE NOT NULL,
|
|
130
|
+
PRIMARY KEY("id"),
|
|
131
|
+
FOREIGN KEY ("systemId") REFERENCES public.system(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
132
|
+
FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
133
|
+
);
|
|
134
|
+
CREATE INDEX "user_systems_systemId" ON public.user_systems USING btree ("systemId");
|
|
135
|
+
CREATE INDEX "user_systems_userId" ON public.user_systems USING btree ("userId");
|
|
136
|
+
CREATE UNIQUE INDEX "user_systems_systemId_userId" ON user_systems ("systemId", "userId");
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
ALTER TABLE public.codes OWNER TO dba;
|
|
140
|
+
ALTER TABLE public.cores OWNER TO dba;
|
|
141
|
+
ALTER TABLE public.core_accounts OWNER TO dba;
|
|
142
|
+
ALTER TABLE public.departments OWNER TO dba;
|
|
143
|
+
ALTER TABLE public.invoices OWNER TO dba;
|
|
144
|
+
ALTER TABLE public.users OWNER TO dba;
|
|
145
|
+
ALTER TABLE public.user_cores OWNER TO dba;
|
|
146
|
+
ALTER TABLE public.user_systems OWNER TO dba;
|
|
147
|
+
ALTER TABLE public.system OWNER TO dba;
|
|
148
|
+
|
|
149
|
+
GRANT SELECT ON public.codes, public.cores, public.core_accounts, public.departments, public.invoices,
|
|
150
|
+
public.users, public.user_cores, public.user_systems, public.system TO famis;
|
|
151
|
+
GRANT INSERT, UPDATE ON public.codes, public.cores, public.invoices, public.users,
|
|
152
|
+
public.user_cores, public.user_systems TO famis;
|
|
153
|
+
GRANT DELETE ON public.codes, public.user_cores, public.user_systems TO famis;
|
|
154
|
+
|
|
155
|
+
GRANT INSERT, TRUNCATE ON departments TO famisparser;
|