@platform-modules/civil-aviation-authority 2.3.294 → 2.3.295
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/dist/models/FollowUpReportRequestModel.js +1 -6
- package/package.json +2 -1
- package/scripts/run-enum-fix.js +30 -0
- package/sql/caa_api_payload_changes_2026_07.sql +17 -39
- package/sql/fix_maintenance_subject_classification_enum_2026_07.sql +21 -41
- package/src/models/FollowUpReportRequestModel.ts +1 -6
|
@@ -80,12 +80,7 @@ __decorate([
|
|
|
80
80
|
__metadata("design:type", String)
|
|
81
81
|
], FollowUpReportRequests.prototype, "subject", void 0);
|
|
82
82
|
__decorate([
|
|
83
|
-
(0, typeorm_1.Column)({
|
|
84
|
-
type: 'enum',
|
|
85
|
-
enum: FollowUpReportSubjectClassification,
|
|
86
|
-
enumName: 'maintenance_subject_classification_en',
|
|
87
|
-
nullable: false,
|
|
88
|
-
}),
|
|
83
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: false }),
|
|
89
84
|
__metadata("design:type", String)
|
|
90
85
|
], FollowUpReportRequests.prototype, "subject_classification", void 0);
|
|
91
86
|
__decorate([
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platform-modules/civil-aviation-authority",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.295",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc && node -e \"require('fs').mkdirSync('dist/i18n',{recursive:true}); require('fs').copyFileSync('src/i18n/workflow-chat-i18n.json','dist/i18n/workflow-chat-i18n.json')\"",
|
|
8
8
|
"dev": "ts-node src/scripts.ts",
|
|
9
|
+
"fix:enum": "node scripts/run-enum-fix.js",
|
|
9
10
|
"sync:sla-sql": "node scripts/sync-sla-reports-sql.js"
|
|
10
11
|
},
|
|
11
12
|
"publishConfig": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { Client } = require('pg');
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
const sqlPath = path.join(__dirname, '..', 'sql', 'fix_maintenance_subject_classification_enum_2026_07.sql');
|
|
8
|
+
const sql = fs.readFileSync(sqlPath, 'utf8');
|
|
9
|
+
|
|
10
|
+
const client = new Client({
|
|
11
|
+
host: process.env.DB_HOST,
|
|
12
|
+
port: Number(process.env.DB_PORT || 5432),
|
|
13
|
+
user: process.env.DB_USER,
|
|
14
|
+
password: process.env.DB_PASS,
|
|
15
|
+
database: process.env.DB_NAME,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await client.connect();
|
|
19
|
+
try {
|
|
20
|
+
await client.query(sql);
|
|
21
|
+
console.log('✅ Enum repair SQL applied successfully.');
|
|
22
|
+
} finally {
|
|
23
|
+
await client.end();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main().catch((error) => {
|
|
28
|
+
console.error('❌ Enum repair failed:', error.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
@@ -31,51 +31,29 @@ ALTER TABLE cyber_security_risk_management_risks
|
|
|
31
31
|
ADD COLUMN IF NOT EXISTS treatment TEXT,
|
|
32
32
|
ADD COLUMN IF NOT EXISTS action TEXT;
|
|
33
33
|
|
|
34
|
-
-- 7. Follow-up report: subject_classification enum
|
|
35
|
-
ALTER
|
|
36
|
-
ALTER
|
|
37
|
-
|
|
38
|
-
ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Limited';
|
|
34
|
+
-- 7. Follow-up report: subject_classification as varchar (avoids TypeORM PG enum sync failures)
|
|
35
|
+
ALTER TABLE followup_report_items
|
|
36
|
+
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
37
|
+
USING subject_classification::text;
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'maintenance_subject_classification_en_old') THEN
|
|
44
|
-
IF EXISTS (
|
|
45
|
-
SELECT 1
|
|
46
|
-
FROM information_schema.columns
|
|
47
|
-
WHERE table_schema = 'public'
|
|
48
|
-
AND table_name = 'followup_report_items'
|
|
49
|
-
AND column_name = 'subject_classification'
|
|
50
|
-
AND udt_name = 'maintenance_subject_classification_en_old'
|
|
51
|
-
) THEN
|
|
52
|
-
ALTER TABLE followup_report_items
|
|
53
|
-
ALTER COLUMN subject_classification TYPE maintenance_subject_classification_en
|
|
54
|
-
USING subject_classification::text::maintenance_subject_classification_en;
|
|
55
|
-
END IF;
|
|
39
|
+
ALTER TABLE followup_report_requests
|
|
40
|
+
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
41
|
+
USING subject_classification::text;
|
|
56
42
|
|
|
57
|
-
|
|
58
|
-
SELECT 1
|
|
59
|
-
FROM information_schema.columns
|
|
60
|
-
WHERE table_schema = 'public'
|
|
61
|
-
AND table_name = 'followup_report_requests'
|
|
62
|
-
AND column_name = 'subject_classification'
|
|
63
|
-
AND udt_name = 'maintenance_subject_classification_en_old'
|
|
64
|
-
) THEN
|
|
65
|
-
ALTER TABLE followup_report_requests
|
|
66
|
-
ALTER COLUMN subject_classification TYPE maintenance_subject_classification_en
|
|
67
|
-
USING subject_classification::text::maintenance_subject_classification_en;
|
|
68
|
-
END IF;
|
|
43
|
+
DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
|
|
69
44
|
|
|
70
|
-
|
|
45
|
+
DO $$
|
|
46
|
+
BEGIN
|
|
47
|
+
IF NOT EXISTS (
|
|
48
|
+
SELECT 1
|
|
49
|
+
FROM information_schema.columns
|
|
50
|
+
WHERE table_schema = 'public'
|
|
51
|
+
AND udt_name = 'maintenance_subject_classification_en'
|
|
52
|
+
) THEN
|
|
53
|
+
DROP TYPE IF EXISTS maintenance_subject_classification_en;
|
|
71
54
|
END IF;
|
|
72
55
|
END $$;
|
|
73
56
|
|
|
74
|
-
-- 7c. Report items use varchar (nullable) so TypeORM sync does not fight shared PG enum on two tables
|
|
75
|
-
ALTER TABLE followup_report_items
|
|
76
|
-
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
77
|
-
USING subject_classification::text;
|
|
78
|
-
|
|
79
57
|
-- 8. Contract service request: notes, company phone, contract documents table
|
|
80
58
|
ALTER TABLE contract_service_requests
|
|
81
59
|
ADD COLUMN IF NOT EXISTS notes TEXT,
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
-
--
|
|
2
|
-
-- cannot drop type maintenance_subject_classification_en_old because other objects depend on it
|
|
3
|
-
--
|
|
1
|
+
-- Repair stuck TypeORM enum swap for follow-up report subject_classification.
|
|
4
2
|
-- Safe to re-run.
|
|
5
3
|
|
|
6
|
-
--
|
|
7
|
-
ALTER
|
|
8
|
-
ALTER
|
|
9
|
-
|
|
10
|
-
ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Limited';
|
|
4
|
+
-- 1) Move report items off PG enum (_old or live) -> varchar
|
|
5
|
+
ALTER TABLE followup_report_items
|
|
6
|
+
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
7
|
+
USING subject_classification::text;
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
SELECT 1
|
|
17
|
-
FROM information_schema.columns
|
|
18
|
-
WHERE table_schema = 'public'
|
|
19
|
-
AND table_name = 'followup_report_items'
|
|
20
|
-
AND column_name = 'subject_classification'
|
|
21
|
-
AND udt_name = 'maintenance_subject_classification_en_old'
|
|
22
|
-
) THEN
|
|
23
|
-
ALTER TABLE followup_report_items
|
|
24
|
-
ALTER COLUMN subject_classification TYPE maintenance_subject_classification_en
|
|
25
|
-
USING subject_classification::text::maintenance_subject_classification_en;
|
|
26
|
-
END IF;
|
|
9
|
+
-- 2) Move requests off PG enum (_old or live) -> varchar
|
|
10
|
+
ALTER TABLE followup_report_requests
|
|
11
|
+
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
12
|
+
USING subject_classification::text;
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
FROM information_schema.columns
|
|
31
|
-
WHERE table_schema = 'public'
|
|
32
|
-
AND table_name = 'followup_report_requests'
|
|
33
|
-
AND column_name = 'subject_classification'
|
|
34
|
-
AND udt_name = 'maintenance_subject_classification_en_old'
|
|
35
|
-
) THEN
|
|
36
|
-
ALTER TABLE followup_report_requests
|
|
37
|
-
ALTER COLUMN subject_classification TYPE maintenance_subject_classification_en
|
|
38
|
-
USING subject_classification::text::maintenance_subject_classification_en;
|
|
39
|
-
END IF;
|
|
14
|
+
-- 3) Drop leftover TypeORM enum type if nothing depends on it
|
|
15
|
+
DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
|
|
40
16
|
|
|
41
|
-
|
|
17
|
+
-- 4) Drop orphaned live enum only when no column uses it anymore
|
|
18
|
+
DO $$
|
|
19
|
+
BEGIN
|
|
20
|
+
IF NOT EXISTS (
|
|
21
|
+
SELECT 1
|
|
22
|
+
FROM information_schema.columns
|
|
23
|
+
WHERE table_schema = 'public'
|
|
24
|
+
AND udt_name = 'maintenance_subject_classification_en'
|
|
25
|
+
) THEN
|
|
26
|
+
DROP TYPE IF EXISTS maintenance_subject_classification_en;
|
|
42
27
|
END IF;
|
|
43
28
|
END $$;
|
|
44
|
-
|
|
45
|
-
-- Items column: varchar avoids TypeORM multi-table PG enum sync failures
|
|
46
|
-
ALTER TABLE followup_report_items
|
|
47
|
-
ALTER COLUMN subject_classification TYPE VARCHAR(100)
|
|
48
|
-
USING subject_classification::text;
|
|
@@ -62,12 +62,7 @@ export class FollowUpReportRequests extends BaseModel {
|
|
|
62
62
|
@Column({ type: 'varchar', length: 500, nullable: false })
|
|
63
63
|
subject: string;
|
|
64
64
|
|
|
65
|
-
@Column({
|
|
66
|
-
type: 'enum',
|
|
67
|
-
enum: FollowUpReportSubjectClassification,
|
|
68
|
-
enumName: 'maintenance_subject_classification_en',
|
|
69
|
-
nullable: false,
|
|
70
|
-
})
|
|
65
|
+
@Column({ type: 'varchar', length: 100, nullable: false })
|
|
71
66
|
subject_classification: FollowUpReportSubjectClassification;
|
|
72
67
|
|
|
73
68
|
@Column({ type: 'text', nullable: false })
|