@itleanchatbot/shared-models-js-postgres 3.1.11 → 3.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "3.1.11",
3
+ "version": "3.1.12",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,73 +1,95 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  module.exports = {
4
- up: async (queryInterface) => {
5
- await queryInterface.sequelize.transaction(async (transaction) => {
6
- await queryInterface.sequelize.query(
7
- `
8
- CREATE TABLE IF NOT EXISTS public."DialogNodeVisualLayouts" (
9
- "id" uuid NOT NULL,
10
- "EnterpriseId" uuid NOT NULL,
11
- "SkillId" uuid NOT NULL,
12
- "DialogNodeId" uuid NULL,
13
- "visualNodeId" varchar(255) NOT NULL,
14
- "view" varchar(32) NOT NULL DEFAULT 'macro',
15
- "x" numeric(12, 2) NOT NULL DEFAULT 0,
16
- "y" numeric(12, 2) NOT NULL DEFAULT 0,
17
- "width" numeric(12, 2) NOT NULL DEFAULT 260,
18
- "height" numeric(12, 2) NOT NULL DEFAULT 96,
19
- "collapsed" boolean NOT NULL DEFAULT false,
20
- "metadata" jsonb NOT NULL DEFAULT '{}'::jsonb,
21
- "createdAt" timestamp with time zone NOT NULL DEFAULT NOW(),
22
- "updatedAt" timestamp with time zone NOT NULL DEFAULT NOW(),
23
- CONSTRAINT "DialogNodeVisualLayouts_pkey" PRIMARY KEY ("id")
24
- );
25
- `,
26
- { transaction }
27
- );
4
+ async up(queryInterface, Sequelize) {
5
+ await queryInterface.createTable('DialogNodeVisualLayouts', {
6
+ id: {
7
+ type: Sequelize.UUID,
8
+ allowNull: false,
9
+ primaryKey: true,
10
+ defaultValue: Sequelize.UUIDV4,
11
+ },
12
+ EnterpriseId: {
13
+ type: Sequelize.UUID,
14
+ allowNull: false,
15
+ },
16
+ SkillId: {
17
+ type: Sequelize.UUID,
18
+ allowNull: false,
19
+ },
20
+ DialogNodeId: {
21
+ type: Sequelize.UUID,
22
+ allowNull: true,
23
+ },
24
+ visualNodeId: {
25
+ type: Sequelize.STRING(255),
26
+ allowNull: false,
27
+ },
28
+ view: {
29
+ type: Sequelize.STRING(32),
30
+ allowNull: false,
31
+ defaultValue: 'macro',
32
+ },
33
+ x: {
34
+ type: Sequelize.DECIMAL(12, 2),
35
+ allowNull: false,
36
+ defaultValue: 0,
37
+ },
38
+ y: {
39
+ type: Sequelize.DECIMAL(12, 2),
40
+ allowNull: false,
41
+ defaultValue: 0,
42
+ },
43
+ width: {
44
+ type: Sequelize.DECIMAL(12, 2),
45
+ allowNull: false,
46
+ defaultValue: 260,
47
+ },
48
+ height: {
49
+ type: Sequelize.DECIMAL(12, 2),
50
+ allowNull: false,
51
+ defaultValue: 96,
52
+ },
53
+ collapsed: {
54
+ type: Sequelize.BOOLEAN,
55
+ allowNull: false,
56
+ defaultValue: false,
57
+ },
58
+ metadata: {
59
+ type: Sequelize.JSONB,
60
+ allowNull: false,
61
+ defaultValue: {},
62
+ },
63
+ createdAt: {
64
+ allowNull: false,
65
+ type: Sequelize.DATE,
66
+ defaultValue: Sequelize.fn('NOW'),
67
+ },
68
+ updatedAt: {
69
+ allowNull: false,
70
+ type: Sequelize.DATE,
71
+ defaultValue: Sequelize.fn('NOW'),
72
+ },
73
+ })
28
74
 
29
- await queryInterface.sequelize.query(
30
- `
31
- DO $$
32
- BEGIN
33
- IF NOT EXISTS (
34
- SELECT 1
35
- FROM pg_constraint
36
- WHERE conname = 'DialogNodeVisualLayouts_unique_node_view'
37
- ) THEN
38
- ALTER TABLE public."DialogNodeVisualLayouts"
39
- ADD CONSTRAINT "DialogNodeVisualLayouts_unique_node_view"
40
- UNIQUE ("EnterpriseId", "SkillId", "visualNodeId", "view");
41
- END IF;
42
- END $$;
43
- `,
44
- { transaction }
45
- );
75
+ await queryInterface.addConstraint('DialogNodeVisualLayouts', {
76
+ fields: ['EnterpriseId', 'SkillId', 'visualNodeId', 'view'],
77
+ type: 'unique',
78
+ name: 'DialogNodeVisualLayouts_unique_node_view',
79
+ })
46
80
 
47
- await queryInterface.sequelize.query(
48
- `
49
- CREATE INDEX IF NOT EXISTS "DialogNodeVisualLayouts_skill_view_idx"
50
- ON public."DialogNodeVisualLayouts" ("EnterpriseId", "SkillId", "view");
51
- `,
52
- { transaction }
53
- );
81
+ await queryInterface.addIndex('DialogNodeVisualLayouts', {
82
+ fields: ['EnterpriseId', 'SkillId', 'view'],
83
+ name: 'DialogNodeVisualLayouts_skill_view_idx',
84
+ })
54
85
 
55
- await queryInterface.sequelize.query(
56
- `
57
- CREATE INDEX IF NOT EXISTS "DialogNodeVisualLayouts_dialog_node_idx"
58
- ON public."DialogNodeVisualLayouts" ("DialogNodeId");
59
- `,
60
- { transaction }
61
- );
62
- });
86
+ await queryInterface.addIndex('DialogNodeVisualLayouts', {
87
+ fields: ['DialogNodeId'],
88
+ name: 'DialogNodeVisualLayouts_dialog_node_idx',
89
+ })
63
90
  },
64
91
 
65
- down: async (queryInterface) => {
66
- await queryInterface.sequelize.transaction(async (transaction) => {
67
- await queryInterface.sequelize.query(
68
- 'DROP TABLE IF EXISTS public."DialogNodeVisualLayouts";',
69
- { transaction }
70
- );
71
- });
92
+ async down(queryInterface) {
93
+ await queryInterface.dropTable('DialogNodeVisualLayouts')
72
94
  },
73
- };
95
+ }