@opengis/pay 1.1.12 → 1.1.14

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.
Files changed (36) hide show
  1. package/module/pay/cls/billing.payment_status.json +8 -3
  2. package/module/pay/select/billing.subscription_id.sql +1 -0
  3. package/module/{pay → pay1}/card/billing.accounts.table/general_info.hbs +10 -10
  4. package/module/{pay → pay1}/card/billing.accounts.table/index.yml +15 -15
  5. package/module/{pay → pay1}/card/billing.accounts.table/users.hbs +11 -11
  6. package/module/{pay → pay1}/card/billing.payments.table/general_info.hbs +12 -12
  7. package/module/{pay → pay1}/card/billing.payments.table/index.yml +9 -9
  8. package/module/{pay → pay1}/card/billing.users.table/general_info.hbs +10 -10
  9. package/module/{pay → pay1}/card/billing.users.table/index.yml +9 -9
  10. package/module/pay1/cls/billing.payment_status.json +22 -0
  11. package/module/{pay → pay1}/form/billing.account_user.form.json +14 -14
  12. package/module/{pay → pay1}/form/billing.accounts.form.json +30 -30
  13. package/module/{pay → pay1}/form/billing.payment.form.json +22 -22
  14. package/module/{pay → pay1}/form/billing.users.form.json +38 -38
  15. package/module/{pay → pay1}/menu.json +24 -24
  16. package/module/pay1/pt/marketplace-service-payment-client-template.html +147 -0
  17. package/module/pay1/select/billing.account_id.sql +1 -0
  18. package/module/pay1/select/billing.service_id.sql +1 -0
  19. package/module/pay1/select/billing.subscription_id.sql +1 -0
  20. package/module/pay1/select/billing.user_id.sql +1 -0
  21. package/module/{pay → pay1}/table/billing.accounts.table.json +60 -60
  22. package/module/{pay → pay1}/table/billing.payments.table.json +67 -67
  23. package/module/{pay → pay1}/table/billing.users.table.json +70 -70
  24. package/package.json +2 -2
  25. package/plugin.js +18 -2
  26. package/server/migrations/1_users.sql +120 -120
  27. package/server/migrations/2_accounts.sql +59 -59
  28. package/server/migrations/3_utils.sql +73 -73
  29. package/server/migrations/4_subscriptions.sql +35 -35
  30. package/server/migrations/5_payments.sql +36 -36
  31. package/server/migrations/6_invoices.sql +54 -54
  32. package/server/plugins/cron.js +22 -0
  33. package/server/routes/payment.info.js +45 -0
  34. package/server/routes/portmone.redirect.js +17 -15
  35. package/server/routes/portmone.status.js +8 -4
  36. package/server/routes/utils/portmone.check.status.js +33 -0
@@ -1,121 +1,121 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.users();
4
- ALTER TABLE billing.users DROP CONSTRAINT if exists billing_user_id_pkey cascade;
5
-
6
- ALTER TABLE billing.users add column if not exists user_id text NOT NULL DEFAULT next_id();
7
- ALTER TABLE billing.users add column if not exists login text;
8
- ALTER TABLE billing.users add column if not exists password text NOT NULL DEFAULT ''::text;
9
- ALTER TABLE billing.users add column if not exists user_name text;
10
- ALTER TABLE billing.users add column if not exists sur_name text;
11
- ALTER TABLE billing.users add column if not exists father_name text;
12
- ALTER TABLE billing.users add column if not exists email text;
13
- ALTER TABLE billing.users add column if not exists phone text;
14
- ALTER TABLE billing.users add column if not exists avatar text;
15
- ALTER TABLE billing.users add column if not exists enabled boolean;
16
- ALTER TABLE billing.users add column if not exists user_personal_code text;
17
- ALTER TABLE billing.users add column if not exists last_activity_date timestamp without time zone;
18
- ALTER TABLE billing.users add column if not exists user_type text DEFAULT 'regular'::text;
19
- ALTER TABLE billing.users add column if not exists salt text;
20
- ALTER TABLE billing.users add column if not exists uid text;
21
- ALTER TABLE billing.users add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
22
- ALTER TABLE billing.users add column if not exists editor_id text;
23
- ALTER TABLE billing.users add column if not exists editor_date timestamp without time zone;
24
- ALTER TABLE billing.users add column if not exists files json;
25
-
26
- COMMENT ON TABLE billing.users IS 'Користувачі';
27
-
28
- COMMENT ON COLUMN billing.users.user_id IS 'ID користувача';
29
- COMMENT ON COLUMN billing.users.login IS 'Логін користувача';
30
- COMMENT ON COLUMN billing.users.password IS 'Пароль користувача';
31
- COMMENT ON COLUMN billing.users.user_name IS 'Ім''я користувача';
32
- COMMENT ON COLUMN billing.users.sur_name IS 'Прізвище користувача';
33
- COMMENT ON COLUMN billing.users.father_name IS 'По-батькові користувача';
34
- COMMENT ON COLUMN billing.users.email IS 'Ел. пошта користувача';
35
- COMMENT ON COLUMN billing.users.phone IS 'Номер телефону користувача';
36
- COMMENT ON COLUMN billing.users.avatar IS 'Аватар';
37
- COMMENT ON COLUMN billing.users.enabled IS 'On / Off';
38
- COMMENT ON COLUMN billing.users.last_activity_date IS 'Дата останньої активності';
39
- COMMENT ON COLUMN billing.users.user_type IS 'Тип користувача';
40
- COMMENT ON COLUMN billing.users.salt IS 'Сіль';
41
-
42
- CREATE EXTENSION if not exists pgcrypto SCHEMA public VERSION "1.3";
43
- CREATE OR REPLACE FUNCTION billing.crypt(text, text) RETURNS text AS '$libdir/pgcrypto', 'pg_crypt' LANGUAGE c IMMUTABLE STRICT COST 1;
44
-
45
- CREATE OR REPLACE FUNCTION billing.insert_update_user_before()
46
- RETURNS trigger AS
47
-
48
- $BODY$
49
- DECLARE
50
-
51
- iterations int;
52
- hash character varying;
53
-
54
- BEGIN
55
-
56
- if(TG_OP='INSERT' or (TG_OP='UPDATE' and new.password<>old.password)) then
57
- if(char_length(new.password) <> 0 and char_length(new.password) < 8) then
58
- --raise exception 'password must be longer than 8 characters';
59
- end if;
60
- new.salt=md5(now()::text);
61
- --raise exception '%','change pass';
62
- if(new.salt ='') then
63
- new.salt=gen_salt('md5');
64
- end if;
65
- iterations = 10;
66
- hash='';
67
-
68
- loop
69
- if iterations=0 then
70
- exit;
71
- end if;
72
- hash = md5(new.password||hash||new.salt);
73
- iterations=iterations-1;
74
- end loop;
75
- new.password=billing.crypt(hash,new.salt);
76
-
77
- end if;
78
- RETURN new;
79
- END
80
- $BODY$
81
-
82
- LANGUAGE plpgsql VOLATILE COST 100;
83
-
84
- DROP TRIGGER if exists insert_update_user_before on billing.users;
85
- CREATE TRIGGER insert_update_user_before BEFORE INSERT OR UPDATE ON billing.users FOR EACH ROW
86
- EXECUTE PROCEDURE billing.insert_update_user_before();
87
-
88
- CREATE TABLE if not exists billing.users_social_auth();
89
- ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_usa_id_pkey cascade;
90
- ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_user_id_fkey cascade;
91
-
92
- CREATE TABLE if not exists billing.users_social_auth();
93
- ALTER TABLE billing.users_social_auth add column if not exists usa_id text NOT NULL DEFAULT next_id();
94
- ALTER TABLE billing.users_social_auth add column if not exists user_id text;
95
- ALTER TABLE billing.users_social_auth add column if not exists user_name text;
96
- ALTER TABLE billing.users_social_auth add column if not exists sur_name text;
97
- ALTER TABLE billing.users_social_auth add column if not exists email text;
98
- ALTER TABLE billing.users_social_auth add column if not exists city text;
99
- ALTER TABLE billing.users_social_auth add column if not exists phone text;
100
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_id text;
101
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_type text;
102
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_code text;
103
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_obj json;
104
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_date timestamp without time zone;
105
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_softpro_code text;
106
- ALTER TABLE billing.users_social_auth add column if not exists enabled boolean;
107
- ALTER TABLE billing.users_social_auth add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
108
- ALTER TABLE billing.users_social_auth add column if not exists editor_date timestamp without time zone;
109
- ALTER TABLE billing.users_social_auth add column if not exists uid text;
110
- ALTER TABLE billing.users_social_auth add column if not exists editor_id text;
111
- ALTER TABLE billing.users_social_auth add column if not exists files json;
112
- ALTER TABLE billing.users_social_auth add column if not exists lang text;
113
- ALTER TABLE billing.users_social_auth add column if not exists social_auth_url text;
114
-
115
- COMMENT ON TABLE billing.users_social_auth IS 'Авторизація користувачів через соц. мережі';
116
- COMMENT ON COLUMN billing.users_social_auth.user_id IS 'ID користувача';
117
-
118
- ALTER TABLE billing.users add CONSTRAINT billing_user_id_pkey PRIMARY KEY (user_id);
119
- ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_usa_id_pkey PRIMARY KEY (usa_id);
120
- ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_user_id_fkey FOREIGN KEY (user_id)
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.users();
4
+ ALTER TABLE billing.users DROP CONSTRAINT if exists billing_user_id_pkey cascade;
5
+
6
+ ALTER TABLE billing.users add column if not exists user_id text NOT NULL DEFAULT next_id();
7
+ ALTER TABLE billing.users add column if not exists login text;
8
+ ALTER TABLE billing.users add column if not exists password text NOT NULL DEFAULT ''::text;
9
+ ALTER TABLE billing.users add column if not exists user_name text;
10
+ ALTER TABLE billing.users add column if not exists sur_name text;
11
+ ALTER TABLE billing.users add column if not exists father_name text;
12
+ ALTER TABLE billing.users add column if not exists email text;
13
+ ALTER TABLE billing.users add column if not exists phone text;
14
+ ALTER TABLE billing.users add column if not exists avatar text;
15
+ ALTER TABLE billing.users add column if not exists enabled boolean;
16
+ ALTER TABLE billing.users add column if not exists user_personal_code text;
17
+ ALTER TABLE billing.users add column if not exists last_activity_date timestamp without time zone;
18
+ ALTER TABLE billing.users add column if not exists user_type text DEFAULT 'regular'::text;
19
+ ALTER TABLE billing.users add column if not exists salt text;
20
+ ALTER TABLE billing.users add column if not exists uid text;
21
+ ALTER TABLE billing.users add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
22
+ ALTER TABLE billing.users add column if not exists editor_id text;
23
+ ALTER TABLE billing.users add column if not exists editor_date timestamp without time zone;
24
+ ALTER TABLE billing.users add column if not exists files json;
25
+
26
+ COMMENT ON TABLE billing.users IS 'Користувачі';
27
+
28
+ COMMENT ON COLUMN billing.users.user_id IS 'ID користувача';
29
+ COMMENT ON COLUMN billing.users.login IS 'Логін користувача';
30
+ COMMENT ON COLUMN billing.users.password IS 'Пароль користувача';
31
+ COMMENT ON COLUMN billing.users.user_name IS 'Ім''я користувача';
32
+ COMMENT ON COLUMN billing.users.sur_name IS 'Прізвище користувача';
33
+ COMMENT ON COLUMN billing.users.father_name IS 'По-батькові користувача';
34
+ COMMENT ON COLUMN billing.users.email IS 'Ел. пошта користувача';
35
+ COMMENT ON COLUMN billing.users.phone IS 'Номер телефону користувача';
36
+ COMMENT ON COLUMN billing.users.avatar IS 'Аватар';
37
+ COMMENT ON COLUMN billing.users.enabled IS 'On / Off';
38
+ COMMENT ON COLUMN billing.users.last_activity_date IS 'Дата останньої активності';
39
+ COMMENT ON COLUMN billing.users.user_type IS 'Тип користувача';
40
+ COMMENT ON COLUMN billing.users.salt IS 'Сіль';
41
+
42
+ CREATE EXTENSION if not exists pgcrypto SCHEMA public VERSION "1.3";
43
+ CREATE OR REPLACE FUNCTION billing.crypt(text, text) RETURNS text AS '$libdir/pgcrypto', 'pg_crypt' LANGUAGE c IMMUTABLE STRICT COST 1;
44
+
45
+ CREATE OR REPLACE FUNCTION billing.insert_update_user_before()
46
+ RETURNS trigger AS
47
+
48
+ $BODY$
49
+ DECLARE
50
+
51
+ iterations int;
52
+ hash character varying;
53
+
54
+ BEGIN
55
+
56
+ if(TG_OP='INSERT' or (TG_OP='UPDATE' and new.password<>old.password)) then
57
+ if(char_length(new.password) <> 0 and char_length(new.password) < 8) then
58
+ --raise exception 'password must be longer than 8 characters';
59
+ end if;
60
+ new.salt=md5(now()::text);
61
+ --raise exception '%','change pass';
62
+ if(new.salt ='') then
63
+ new.salt=gen_salt('md5');
64
+ end if;
65
+ iterations = 10;
66
+ hash='';
67
+
68
+ loop
69
+ if iterations=0 then
70
+ exit;
71
+ end if;
72
+ hash = md5(new.password||hash||new.salt);
73
+ iterations=iterations-1;
74
+ end loop;
75
+ new.password=billing.crypt(hash,new.salt);
76
+
77
+ end if;
78
+ RETURN new;
79
+ END
80
+ $BODY$
81
+
82
+ LANGUAGE plpgsql VOLATILE COST 100;
83
+
84
+ DROP TRIGGER if exists insert_update_user_before on billing.users;
85
+ CREATE TRIGGER insert_update_user_before BEFORE INSERT OR UPDATE ON billing.users FOR EACH ROW
86
+ EXECUTE PROCEDURE billing.insert_update_user_before();
87
+
88
+ CREATE TABLE if not exists billing.users_social_auth();
89
+ ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_usa_id_pkey cascade;
90
+ ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_user_id_fkey cascade;
91
+
92
+ CREATE TABLE if not exists billing.users_social_auth();
93
+ ALTER TABLE billing.users_social_auth add column if not exists usa_id text NOT NULL DEFAULT next_id();
94
+ ALTER TABLE billing.users_social_auth add column if not exists user_id text;
95
+ ALTER TABLE billing.users_social_auth add column if not exists user_name text;
96
+ ALTER TABLE billing.users_social_auth add column if not exists sur_name text;
97
+ ALTER TABLE billing.users_social_auth add column if not exists email text;
98
+ ALTER TABLE billing.users_social_auth add column if not exists city text;
99
+ ALTER TABLE billing.users_social_auth add column if not exists phone text;
100
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_id text;
101
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_type text;
102
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_code text;
103
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_obj json;
104
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_date timestamp without time zone;
105
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_softpro_code text;
106
+ ALTER TABLE billing.users_social_auth add column if not exists enabled boolean;
107
+ ALTER TABLE billing.users_social_auth add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
108
+ ALTER TABLE billing.users_social_auth add column if not exists editor_date timestamp without time zone;
109
+ ALTER TABLE billing.users_social_auth add column if not exists uid text;
110
+ ALTER TABLE billing.users_social_auth add column if not exists editor_id text;
111
+ ALTER TABLE billing.users_social_auth add column if not exists files json;
112
+ ALTER TABLE billing.users_social_auth add column if not exists lang text;
113
+ ALTER TABLE billing.users_social_auth add column if not exists social_auth_url text;
114
+
115
+ COMMENT ON TABLE billing.users_social_auth IS 'Авторизація користувачів через соц. мережі';
116
+ COMMENT ON COLUMN billing.users_social_auth.user_id IS 'ID користувача';
117
+
118
+ ALTER TABLE billing.users add CONSTRAINT billing_user_id_pkey PRIMARY KEY (user_id);
119
+ ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_usa_id_pkey PRIMARY KEY (usa_id);
120
+ ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_user_id_fkey FOREIGN KEY (user_id)
121
121
  REFERENCES billing.users (user_id);
@@ -1,59 +1,59 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.accounts();
4
-
5
- ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_id_pkey cascade;
6
- ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_edrpou_unique cascade;
7
-
8
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_id text NOT NULL DEFAULT next_id();
9
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_name text NOT NULL;
10
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_edrpou text;
11
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_email text;
12
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
13
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
14
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS uid text NOT NULL;
15
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_id text;
16
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
17
- ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS files json;
18
-
19
- COMMENT ON TABLE billing.accounts IS 'Акаунти';
20
- COMMENT ON COLUMN billing.accounts.account_id IS 'ID';
21
- COMMENT ON COLUMN billing.accounts.account_name IS 'Назва';
22
- COMMENT ON COLUMN billing.accounts.account_edrpou IS 'Код ЄДРПОУ';
23
- COMMENT ON COLUMN billing.accounts.enabled IS 'On / Off';
24
-
25
- CREATE TABLE IF NOT EXISTS billing.account_user();
26
-
27
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_au_id_pkey cascade;
28
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_fkey cascade;
29
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_user_id_fkey;
30
- ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_user_id_unique;
31
-
32
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS au_id text NOT NULL DEFAULT next_id();
33
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS account_id text NOT NULL;
34
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS user_id text NOT NULL;
35
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
36
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS uid text NOT NULL;
37
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_id text;
38
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
39
- ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS files json;
40
-
41
- COMMENT ON TABLE billing.account_user IS 'Відношення акаунтів та користувачів';
42
- COMMENT ON COLUMN billing.account_user.au_id IS 'ID';
43
- COMMENT ON COLUMN billing.account_user.account_id IS 'Акаунт організації';
44
- COMMENT ON COLUMN billing.account_user.user_id IS 'Акаунт користувача';
45
-
46
- CREATE INDEX if not exists billing_account_user_account_id_btree_idx ON billing.account_user USING btree (account_id COLLATE pg_catalog."default");
47
- CREATE INDEX if not exists billing_account_user_account_id_trgm_idx ON billing.account_user USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
48
- CREATE INDEX if not exists billing_account_user_user_id_btree_idx ON billing.account_user USING btree (user_id COLLATE pg_catalog."default");
49
- CREATE INDEX if not exists billing_account_user_user_id_trgm_idx ON billing.account_user USING gin (user_id COLLATE pg_catalog."default" gin_trgm_ops);
50
-
51
- ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_id_pkey PRIMARY KEY (account_id);
52
- ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_edrpou_unique UNIQUE (account_edrpou);
53
-
54
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_au_id_pkey PRIMARY KEY (au_id);
55
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_fkey FOREIGN KEY (account_id)
56
- REFERENCES billing.accounts (account_id);
57
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_user_id_fkey FOREIGN KEY (user_id)
58
- REFERENCES billing.users (user_id);
59
- ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_user_id_unique UNIQUE (account_id,user_id);
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.accounts();
4
+
5
+ ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_id_pkey cascade;
6
+ ALTER TABLE billing.accounts DROP CONSTRAINT if exists billing_account_account_edrpou_unique cascade;
7
+
8
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_id text NOT NULL DEFAULT next_id();
9
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_name text NOT NULL;
10
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_edrpou text;
11
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS account_email text;
12
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
13
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
14
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS uid text NOT NULL;
15
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_id text;
16
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
17
+ ALTER TABLE billing.accounts ADD COLUMN IF NOT EXISTS files json;
18
+
19
+ COMMENT ON TABLE billing.accounts IS 'Акаунти';
20
+ COMMENT ON COLUMN billing.accounts.account_id IS 'ID';
21
+ COMMENT ON COLUMN billing.accounts.account_name IS 'Назва';
22
+ COMMENT ON COLUMN billing.accounts.account_edrpou IS 'Код ЄДРПОУ';
23
+ COMMENT ON COLUMN billing.accounts.enabled IS 'On / Off';
24
+
25
+ CREATE TABLE IF NOT EXISTS billing.account_user();
26
+
27
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_au_id_pkey cascade;
28
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_fkey cascade;
29
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_user_id_fkey;
30
+ ALTER TABLE billing.account_user DROP CONSTRAINT if exists billing_account_user_account_id_user_id_unique;
31
+
32
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS au_id text NOT NULL DEFAULT next_id();
33
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS account_id text NOT NULL;
34
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS user_id text NOT NULL;
35
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
36
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS uid text NOT NULL;
37
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_id text;
38
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
39
+ ALTER TABLE billing.account_user ADD COLUMN IF NOT EXISTS files json;
40
+
41
+ COMMENT ON TABLE billing.account_user IS 'Відношення акаунтів та користувачів';
42
+ COMMENT ON COLUMN billing.account_user.au_id IS 'ID';
43
+ COMMENT ON COLUMN billing.account_user.account_id IS 'Акаунт організації';
44
+ COMMENT ON COLUMN billing.account_user.user_id IS 'Акаунт користувача';
45
+
46
+ CREATE INDEX if not exists billing_account_user_account_id_btree_idx ON billing.account_user USING btree (account_id COLLATE pg_catalog."default");
47
+ CREATE INDEX if not exists billing_account_user_account_id_trgm_idx ON billing.account_user USING gin (account_id COLLATE pg_catalog."default" gin_trgm_ops);
48
+ CREATE INDEX if not exists billing_account_user_user_id_btree_idx ON billing.account_user USING btree (user_id COLLATE pg_catalog."default");
49
+ CREATE INDEX if not exists billing_account_user_user_id_trgm_idx ON billing.account_user USING gin (user_id COLLATE pg_catalog."default" gin_trgm_ops);
50
+
51
+ ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_id_pkey PRIMARY KEY (account_id);
52
+ ALTER TABLE billing.accounts ADD CONSTRAINT billing_account_account_edrpou_unique UNIQUE (account_edrpou);
53
+
54
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_au_id_pkey PRIMARY KEY (au_id);
55
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_fkey FOREIGN KEY (account_id)
56
+ REFERENCES billing.accounts (account_id);
57
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_user_id_fkey FOREIGN KEY (user_id)
58
+ REFERENCES billing.users (user_id);
59
+ ALTER TABLE billing.account_user ADD CONSTRAINT billing_account_user_account_id_user_id_unique UNIQUE (account_id,user_id);
@@ -1,74 +1,74 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE IF NOT EXISTS billing.products();
4
- ALTER TABLE billing.products DROP CONSTRAINT IF EXISTS billing_product_id_pkey CASCADE;
5
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS product_id text not null default next_id();
6
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS name text not null;
7
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS description text;
8
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS price_type text;
9
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS image text;
10
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
11
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
12
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS uid text NOT NULL;
13
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_id text;
14
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
15
- ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS files json;
16
-
17
- CREATE TABLE IF NOT EXISTS billing.plans();
18
- ALTER TABLE billing.plans DROP CONSTRAINT IF EXISTS billing_plan_id_pkey CASCADE;
19
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS plan_id text not null default next_id();
20
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS name text not null;
21
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
22
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS multiplier numeric not null default 0;
23
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
24
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
25
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_id text;
26
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
27
- ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS files json;
28
-
29
- CREATE TABLE IF NOT EXISTS billing.product_plans();
30
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_pkey CASCADE;
31
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_product_id_fkey CASCADE;
32
- ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_fkey CASCADE;
33
-
34
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_plan_id text not null default next_id();
35
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_id text not null;
36
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS plan_id text not null;
37
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS price numeric not null default 0;
38
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS max_unit numeric not null default 1;
39
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS enabled boolean default true;
40
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
41
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
42
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_id text;
43
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
44
- ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS files json;
45
-
46
- ALTER TABLE billing.products ADD CONSTRAINT billing_product_id_pkey PRIMARY KEY (product_id);
47
- ALTER TABLE billing.plans ADD CONSTRAINT billing_plan_id_pkey PRIMARY KEY (plan_id);
48
-
49
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_pkey PRIMARY KEY (product_plan_id);
50
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_product_id_fkey FOREIGN KEY (product_id)
51
- REFERENCES billing.products (product_id);
52
- ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_fkey FOREIGN KEY (plan_id)
53
- REFERENCES billing.plans (plan_id);
54
-
55
- COMMENT ON TABLE billing.products IS 'Товари (послуги)';
56
- COMMENT ON COLUMN billing.products.product_id IS 'ID';
57
- COMMENT ON COLUMN billing.products.name IS 'Назва';
58
- COMMENT ON COLUMN billing.products.description IS 'Опис';
59
- COMMENT ON COLUMN billing.products.price_type IS 'Тип плати (account/unit)';
60
- COMMENT ON COLUMN billing.products.image is 'Зображення';
61
- COMMENT ON COLUMN billing.products.enabled is 'On / Off';
62
-
63
- COMMENT ON TABLE billing.plans IS 'Перелік тарифних планів';
64
- COMMENT ON COLUMN billing.plans.plan_id IS 'ID';
65
- COMMENT ON COLUMN billing.plans.name IS 'Назва';
66
- COMMENT ON COLUMN billing.plans.enabled is 'On / Off';
67
-
68
- COMMENT ON TABLE billing.product_plans IS 'Відношення планів та товарів (послуг)';
69
- COMMENT ON COLUMN billing.product_plans.product_plan_id is 'ID';
70
- COMMENT ON COLUMN billing.product_plans.product_id is 'ID товару (послуги)';
71
- COMMENT ON COLUMN billing.product_plans.plan_id is 'ID тарифного плану';
72
- COMMENT ON COLUMN billing.product_plans.price is 'Вартість';
73
- COMMENT ON COLUMN billing.product_plans.max_unit is 'Максимальна кількість користувачів в межах тарифу';
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE IF NOT EXISTS billing.products();
4
+ ALTER TABLE billing.products DROP CONSTRAINT IF EXISTS billing_product_id_pkey CASCADE;
5
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS product_id text not null default next_id();
6
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS name text not null;
7
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS description text;
8
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS price_type text;
9
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS image text;
10
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
11
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
12
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS uid text NOT NULL;
13
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_id text;
14
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
15
+ ALTER TABLE billing.products ADD COLUMN IF NOT EXISTS files json;
16
+
17
+ CREATE TABLE IF NOT EXISTS billing.plans();
18
+ ALTER TABLE billing.plans DROP CONSTRAINT IF EXISTS billing_plan_id_pkey CASCADE;
19
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS plan_id text not null default next_id();
20
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS name text not null;
21
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS enabled boolean not null default true;
22
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS multiplier numeric not null default 0;
23
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
24
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
25
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_id text;
26
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
27
+ ALTER TABLE billing.plans ADD COLUMN IF NOT EXISTS files json;
28
+
29
+ CREATE TABLE IF NOT EXISTS billing.product_plans();
30
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_pkey CASCADE;
31
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_product_id_fkey CASCADE;
32
+ ALTER TABLE billing.product_plans DROP CONSTRAINT IF EXISTS billing_product_plan_id_fkey CASCADE;
33
+
34
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_plan_id text not null default next_id();
35
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS product_id text not null;
36
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS plan_id text not null;
37
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS price numeric not null default 0;
38
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS max_unit numeric not null default 1;
39
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS enabled boolean default true;
40
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
41
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS uid text NOT NULL;
42
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_id text;
43
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
44
+ ALTER TABLE billing.product_plans ADD COLUMN IF NOT EXISTS files json;
45
+
46
+ ALTER TABLE billing.products ADD CONSTRAINT billing_product_id_pkey PRIMARY KEY (product_id);
47
+ ALTER TABLE billing.plans ADD CONSTRAINT billing_plan_id_pkey PRIMARY KEY (plan_id);
48
+
49
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_pkey PRIMARY KEY (product_plan_id);
50
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_product_id_fkey FOREIGN KEY (product_id)
51
+ REFERENCES billing.products (product_id);
52
+ ALTER TABLE billing.product_plans ADD CONSTRAINT billing_product_plan_id_fkey FOREIGN KEY (plan_id)
53
+ REFERENCES billing.plans (plan_id);
54
+
55
+ COMMENT ON TABLE billing.products IS 'Товари (послуги)';
56
+ COMMENT ON COLUMN billing.products.product_id IS 'ID';
57
+ COMMENT ON COLUMN billing.products.name IS 'Назва';
58
+ COMMENT ON COLUMN billing.products.description IS 'Опис';
59
+ COMMENT ON COLUMN billing.products.price_type IS 'Тип плати (account/unit)';
60
+ COMMENT ON COLUMN billing.products.image is 'Зображення';
61
+ COMMENT ON COLUMN billing.products.enabled is 'On / Off';
62
+
63
+ COMMENT ON TABLE billing.plans IS 'Перелік тарифних планів';
64
+ COMMENT ON COLUMN billing.plans.plan_id IS 'ID';
65
+ COMMENT ON COLUMN billing.plans.name IS 'Назва';
66
+ COMMENT ON COLUMN billing.plans.enabled is 'On / Off';
67
+
68
+ COMMENT ON TABLE billing.product_plans IS 'Відношення планів та товарів (послуг)';
69
+ COMMENT ON COLUMN billing.product_plans.product_plan_id is 'ID';
70
+ COMMENT ON COLUMN billing.product_plans.product_id is 'ID товару (послуги)';
71
+ COMMENT ON COLUMN billing.product_plans.plan_id is 'ID тарифного плану';
72
+ COMMENT ON COLUMN billing.product_plans.price is 'Вартість';
73
+ COMMENT ON COLUMN billing.product_plans.max_unit is 'Максимальна кількість користувачів в межах тарифу';
74
74
  COMMENT ON COLUMN billing.product_plans.enabled is 'On / Off';
@@ -1,36 +1,36 @@
1
- create schema if not exists billing;
2
-
3
- CREATE TABLE if not exists billing.subscriptions();
4
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_subscription_id_pkey cascade;
5
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_account_id_fkey cascade;
6
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_product_id_fkey cascade;
7
- alter table billing.subscriptions drop constraint if exists billing_subscriptions_plan_id_fkey cascade;
8
-
9
- alter table billing.subscriptions add column if not exists subscription_id text not null default next_id();
10
- alter table billing.subscriptions add column if not exists account_id text not null;
11
- alter table billing.subscriptions add column if not exists product_id text not null;
12
- alter table billing.subscriptions add column if not exists product_plan_id text not null;
13
- alter table billing.subscriptions add column if not exists is_trial boolean not null default false;
14
- alter table billing.subscriptions add column if not exists start_date date not null default CURRENT_DATE;
15
- alter table billing.subscriptions add column if not exists cdate timestamp without time zone default date_trunc('seconds'::text, now());
16
- alter table billing.subscriptions add column if not exists uid text not null;
17
- alter table billing.subscriptions add column if not exists editor_id text;
18
- alter table billing.subscriptions add column if not exists editor_date timestamp without time zone;
19
- alter table billing.subscriptions add column if not exists files json;
20
-
21
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_subscription_id_pkey PRIMARY KEY(subscription_id);
22
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_account_id_fkey FOREIGN KEY(account_id)
23
- REFERENCES billing.accounts (account_id);
24
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_product_id_fkey FOREIGN KEY(product_id)
25
- REFERENCES billing.products (product_id);
26
- ALTER TABLE billing.subscriptions add constraint billing_subscriptions_plan_id_fkey FOREIGN KEY(product_plan_id)
27
- REFERENCES billing.product_plans (product_plan_id);
28
-
29
- COMMENT ON TABLE billing.subscriptions IS 'Підписки';
30
- COMMENT ON COLUMN billing.subscriptions.subscription_id IS 'ID';
31
-
32
- COMMENT ON COLUMN billing.subscriptions.account_id IS 'ID акаунту';
33
- COMMENT ON COLUMN billing.subscriptions.product_id IS 'ID товару';
34
- COMMENT ON COLUMN billing.subscriptions.product_plan_id IS 'ID тарифного плану';
35
- COMMENT ON COLUMN billing.subscriptions.is_trial IS 'Випробувальний строк';
1
+ create schema if not exists billing;
2
+
3
+ CREATE TABLE if not exists billing.subscriptions();
4
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_subscription_id_pkey cascade;
5
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_account_id_fkey cascade;
6
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_product_id_fkey cascade;
7
+ alter table billing.subscriptions drop constraint if exists billing_subscriptions_plan_id_fkey cascade;
8
+
9
+ alter table billing.subscriptions add column if not exists subscription_id text not null default next_id();
10
+ alter table billing.subscriptions add column if not exists account_id text not null;
11
+ alter table billing.subscriptions add column if not exists product_id text not null;
12
+ alter table billing.subscriptions add column if not exists product_plan_id text not null;
13
+ alter table billing.subscriptions add column if not exists is_trial boolean not null default false;
14
+ alter table billing.subscriptions add column if not exists start_date date not null default CURRENT_DATE;
15
+ alter table billing.subscriptions add column if not exists cdate timestamp without time zone default date_trunc('seconds'::text, now());
16
+ alter table billing.subscriptions add column if not exists uid text not null;
17
+ alter table billing.subscriptions add column if not exists editor_id text;
18
+ alter table billing.subscriptions add column if not exists editor_date timestamp without time zone;
19
+ alter table billing.subscriptions add column if not exists files json;
20
+
21
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_subscription_id_pkey PRIMARY KEY(subscription_id);
22
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_account_id_fkey FOREIGN KEY(account_id)
23
+ REFERENCES billing.accounts (account_id);
24
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_product_id_fkey FOREIGN KEY(product_id)
25
+ REFERENCES billing.products (product_id);
26
+ ALTER TABLE billing.subscriptions add constraint billing_subscriptions_plan_id_fkey FOREIGN KEY(product_plan_id)
27
+ REFERENCES billing.product_plans (product_plan_id);
28
+
29
+ COMMENT ON TABLE billing.subscriptions IS 'Підписки';
30
+ COMMENT ON COLUMN billing.subscriptions.subscription_id IS 'ID';
31
+
32
+ COMMENT ON COLUMN billing.subscriptions.account_id IS 'ID акаунту';
33
+ COMMENT ON COLUMN billing.subscriptions.product_id IS 'ID товару';
34
+ COMMENT ON COLUMN billing.subscriptions.product_plan_id IS 'ID тарифного плану';
35
+ COMMENT ON COLUMN billing.subscriptions.is_trial IS 'Випробувальний строк';
36
36
  COMMENT ON COLUMN billing.subscriptions.start_date IS 'Дата початку дії підписки';