@opengis/fastify-table 1.1.78 → 1.1.79

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 (77) hide show
  1. package/index.js +76 -76
  2. package/package.json +45 -45
  3. package/server/migrations/0.sql +80 -80
  4. package/server/migrations/cls.sql +39 -39
  5. package/server/migrations/context.sql +95 -0
  6. package/server/migrations/properties.sql +144 -144
  7. package/server/migrations/roles.sql +179 -175
  8. package/server/migrations/users.sql +170 -170
  9. package/server/plugins/cron/funcs/addCron.js +130 -130
  10. package/server/plugins/cron/index.js +6 -6
  11. package/server/plugins/crud/funcs/dataDelete.js +21 -21
  12. package/server/plugins/crud/funcs/dataInsert.js +38 -38
  13. package/server/plugins/crud/funcs/dataUpdate.js +50 -50
  14. package/server/plugins/crud/funcs/getAccess.js +48 -48
  15. package/server/plugins/crud/funcs/getOpt.js +13 -13
  16. package/server/plugins/crud/funcs/setOpt.js +21 -21
  17. package/server/plugins/crud/funcs/setToken.js +44 -44
  18. package/server/plugins/crud/funcs/utils/getFolder.js +10 -10
  19. package/server/plugins/crud/funcs/utils/logChanges.js +62 -62
  20. package/server/plugins/crud/index.js +23 -23
  21. package/server/plugins/hook/index.js +8 -8
  22. package/server/plugins/logger/errorStatus.js +19 -19
  23. package/server/plugins/logger/index.js +21 -21
  24. package/server/plugins/migration/funcs/exec.migrations.js +79 -79
  25. package/server/plugins/migration/index.js +7 -7
  26. package/server/plugins/pg/funcs/getMeta.js +28 -28
  27. package/server/plugins/pg/funcs/getPG.js +33 -33
  28. package/server/plugins/pg/pgClients.js +21 -21
  29. package/server/plugins/policy/funcs/checkPolicy.js +92 -92
  30. package/server/plugins/policy/funcs/checkXSS.js +1 -1
  31. package/server/plugins/policy/index.js +12 -12
  32. package/server/plugins/policy/sqlInjection.js +33 -33
  33. package/server/plugins/redis/client.js +8 -8
  34. package/server/plugins/redis/funcs/redisClients.js +3 -3
  35. package/server/plugins/redis/index.js +17 -17
  36. package/server/plugins/table/funcs/addTemplateDir.js +8 -8
  37. package/server/plugins/table/funcs/getFilterSQL/index.js +96 -96
  38. package/server/plugins/table/funcs/getFilterSQL/util/formatValue.js +170 -170
  39. package/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
  40. package/server/plugins/table/funcs/getFilterSQL/util/getFilterQuery.js +66 -66
  41. package/server/plugins/table/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
  42. package/server/plugins/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
  43. package/server/plugins/table/funcs/getSelect.js +19 -19
  44. package/server/plugins/table/funcs/getSelectMeta.js +60 -60
  45. package/server/plugins/table/funcs/getTemplates.js +19 -19
  46. package/server/plugins/table/funcs/gisIRColumn.js +72 -72
  47. package/server/plugins/table/funcs/loadTemplate.js +1 -1
  48. package/server/plugins/table/funcs/loadTemplatePath.js +1 -1
  49. package/server/plugins/table/funcs/metaFormat/getSelectVal.js +38 -22
  50. package/server/plugins/table/funcs/metaFormat/index.js +31 -30
  51. package/server/plugins/table/funcs/userTemplateDir.js +1 -1
  52. package/server/plugins/table/index.js +13 -13
  53. package/server/plugins/util/funcs/eventStream.js +28 -28
  54. package/server/plugins/util/index.js +7 -7
  55. package/server/routes/cron/index.js +14 -14
  56. package/server/routes/crud/controllers/deleteCrud.js +36 -36
  57. package/server/routes/crud/controllers/insert.js +80 -80
  58. package/server/routes/crud/controllers/table.js +91 -91
  59. package/server/routes/crud/controllers/update.js +82 -82
  60. package/server/routes/crud/index.js +21 -21
  61. package/server/routes/logger/controllers/logger.file.js +92 -92
  62. package/server/routes/logger/controllers/utils/checkUserAccess.js +19 -19
  63. package/server/routes/logger/controllers/utils/getRootDir.js +26 -26
  64. package/server/routes/logger/index.js +17 -17
  65. package/server/routes/properties/controllers/properties.add.js +55 -55
  66. package/server/routes/properties/controllers/properties.get.js +17 -17
  67. package/server/routes/properties/index.js +16 -16
  68. package/server/routes/table/controllers/data.js +144 -144
  69. package/server/routes/table/controllers/filter.js +60 -60
  70. package/server/routes/table/controllers/form.js +42 -42
  71. package/server/routes/table/controllers/search.js +74 -74
  72. package/server/routes/table/controllers/suggest.js +84 -84
  73. package/server/routes/table/index.js +28 -28
  74. package/server/routes/table/schema.js +64 -64
  75. package/server/routes/util/controllers/status.monitor.js +8 -8
  76. package/server/routes/util/index.js +11 -11
  77. package/utils.js +122 -122
package/index.js CHANGED
@@ -1,76 +1,76 @@
1
- import path from 'node:path';
2
- import fp from 'fastify-plugin';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- import config from './config.js';
6
-
7
- // plugins
8
- import cronPlugin from './server/plugins/cron/index.js';
9
- import crudPlugin from './server/plugins/crud/index.js';
10
- // hook, logger, migration - utils only
11
- import pgPlugin from './server/plugins/pg/index.js';
12
- import policyPlugin from './server/plugins/policy/index.js';
13
- import redisPlugin from './server/plugins/redis/index.js';
14
- import tablePlugin from './server/plugins/table/index.js';
15
- import utilPlugin from './server/plugins/util/index.js';
16
- import loggerPlugin from './server/plugins/logger/index.js';
17
-
18
- // routes
19
- import cronRoutes from './server/routes/cron/index.js';
20
- import crudRoutes from './server/routes/crud/index.js';
21
- import loggerRoutes from './server/routes/logger/index.js';
22
- import propertiesRoutes from './server/routes/properties/index.js';
23
- import tableRoutes from './server/routes/table/index.js';
24
- import utilRoutes from './server/routes/util/index.js';
25
-
26
- import {
27
- addTemplateDir, execMigrations,
28
- } from './utils.js';
29
-
30
- async function plugin(fastify, opt) {
31
- config.pg = opt.pg;
32
- config.redis = opt.redis;
33
- config.root = opt.root;
34
- config.mapServerRoot = opt.mapServerRoot;
35
-
36
- // independent npm start / unit test
37
- if (!fastify.config) {
38
- fastify.decorate('config', config);
39
- }
40
-
41
- fastify.register(import('@fastify/sensible'), {
42
- errorHandler: false,
43
- });
44
-
45
- fastify.register(import('@fastify/url-data'), {
46
- errorHandler: false,
47
- });
48
-
49
- fastify.register(import('@opengis/fastify-hb'));
50
-
51
- execMigrations().catch(err => console.log(err));
52
-
53
- // plugins / utils / funcs
54
- policyPlugin(fastify);
55
- redisPlugin(fastify);
56
- await pgPlugin(fastify, opt);
57
- tablePlugin(fastify, opt);
58
- crudPlugin(fastify, opt);
59
- utilPlugin(fastify, opt);
60
- cronPlugin(fastify, opt);
61
- loggerPlugin(fastify, opt);
62
-
63
- // routes / api
64
- cronRoutes(fastify, opt);
65
- crudRoutes(fastify, opt);
66
- loggerRoutes(fastify, opt);
67
- propertiesRoutes(fastify, opt);
68
- tableRoutes(fastify, opt);
69
- utilRoutes(fastify, opt);
70
-
71
- // core templates && cls
72
- const filename = fileURLToPath(import.meta.url);
73
- const cwd = path.dirname(filename);
74
- addTemplateDir(path.join(cwd, 'module/core'));
75
- }
76
- export default fp(plugin);
1
+ import path from 'node:path';
2
+ import fp from 'fastify-plugin';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ import config from './config.js';
6
+
7
+ // plugins
8
+ import cronPlugin from './server/plugins/cron/index.js';
9
+ import crudPlugin from './server/plugins/crud/index.js';
10
+ // hook, logger, migration - utils only
11
+ import pgPlugin from './server/plugins/pg/index.js';
12
+ import policyPlugin from './server/plugins/policy/index.js';
13
+ import redisPlugin from './server/plugins/redis/index.js';
14
+ import tablePlugin from './server/plugins/table/index.js';
15
+ import utilPlugin from './server/plugins/util/index.js';
16
+ import loggerPlugin from './server/plugins/logger/index.js';
17
+
18
+ // routes
19
+ import cronRoutes from './server/routes/cron/index.js';
20
+ import crudRoutes from './server/routes/crud/index.js';
21
+ import loggerRoutes from './server/routes/logger/index.js';
22
+ import propertiesRoutes from './server/routes/properties/index.js';
23
+ import tableRoutes from './server/routes/table/index.js';
24
+ import utilRoutes from './server/routes/util/index.js';
25
+
26
+ import {
27
+ addTemplateDir, execMigrations,
28
+ } from './utils.js';
29
+
30
+ async function plugin(fastify, opt) {
31
+ config.pg = opt.pg;
32
+ config.redis = opt.redis;
33
+ config.root = opt.root;
34
+ config.mapServerRoot = opt.mapServerRoot;
35
+
36
+ // independent npm start / unit test
37
+ if (!fastify.config) {
38
+ fastify.decorate('config', config);
39
+ }
40
+
41
+ fastify.register(import('@fastify/sensible'), {
42
+ errorHandler: false,
43
+ });
44
+
45
+ fastify.register(import('@fastify/url-data'), {
46
+ errorHandler: false,
47
+ });
48
+
49
+ fastify.register(import('@opengis/fastify-hb'));
50
+
51
+ execMigrations().catch(err => console.log(err));
52
+
53
+ // plugins / utils / funcs
54
+ policyPlugin(fastify);
55
+ redisPlugin(fastify);
56
+ await pgPlugin(fastify, opt);
57
+ tablePlugin(fastify, opt);
58
+ crudPlugin(fastify, opt);
59
+ utilPlugin(fastify, opt);
60
+ cronPlugin(fastify, opt);
61
+ loggerPlugin(fastify, opt);
62
+
63
+ // routes / api
64
+ cronRoutes(fastify, opt);
65
+ crudRoutes(fastify, opt);
66
+ loggerRoutes(fastify, opt);
67
+ propertiesRoutes(fastify, opt);
68
+ tableRoutes(fastify, opt);
69
+ utilRoutes(fastify, opt);
70
+
71
+ // core templates && cls
72
+ const filename = fileURLToPath(import.meta.url);
73
+ const cwd = path.dirname(filename);
74
+ addTemplateDir(path.join(cwd, 'module/core'));
75
+ }
76
+ export default fp(plugin);
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "@opengis/fastify-table",
3
- "version": "1.1.78",
4
- "type": "module",
5
- "description": "core-plugins",
6
- "main": "index.js",
7
- "files": [
8
- "server/*",
9
- "index.js",
10
- "utils.js",
11
- "config.js"
12
- ],
13
- "scripts": {
14
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
15
- "test": "node --test",
16
- "docs:dev": "vitepress dev docs",
17
- "docs:build": "vitepress build docs",
18
- "docs:preview": "vitepress preview docs"
19
- },
20
- "dependencies": {
21
- "@fastify/sensible": "^5.0.0",
22
- "@fastify/url-data": "^5.4.0",
23
- "@opengis/fastify-hb": "^1.4.8",
24
- "fastify": "^4.26.1",
25
- "fastify-plugin": "^4.0.0",
26
- "ioredis": "^5.3.2",
27
- "nodemailer": "^6.5.0",
28
- "pg": "^8.11.3",
29
- "pino-abstract-transport": "^2.0.0"
30
- },
31
- "devDependencies": {
32
- "@panzoom/panzoom": "^4.5.1",
33
- "eslint": "^8.49.0",
34
- "eslint-config-airbnb": "^19.0.4",
35
- "markdown-it-abbr": "^2.0.0",
36
- "mermaid": "^10.9.3",
37
- "sass": "1.72.0",
38
- "vitepress": "^1.3.4",
39
- "vitepress-plugin-mermaid": "^2.0.16",
40
- "vitepress-plugin-tabs": "^0.5.0",
41
- "vitepress-sidebar": "^1.25.0",
42
- "vue": "^3.4.27"
43
- },
44
- "author": "Softpro",
45
- "license": "ISC"
1
+ {
2
+ "name": "@opengis/fastify-table",
3
+ "version": "1.1.79",
4
+ "type": "module",
5
+ "description": "core-plugins",
6
+ "main": "index.js",
7
+ "files": [
8
+ "server/*",
9
+ "index.js",
10
+ "utils.js",
11
+ "config.js"
12
+ ],
13
+ "scripts": {
14
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
15
+ "test": "node --test",
16
+ "docs:dev": "vitepress dev docs",
17
+ "docs:build": "vitepress build docs",
18
+ "docs:preview": "vitepress preview docs"
19
+ },
20
+ "dependencies": {
21
+ "@fastify/sensible": "^5.0.0",
22
+ "@fastify/url-data": "^5.4.0",
23
+ "@opengis/fastify-hb": "^1.4.8",
24
+ "fastify": "^4.26.1",
25
+ "fastify-plugin": "^4.0.0",
26
+ "ioredis": "^5.3.2",
27
+ "nodemailer": "^6.5.0",
28
+ "pg": "^8.11.3",
29
+ "pino-abstract-transport": "^2.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@panzoom/panzoom": "^4.5.1",
33
+ "eslint": "^8.49.0",
34
+ "eslint-config-airbnb": "^19.0.4",
35
+ "markdown-it-abbr": "^2.0.0",
36
+ "mermaid": "^10.9.3",
37
+ "sass": "1.72.0",
38
+ "vitepress": "^1.3.4",
39
+ "vitepress-plugin-mermaid": "^2.0.16",
40
+ "vitepress-plugin-tabs": "^0.5.0",
41
+ "vitepress-sidebar": "^1.25.0",
42
+ "vue": "^3.4.27"
43
+ },
44
+ "author": "Softpro",
45
+ "license": "ISC"
46
46
  }
@@ -1,80 +1,80 @@
1
- -- fix error if function exists and return type not text i.e bigint
2
-
3
- do $$
4
-
5
- declare
6
- m record;
7
- _pk text;
8
- _tables json;
9
- _returnType text;
10
-
11
- begin
12
-
13
- select format_type(p.prorettype, null) as return_type
14
- from pg_proc p
15
- where p.proname = 'next_id'
16
- and p.pronamespace = 'public'::regnamespace into _returnType;
17
-
18
- if (_returnType != 'text') then
19
- raise notice 'default reassign start: % -> text', _returnType;
20
-
21
- CREATE EXTENSION if not exists "uuid-ossp";
22
-
23
- SELECT json_object_agg(a.attrelid::regclass, a.attname)
24
- FROM pg_catalog.pg_attribute a
25
- LEFT JOIN pg_catalog.pg_attrdef d ON (a.attrelid, a.attnum) = (d.adrelid, d.adnum)
26
- WHERE NOT a.attisdropped -- no dropped (dead) columns
27
- AND a.attnum > 0 -- no system columns
28
- AND pg_get_expr(d.adbin, d.adrelid) = 'next_id()' into _tables;
29
-
30
- FOR m in (select json_object_keys(_tables) as table) loop
31
- _pk = _tables->>m.table;
32
- raise notice 'drop default: %,%', m.table, _pk;
33
- EXECUTE('alter table '|| m.table || ' alter column ' || _pk || ' set default null;');
34
- end loop;
35
-
36
- DROP FUNCTION IF EXISTS next_id();
37
-
38
- CREATE EXTENSION if not exists "uuid-ossp";
39
- ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
40
-
41
- CREATE OR REPLACE FUNCTION next_id()
42
- RETURNS text AS
43
- $BODY$
44
- DECLARE
45
-
46
- BEGIN
47
- return replace(public.uuid_generate_v4()::text, '-', '');
48
- END;
49
- $BODY$
50
- LANGUAGE plpgsql VOLATILE
51
- COST 100;
52
-
53
- FOR m in (select json_object_keys(_tables) as table) loop
54
- _pk = _tables->>m.table;
55
- raise notice 'reassign default: %, %', m.table, _pk;
56
- EXECUTE('alter table '|| m.table || ' alter column ' || _pk || ' set default next_id();');
57
- end loop;
58
-
59
- raise notice 'reassign default finish: %', _tables;
60
-
61
- else
62
- raise notice 'skip default reassign';
63
-
64
- CREATE EXTENSION if not exists "uuid-ossp";
65
- ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
66
-
67
- CREATE OR REPLACE FUNCTION next_id()
68
- RETURNS text AS
69
- $BODY$
70
- DECLARE
71
-
72
- BEGIN
73
- return replace(public.uuid_generate_v4()::text, '-', '');
74
- END;
75
- $BODY$
76
- LANGUAGE plpgsql VOLATILE
77
- COST 100;
78
- end if;
79
-
80
- end $$
1
+ -- fix error if function exists and return type not text i.e bigint
2
+
3
+ do $$
4
+
5
+ declare
6
+ m record;
7
+ _pk text;
8
+ _tables json;
9
+ _returnType text;
10
+
11
+ begin
12
+
13
+ select format_type(p.prorettype, null) as return_type
14
+ from pg_proc p
15
+ where p.proname = 'next_id'
16
+ and p.pronamespace = 'public'::regnamespace into _returnType;
17
+
18
+ if (_returnType != 'text') then
19
+ raise notice 'default reassign start: % -> text', _returnType;
20
+
21
+ CREATE EXTENSION if not exists "uuid-ossp";
22
+
23
+ SELECT json_object_agg(a.attrelid::regclass, a.attname)
24
+ FROM pg_catalog.pg_attribute a
25
+ LEFT JOIN pg_catalog.pg_attrdef d ON (a.attrelid, a.attnum) = (d.adrelid, d.adnum)
26
+ WHERE NOT a.attisdropped -- no dropped (dead) columns
27
+ AND a.attnum > 0 -- no system columns
28
+ AND pg_get_expr(d.adbin, d.adrelid) = 'next_id()' into _tables;
29
+
30
+ FOR m in (select json_object_keys(_tables) as table) loop
31
+ _pk = _tables->>m.table;
32
+ raise notice 'drop default: %,%', m.table, _pk;
33
+ EXECUTE('alter table '|| m.table || ' alter column ' || _pk || ' set default null;');
34
+ end loop;
35
+
36
+ DROP FUNCTION IF EXISTS next_id();
37
+
38
+ CREATE EXTENSION if not exists "uuid-ossp";
39
+ ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
40
+
41
+ CREATE OR REPLACE FUNCTION next_id()
42
+ RETURNS text AS
43
+ $BODY$
44
+ DECLARE
45
+
46
+ BEGIN
47
+ return replace(public.uuid_generate_v4()::text, '-', '');
48
+ END;
49
+ $BODY$
50
+ LANGUAGE plpgsql VOLATILE
51
+ COST 100;
52
+
53
+ FOR m in (select json_object_keys(_tables) as table) loop
54
+ _pk = _tables->>m.table;
55
+ raise notice 'reassign default: %, %', m.table, _pk;
56
+ EXECUTE('alter table '|| m.table || ' alter column ' || _pk || ' set default next_id();');
57
+ end loop;
58
+
59
+ raise notice 'reassign default finish: %', _tables;
60
+
61
+ else
62
+ raise notice 'skip default reassign';
63
+
64
+ CREATE EXTENSION if not exists "uuid-ossp";
65
+ ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
66
+
67
+ CREATE OR REPLACE FUNCTION next_id()
68
+ RETURNS text AS
69
+ $BODY$
70
+ DECLARE
71
+
72
+ BEGIN
73
+ return replace(public.uuid_generate_v4()::text, '-', '');
74
+ END;
75
+ $BODY$
76
+ LANGUAGE plpgsql VOLATILE
77
+ COST 100;
78
+ end if;
79
+
80
+ end $$
@@ -1,39 +1,39 @@
1
- create schema if not exists admin;
2
-
3
- CREATE TABLE if not exists admin.cls();
4
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS clsid text;
5
- ALTER TABLE admin.cls DROP CONSTRAINT IF EXISTS admin_cls_pkey;
6
- ALTER TABLE admin.cls DROP CONSTRAINT IF EXISTS admin_cls_unique;
7
-
8
- ALTER TABLE admin.cls ALTER COLUMN clsid SET NOT NULL;
9
- ALTER TABLE admin.cls ALTER COLUMN clsid SET DEFAULT next_id();
10
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS name text;
11
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS data text;
12
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS type text;
13
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS code text;
14
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS parent text;
15
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS ua text;
16
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS en text;
17
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS module text;
18
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS files json;
19
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS cdate timestamp without time zone;
20
- ALTER TABLE admin.cls ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
21
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS editor_id text;
22
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
23
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS uid text;
24
- ALTER TABLE admin.cls ALTER COLUMN uid SET NOT NULL;
25
- ALTER TABLE admin.cls ALTER COLUMN uid SET DEFAULT '1'::text;
26
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS icon text;
27
- ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS color text;
28
-
29
- ALTER TABLE admin.cls ADD CONSTRAINT admin_cls_pkey PRIMARY KEY (clsid);
30
- ALTER TABLE admin.cls ADD CONSTRAINT admin_cls_unique UNIQUE (code, parent);
31
-
32
- COMMENT ON COLUMN admin.cls.name IS 'Назва';
33
- COMMENT ON COLUMN admin.cls.type IS 'Тип';
34
- COMMENT ON COLUMN admin.cls.data IS 'SQL';
35
- COMMENT ON COLUMN admin.cls.code IS 'Код';
36
- COMMENT ON COLUMN admin.cls.parent IS 'Назва батьківського об''єкту';
37
- COMMENT ON COLUMN admin.cls.module IS 'Модуль';
38
- COMMENT ON COLUMN admin.cls.icon IS 'Іконка';
39
- COMMENT ON COLUMN admin.cls.color IS 'Колір';
1
+ create schema if not exists admin;
2
+
3
+ CREATE TABLE if not exists admin.cls();
4
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS clsid text;
5
+ ALTER TABLE admin.cls DROP CONSTRAINT IF EXISTS admin_cls_pkey;
6
+ ALTER TABLE admin.cls DROP CONSTRAINT IF EXISTS admin_cls_unique;
7
+
8
+ ALTER TABLE admin.cls ALTER COLUMN clsid SET NOT NULL;
9
+ ALTER TABLE admin.cls ALTER COLUMN clsid SET DEFAULT next_id();
10
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS name text;
11
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS data text;
12
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS type text;
13
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS code text;
14
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS parent text;
15
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS ua text;
16
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS en text;
17
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS module text;
18
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS files json;
19
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS cdate timestamp without time zone;
20
+ ALTER TABLE admin.cls ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
21
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS editor_id text;
22
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
23
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS uid text;
24
+ ALTER TABLE admin.cls ALTER COLUMN uid SET NOT NULL;
25
+ ALTER TABLE admin.cls ALTER COLUMN uid SET DEFAULT '1'::text;
26
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS icon text;
27
+ ALTER TABLE admin.cls ADD COLUMN IF NOT EXISTS color text;
28
+
29
+ ALTER TABLE admin.cls ADD CONSTRAINT admin_cls_pkey PRIMARY KEY (clsid);
30
+ ALTER TABLE admin.cls ADD CONSTRAINT admin_cls_unique UNIQUE (code, parent);
31
+
32
+ COMMENT ON COLUMN admin.cls.name IS 'Назва';
33
+ COMMENT ON COLUMN admin.cls.type IS 'Тип';
34
+ COMMENT ON COLUMN admin.cls.data IS 'SQL';
35
+ COMMENT ON COLUMN admin.cls.code IS 'Код';
36
+ COMMENT ON COLUMN admin.cls.parent IS 'Назва батьківського об''єкту';
37
+ COMMENT ON COLUMN admin.cls.module IS 'Модуль';
38
+ COMMENT ON COLUMN admin.cls.icon IS 'Іконка';
39
+ COMMENT ON COLUMN admin.cls.color IS 'Колір';
@@ -0,0 +1,95 @@
1
+ CREATE TABLE IF NOT EXISTS admin.rules();
2
+ ALTER TABLE admin.rules add column if not exists rule_id text;
3
+ ALTER TABLE admin.rules add column if not exists rule_type text;
4
+ ALTER TABLE admin.rules add column if not exists rule_name text;
5
+ ALTER TABLE admin.rules add column if not exists attr text;
6
+ ALTER TABLE admin.rules add column if not exists routes text[];
7
+ ALTER TABLE admin.rules add column if not exists uid text;
8
+ ALTER TABLE admin.rules add column if not exists cdate timestamp without time zone;
9
+ ALTER TABLE admin.rules add column if not exists rule_query text;
10
+ ALTER TABLE admin.rules add column if not exists cls text;
11
+ COMMENT ON COLUMN admin.rules.rule_type IS 'Тип повноваження';
12
+ COMMENT ON COLUMN admin.rules.rule_name IS 'Назва';
13
+ COMMENT ON COLUMN admin.rules.attr IS 'Атрибут';
14
+ COMMENT ON COLUMN admin.rules.routes IS 'Роути';
15
+ COMMENT ON COLUMN admin.rules.uid IS 'Хто створив';
16
+ COMMENT ON COLUMN admin.rules.cdate IS 'Дата створення';
17
+ COMMENT ON COLUMN admin.rules.rule_query IS 'Запит';
18
+ ALTER TABLE admin.rules ALTER COLUMN attr DROP NOT NULL;
19
+ ALTER TABLE admin.rules ALTER COLUMN cdate DROP NOT NULL;ALTER TABLE admin.rules ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
20
+ ALTER TABLE admin.rules ALTER COLUMN cls DROP NOT NULL;
21
+ ALTER TABLE admin.rules ALTER COLUMN routes DROP NOT NULL;
22
+ ALTER TABLE admin.rules ALTER COLUMN rule_id SET NOT NULL;ALTER TABLE admin.rules ALTER COLUMN rule_id SET DEFAULT next_id();
23
+ ALTER TABLE admin.rules ALTER COLUMN rule_name DROP NOT NULL;
24
+ ALTER TABLE admin.rules ALTER COLUMN rule_query DROP NOT NULL;
25
+ ALTER TABLE admin.rules ALTER COLUMN rule_type DROP NOT NULL;
26
+ ALTER TABLE admin.rules ALTER COLUMN uid DROP NOT NULL;
27
+
28
+
29
+ CREATE TABLE IF NOT EXISTS admin.accounts();
30
+ ALTER TABLE admin.accounts add column if not exists account_id text;
31
+ ALTER TABLE admin.accounts add column if not exists account_name text;
32
+ ALTER TABLE admin.accounts add column if not exists description text;
33
+ ALTER TABLE admin.accounts add column if not exists uid text;
34
+ ALTER TABLE admin.accounts add column if not exists cdate timestamp without time zone;
35
+ COMMENT ON COLUMN admin.accounts.account_name IS 'Назва';
36
+ COMMENT ON COLUMN admin.accounts.description IS 'Опис';
37
+ COMMENT ON COLUMN admin.accounts.uid IS 'Хто створив';
38
+ COMMENT ON COLUMN admin.accounts.cdate IS 'Дата створення';
39
+ ALTER TABLE admin.accounts ALTER COLUMN account_id SET NOT NULL;ALTER TABLE admin.accounts ALTER COLUMN account_id SET DEFAULT next_id();
40
+ ALTER TABLE admin.accounts ALTER COLUMN account_name DROP NOT NULL;
41
+ ALTER TABLE admin.accounts ALTER COLUMN cdate DROP NOT NULL;ALTER TABLE admin.accounts ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
42
+ ALTER TABLE admin.accounts ALTER COLUMN description DROP NOT NULL;
43
+ ALTER TABLE admin.accounts ALTER COLUMN uid DROP NOT NULL;
44
+
45
+
46
+ CREATE TABLE IF NOT EXISTS admin.account_users();
47
+ ALTER TABLE admin.account_users add column if not exists au_id text;
48
+ ALTER TABLE admin.account_users add column if not exists account_id text;
49
+ ALTER TABLE admin.account_users add column if not exists user_uid text;
50
+ ALTER TABLE admin.account_users add column if not exists uid text;
51
+ ALTER TABLE admin.account_users add column if not exists cdate timestamp without time zone;
52
+ COMMENT ON COLUMN admin.account_users.account_id IS 'id Організації';
53
+ COMMENT ON COLUMN admin.account_users.user_uid IS 'id Користувача';
54
+ COMMENT ON COLUMN admin.account_users.uid IS 'Хто створив';
55
+ COMMENT ON COLUMN admin.account_users.cdate IS 'Дата створення';
56
+ ALTER TABLE admin.account_users ALTER COLUMN account_id DROP NOT NULL;
57
+ ALTER TABLE admin.account_users ALTER COLUMN au_id SET NOT NULL;ALTER TABLE admin.account_users ALTER COLUMN au_id SET DEFAULT next_id();
58
+ ALTER TABLE admin.account_users ALTER COLUMN cdate DROP NOT NULL;ALTER TABLE admin.account_users ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
59
+ ALTER TABLE admin.account_users ALTER COLUMN uid DROP NOT NULL;
60
+ ALTER TABLE admin.account_users ALTER COLUMN user_uid DROP NOT NULL;
61
+
62
+
63
+ CREATE TABLE IF NOT EXISTS admin.account_grants();
64
+ ALTER TABLE admin.account_grants add column if not exists ag_id text;
65
+ ALTER TABLE admin.account_grants add column if not exists account_id text;
66
+ ALTER TABLE admin.account_grants add column if not exists rule_id text;
67
+ ALTER TABLE admin.account_grants add column if not exists routes text[];
68
+ ALTER TABLE admin.account_grants add column if not exists rule_values text[];
69
+ ALTER TABLE admin.account_grants add column if not exists grants_doc_id text;
70
+ ALTER TABLE admin.account_grants add column if not exists grant_scan text;
71
+ ALTER TABLE admin.account_grants add column if not exists expire_date date;
72
+ ALTER TABLE admin.account_grants add column if not exists actions text[];
73
+ ALTER TABLE admin.account_grants add column if not exists uid text;
74
+ ALTER TABLE admin.account_grants add column if not exists cdate timestamp without time zone;
75
+ COMMENT ON COLUMN admin.account_grants.account_id IS 'id Організації';
76
+ COMMENT ON COLUMN admin.account_grants.rule_id IS 'id Правила';
77
+ COMMENT ON COLUMN admin.account_grants.routes IS 'Роути';
78
+ COMMENT ON COLUMN admin.account_grants.rule_values IS 'Значення';
79
+ COMMENT ON COLUMN admin.account_grants.grants_doc_id IS 'id Документу';
80
+ COMMENT ON COLUMN admin.account_grants.grant_scan IS 'id Скану';
81
+ COMMENT ON COLUMN admin.account_grants.expire_date IS 'Дата закінчення дії дозволу';
82
+ COMMENT ON COLUMN admin.account_grants.actions IS 'Дії';
83
+ COMMENT ON COLUMN admin.account_grants.uid IS 'Хто створив';
84
+ COMMENT ON COLUMN admin.account_grants.cdate IS 'Дата створення';
85
+ ALTER TABLE admin.account_grants ALTER COLUMN account_id DROP NOT NULL;
86
+ ALTER TABLE admin.account_grants ALTER COLUMN actions DROP NOT NULL;
87
+ ALTER TABLE admin.account_grants ALTER COLUMN ag_id SET NOT NULL;ALTER TABLE admin.account_grants ALTER COLUMN ag_id SET DEFAULT next_id();
88
+ ALTER TABLE admin.account_grants ALTER COLUMN cdate DROP NOT NULL;ALTER TABLE admin.account_grants ALTER COLUMN cdate SET DEFAULT (now())::timestamp without time zone;
89
+ ALTER TABLE admin.account_grants ALTER COLUMN expire_date DROP NOT NULL;
90
+ ALTER TABLE admin.account_grants ALTER COLUMN grant_scan DROP NOT NULL;
91
+ ALTER TABLE admin.account_grants ALTER COLUMN grants_doc_id DROP NOT NULL;
92
+ ALTER TABLE admin.account_grants ALTER COLUMN routes DROP NOT NULL;
93
+ ALTER TABLE admin.account_grants ALTER COLUMN rule_id DROP NOT NULL;
94
+ ALTER TABLE admin.account_grants ALTER COLUMN rule_values DROP NOT NULL;
95
+ ALTER TABLE admin.account_grants ALTER COLUMN uid DROP NOT NULL;