@tomei/sso 0.50.1 → 0.50.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ /** @type {import('sequelize-cli').Migration} */
4
+ module.exports = {
5
+ up: async (queryInterface, Sequelize) => {
6
+ await queryInterface.createTable('sso_Building', {
7
+ GroupCode: {
8
+ type: Sequelize.STRING(10),
9
+ primaryKey: true,
10
+ allowNull: false,
11
+ references: {
12
+ model: 'sso_Group',
13
+ key: 'GroupCode',
14
+ },
15
+ onUpdate: 'CASCADE',
16
+ onDelete: 'CASCADE',
17
+ },
18
+ BuildingType: {
19
+ type: Sequelize.ENUM('Outlet', 'Office'),
20
+ allowNull: true,
21
+ },
22
+ Email: {
23
+ type: Sequelize.STRING(200),
24
+ allowNull: true,
25
+ },
26
+ Mobile: {
27
+ type: Sequelize.STRING(20),
28
+ allowNull: true,
29
+ },
30
+ Phone: {
31
+ type: Sequelize.STRING(20),
32
+ allowNull: false,
33
+ },
34
+ Brand: {
35
+ type: Sequelize.STRING(10),
36
+ allowNull: true,
37
+ },
38
+ OpeningDate: {
39
+ type: Sequelize.DATE,
40
+ allowNull: true,
41
+ },
42
+ CeasedDate: {
43
+ type: Sequelize.DATE,
44
+ allowNull: true,
45
+ },
46
+ OpeningHours: {
47
+ type: Sequelize.STRING(200),
48
+ allowNull: true,
49
+ },
50
+ CreatedById: {
51
+ type: Sequelize.INTEGER,
52
+ allowNull: true,
53
+ references: {
54
+ model: 'sso_User',
55
+ key: 'UserId',
56
+ },
57
+ onDelete: 'CASCADE',
58
+ onUpdate: 'CASCADE',
59
+ },
60
+ CreatedAt: {
61
+ allowNull: false,
62
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
63
+ type: Sequelize.DATE,
64
+ },
65
+ UpdatedById: {
66
+ type: Sequelize.INTEGER,
67
+ allowNull: true,
68
+ references: {
69
+ model: 'sso_User',
70
+ key: 'UserId',
71
+ },
72
+ onDelete: 'CASCADE',
73
+ onUpdate: 'CASCADE',
74
+ },
75
+ UpdatedAt: {
76
+ allowNull: false,
77
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
78
+ type: Sequelize.DATE,
79
+ },
80
+ });
81
+
82
+ // Add a trigger to keep GroupCode and ObjectId in sync on updates
83
+ await queryInterface.sequelize.query(`
84
+ CREATE TRIGGER update_GroupCode_ObjectId
85
+ BEFORE UPDATE ON sso_Building
86
+ FOR EACH ROW
87
+ BEGIN
88
+ IF NEW.ObjectId != OLD.ObjectId THEN
89
+ SET NEW.GroupCode = NEW.ObjectId;
90
+ END IF;
91
+ END;
92
+ `);
93
+ },
94
+
95
+ down: async (queryInterface, Sequelize) => {
96
+ // Drop the trigger before dropping the table
97
+ await queryInterface.sequelize.query(
98
+ `DROP TRIGGER IF EXISTS update_GroupCode_ObjectId`,
99
+ );
100
+ await queryInterface.dropTable('sso_Building');
101
+ },
102
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.50.1",
3
+ "version": "0.50.2",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {