@itleanchatbot/shared-models-js-postgres 2.8.2 → 2.8.3

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": "2.8.2",
3
+ "version": "2.8.3",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.dropTable('WhatsappSessions')
6
+
7
+ await queryInterface.createTable('ConversationSessions', {
8
+ id: {
9
+ allowNull: false,
10
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
11
+ primaryKey: true,
12
+ type: Sequelize.UUID,
13
+ },
14
+ SessionId: {
15
+ allowNull: true,
16
+ type: Sequelize.UUID,
17
+ references: {
18
+ model: 'Sessions',
19
+ key: 'id',
20
+ },
21
+ onDelete: 'SET NULL',
22
+ onUpdate: 'CASCADE',
23
+ },
24
+ ClientId: {
25
+ type: Sequelize.UUID,
26
+ references: {
27
+ model: 'Clients',
28
+ key: 'id',
29
+ },
30
+ allowNull: false,
31
+ onDelete: 'SET NULL',
32
+ onUpdate: 'CASCADE',
33
+ },
34
+ createdAt: {
35
+ allowNull: false,
36
+ type: Sequelize.DATE,
37
+ },
38
+ updatedAt: {
39
+ allowNull: false,
40
+ type: Sequelize.DATE,
41
+ },
42
+ })
43
+ },
44
+
45
+ down: async (queryInterface, Sequelize) => {
46
+ await queryInterface.dropTable('ConversationSessions')
47
+
48
+ await queryInterface.createTable('WhatsappSessions', {
49
+ id: {
50
+ allowNull: false,
51
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
52
+ primaryKey: true,
53
+ type: Sequelize.UUID,
54
+ },
55
+ SessionId: {
56
+ allowNull: true,
57
+ type: Sequelize.UUID,
58
+ references: {
59
+ model: 'Sessions',
60
+ key: 'id',
61
+ },
62
+ onDelete: 'SET NULL',
63
+ onUpdate: 'CASCADE',
64
+ },
65
+ createdAt: {
66
+ allowNull: false,
67
+ type: Sequelize.DATE,
68
+ },
69
+ updatedAt: {
70
+ allowNull: false,
71
+ type: Sequelize.DATE,
72
+ },
73
+ })
74
+ }
75
+ };
@@ -0,0 +1,41 @@
1
+ exports.model = (sequelize, DataType) => {
2
+ const ConversationSessions = sequelize.define('ConversationSessions', {
3
+ ClientId: {
4
+ type: DataTypes.UUID,
5
+ references: {
6
+ model: 'Clients',
7
+ key: 'id',
8
+ },
9
+ allowNull: false,
10
+ onDelete: 'SET NULL',
11
+ onUpdate: 'CASCADE',
12
+ },
13
+ SessionId: {
14
+ type: DataType.UUID,
15
+ references: {
16
+ model: 'Sessions',
17
+ key: 'id',
18
+ },
19
+ allowNull: true,
20
+ onDelete: 'SET NULL',
21
+ },
22
+ ChannelTypeId: {
23
+ type: DataTypes.UUID,
24
+ allowNull: false,
25
+ references: {
26
+ model: 'ChannelTypes',
27
+ key: 'id',
28
+ },
29
+ onDelete: 'RESTRICT',
30
+ onUpdate: 'CASCADE',
31
+ },
32
+ })
33
+
34
+ ConversationSessions.associate = (models) => {
35
+ ConversationSessions.belongsTo(models.Sessions, { onDelete: 'SET NULL' })
36
+ ConversationSessions.belongsTo(models.Client, { onDelete: 'SET NULL' })
37
+ ConversationSessions.belongsTo(models.ChannelTypes)
38
+ }
39
+
40
+ return ConversationSessions
41
+ }
@@ -1,20 +0,0 @@
1
- exports.model = (sequelize, DataType) => {
2
- const WhatsappSessions = sequelize.define('WhatsappSessions', {
3
- SessionId: {
4
- type: DataType.UUID,
5
- references: {
6
- model: 'Sessions',
7
- key: 'id',
8
- },
9
- allowNull: true,
10
- onDelete: 'SET NULL',
11
- },
12
- })
13
-
14
- WhatsappSessions.associate = (models) => {
15
- WhatsappSessions.belongsTo(models.Sessions, { onDelete: 'SET NULL' })
16
- }
17
-
18
- return WhatsappSessions
19
- }
20
-