@danielcok17/prisma-db 1.20.0 → 1.20.2
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 +1 -1
- package/prisma/app.prisma +1 -0
- package/prisma/migrations/20260512090000_add_meeting_booking_url/migration.sql +1 -0
- package/dist/migrations/migrateIngestedDocuments.d.ts +0 -17
- package/dist/migrations/migrateIngestedDocuments.d.ts.map +0 -1
- package/dist/migrations/migrateIngestedDocuments.js +0 -113
- package/dist/migrations/migrateIngestedDocuments.js.map +0 -1
- package/dist/migrations/migrateMessageFiles.d.ts +0 -14
- package/dist/migrations/migrateMessageFiles.d.ts.map +0 -1
- package/dist/migrations/migrateMessageFiles.js +0 -120
- package/dist/migrations/migrateMessageFiles.js.map +0 -1
package/package.json
CHANGED
package/prisma/app.prisma
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "MeetingBooking" ADD COLUMN IF NOT EXISTS "meetingUrl" TEXT;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Migrácia IngestedDocument → UserFile
|
|
3
|
-
*
|
|
4
|
-
* IngestedDocument.storageUrl (DO Spaces) → UserFile.storageKey
|
|
5
|
-
* IngestedDocument.qdrantDocId → UserFile.qdrantDocId
|
|
6
|
-
* IngestedDocument status COMPLETED → UserFile status INDEXED
|
|
7
|
-
*
|
|
8
|
-
* PRED spustením:
|
|
9
|
-
* 1. Nastav DATABASE_URL env var
|
|
10
|
-
* 2. Over že UserFile tabuľka existuje
|
|
11
|
-
* 3. Spusti v staging/dev NAJPRV
|
|
12
|
-
*
|
|
13
|
-
* Spustenie: npx tsx src/migrations/migrateIngestedDocuments.ts
|
|
14
|
-
* Rollback: IngestedDocument záznamy sa NEMAŽÚ
|
|
15
|
-
*/
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=migrateIngestedDocuments.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateIngestedDocuments.d.ts","sourceRoot":"","sources":["../../src/migrations/migrateIngestedDocuments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Migrácia IngestedDocument → UserFile
|
|
4
|
-
*
|
|
5
|
-
* IngestedDocument.storageUrl (DO Spaces) → UserFile.storageKey
|
|
6
|
-
* IngestedDocument.qdrantDocId → UserFile.qdrantDocId
|
|
7
|
-
* IngestedDocument status COMPLETED → UserFile status INDEXED
|
|
8
|
-
*
|
|
9
|
-
* PRED spustením:
|
|
10
|
-
* 1. Nastav DATABASE_URL env var
|
|
11
|
-
* 2. Over že UserFile tabuľka existuje
|
|
12
|
-
* 3. Spusti v staging/dev NAJPRV
|
|
13
|
-
*
|
|
14
|
-
* Spustenie: npx tsx src/migrations/migrateIngestedDocuments.ts
|
|
15
|
-
* Rollback: IngestedDocument záznamy sa NEMAŽÚ
|
|
16
|
-
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
const app_1 = require("../../prisma/generated/app");
|
|
22
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
23
|
-
const prisma = new app_1.PrismaClient();
|
|
24
|
-
async function migrateIngestedDocuments() {
|
|
25
|
-
console.log("Začínam migráciu IngestedDocument → UserFile");
|
|
26
|
-
const docs = await prisma.$queryRaw `SELECT * FROM "IngestedDocument" WHERE "storageUrl" IS NOT NULL OR "storagePath" IS NOT NULL`;
|
|
27
|
-
console.log(`Nájdených ${docs.length} IngestedDocument záznamov`);
|
|
28
|
-
let migrated = 0;
|
|
29
|
-
let skipped = 0;
|
|
30
|
-
let errors = 0;
|
|
31
|
-
for (const doc of docs) {
|
|
32
|
-
try {
|
|
33
|
-
// Odvodni storageKey z storageUrl alebo storagePath
|
|
34
|
-
let storageKey = doc.storageUrl || doc.storagePath || null;
|
|
35
|
-
if (!storageKey) {
|
|
36
|
-
console.warn(`IngestedDocument ${doc.id} (${doc.fileName}) nemá storage, skip`);
|
|
37
|
-
skipped++;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
// Ak je to full URL, extrahuj path (key)
|
|
41
|
-
if (storageKey.startsWith("https://")) {
|
|
42
|
-
try {
|
|
43
|
-
const url = new URL(storageKey);
|
|
44
|
-
storageKey = url.pathname.replace(/^\/[^/]+\//, ""); // odober bucket z path
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
// nechaj ako je
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Skontroluj dedup podľa qdrantDocId
|
|
51
|
-
if (doc.qdrantDocId) {
|
|
52
|
-
const existing = await prisma.userFile.findFirst({
|
|
53
|
-
where: { qdrantDocId: doc.qdrantDocId },
|
|
54
|
-
});
|
|
55
|
-
if (existing) {
|
|
56
|
-
console.log(`UserFile pre qdrantDocId ${doc.qdrantDocId} už existuje, skip`);
|
|
57
|
-
skipped++;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const userFile = await prisma.userFile.create({
|
|
62
|
-
data: {
|
|
63
|
-
userId: doc.userId,
|
|
64
|
-
storageKey,
|
|
65
|
-
// PLACEHOLDER: SHA-256 nie je dostupné pre migrované IngestedDocument záznamy.
|
|
66
|
-
// Dedup cez checksumSha256 nebude fungovať pre tieto záznamy.
|
|
67
|
-
// Po migrácii: ak je potrebný skutočný hash, stiahnuť súbor z S3 a prepočítať.
|
|
68
|
-
checksumSha256: `migrated_${crypto_1.default.randomUUID()}`,
|
|
69
|
-
fileName: doc.fileName,
|
|
70
|
-
fileType: doc.fileType || "application/pdf",
|
|
71
|
-
fileSize: doc.fileSize || 0,
|
|
72
|
-
status: doc.status === "COMPLETED" ? "INDEXED" : "STORED",
|
|
73
|
-
docType: doc.docType,
|
|
74
|
-
legalArea: doc.legalArea,
|
|
75
|
-
summary: doc.summary,
|
|
76
|
-
references: doc.references || [],
|
|
77
|
-
chunkCount: doc.chunkCount,
|
|
78
|
-
qdrantDocId: doc.qdrantDocId,
|
|
79
|
-
indexingCost: doc.embeddingCost,
|
|
80
|
-
indexedAt: doc.status === "COMPLETED" ? doc.updatedAt : null,
|
|
81
|
-
tags: [],
|
|
82
|
-
createdAt: doc.createdAt,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
// Ak má folderId, vytvor FolderItem
|
|
86
|
-
if (doc.folderId) {
|
|
87
|
-
await prisma.folderItem.create({
|
|
88
|
-
data: {
|
|
89
|
-
folderId: doc.folderId,
|
|
90
|
-
entityType: "USER_FILE",
|
|
91
|
-
entityId: userFile.id,
|
|
92
|
-
addedById: doc.userId,
|
|
93
|
-
sortOrder: 0,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
console.log(`Migrovaný: ${doc.fileName} (status: ${doc.status} → ${userFile.status})`);
|
|
98
|
-
migrated++;
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
console.error(`Chyba pri migrácii IngestedDocument ${doc.id}:`, err);
|
|
102
|
-
errors++;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
console.log("\nVýsledok:");
|
|
106
|
-
console.log(` Migrovaných: ${migrated}`);
|
|
107
|
-
console.log(` Preskočených: ${skipped}`);
|
|
108
|
-
console.log(` Chýb: ${errors}`);
|
|
109
|
-
}
|
|
110
|
-
migrateIngestedDocuments()
|
|
111
|
-
.catch(console.error)
|
|
112
|
-
.finally(() => prisma.$disconnect());
|
|
113
|
-
//# sourceMappingURL=migrateIngestedDocuments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateIngestedDocuments.js","sourceRoot":"","sources":["../../src/migrations/migrateIngestedDocuments.ts"],"names":[],"mappings":";A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_SPACES_BUCKET,
|
|
6
|
-
* DO_SPACES_ACCESS_KEY, DO_SPACES_SECRET_KEY, DATABASE_URL
|
|
7
|
-
* 2. Over že UserFile tabuľka existuje (migrácia 20260502185044_add_userfile_system)
|
|
8
|
-
* 3. Spusti v staging/dev NAJPRV pred prod
|
|
9
|
-
*
|
|
10
|
-
* Spustenie: npx tsx src/migrations/migrateMessageFiles.ts
|
|
11
|
-
* Rollback: MessageFile záznamy sa NEMAŽÚ — rollback = vyčisti UserFile záznamy
|
|
12
|
-
*/
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=migrateMessageFiles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateMessageFiles.d.ts","sourceRoot":"","sources":["../../src/migrations/migrateMessageFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Migrácia MessageFile (base64 v DB) → UserFile (S3/DO Spaces)
|
|
4
|
-
*
|
|
5
|
-
* PRED spustením:
|
|
6
|
-
* 1. Nastav env vars: DO_SPACES_ENDPOINT, DO_SPACES_REGION, DO_SPACES_BUCKET,
|
|
7
|
-
* DO_SPACES_ACCESS_KEY, DO_SPACES_SECRET_KEY, DATABASE_URL
|
|
8
|
-
* 2. Over že UserFile tabuľka existuje (migrácia 20260502185044_add_userfile_system)
|
|
9
|
-
* 3. Spusti v staging/dev NAJPRV pred prod
|
|
10
|
-
*
|
|
11
|
-
* Spustenie: npx tsx src/migrations/migrateMessageFiles.ts
|
|
12
|
-
* Rollback: MessageFile záznamy sa NEMAŽÚ — rollback = vyčisti UserFile záznamy
|
|
13
|
-
*/
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const app_1 = require("../../prisma/generated/app");
|
|
19
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
20
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
21
|
-
const prisma = new app_1.PrismaClient();
|
|
22
|
-
const s3 = new client_s3_1.S3Client({
|
|
23
|
-
endpoint: process.env.DO_SPACES_ENDPOINT || "https://fra1.digitaloceanspaces.com",
|
|
24
|
-
region: process.env.DO_SPACES_REGION || "fra1",
|
|
25
|
-
credentials: {
|
|
26
|
-
accessKeyId: process.env.DO_SPACES_ACCESS_KEY || "",
|
|
27
|
-
secretAccessKey: process.env.DO_SPACES_SECRET_KEY || "",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
const BUCKET = process.env.DO_SPACES_BUCKET || "smartlex-user-files";
|
|
31
|
-
async function migrateMessageFiles() {
|
|
32
|
-
console.log("Začínam migráciu MessageFile → UserFile");
|
|
33
|
-
// Nájdi všetky FolderItem záznamy s entityType=ATTACHMENT
|
|
34
|
-
const attachments = await prisma.folderItem.findMany({
|
|
35
|
-
where: { entityType: "ATTACHMENT" },
|
|
36
|
-
});
|
|
37
|
-
console.log(`Nájdených ${attachments.length} ATTACHMENT FolderItem záznamov`);
|
|
38
|
-
let migrated = 0;
|
|
39
|
-
let skipped = 0;
|
|
40
|
-
let errors = 0;
|
|
41
|
-
for (const attachment of attachments) {
|
|
42
|
-
try {
|
|
43
|
-
// Načítaj MessageFile cez raw query (Prisma ho môže nemať ako typed model)
|
|
44
|
-
const messageFiles = await prisma.$queryRaw `SELECT id, "fileName", "fileType", "base64Data", "uploadedAt" FROM "MessageFile" WHERE id = ${attachment.entityId}`;
|
|
45
|
-
if (!messageFiles[0]) {
|
|
46
|
-
console.warn(`MessageFile ${attachment.entityId} nenájdený, skip`);
|
|
47
|
-
skipped++;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const mf = messageFiles[0];
|
|
51
|
-
// Dekóduj base64 → buffer
|
|
52
|
-
if (!mf.base64Data) {
|
|
53
|
-
console.warn(`MessageFile ${mf.id} (${mf.fileName}) má prázdny base64Data, skip`);
|
|
54
|
-
skipped++;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const buffer = Buffer.from(mf.base64Data, "base64");
|
|
58
|
-
const checksumSha256 = crypto_1.default.createHash("sha256").update(buffer).digest("hex");
|
|
59
|
-
// Skontroluj dedup podľa checksum
|
|
60
|
-
const existing = await prisma.userFile.findFirst({
|
|
61
|
-
where: { checksumSha256 },
|
|
62
|
-
});
|
|
63
|
-
if (existing) {
|
|
64
|
-
console.log(`UserFile pre checksum ${checksumSha256.substring(0, 8)}... už existuje, aktualizujem FolderItem`);
|
|
65
|
-
await prisma.folderItem.update({
|
|
66
|
-
where: { id: attachment.id },
|
|
67
|
-
data: { entityType: "USER_FILE", entityId: existing.id },
|
|
68
|
-
});
|
|
69
|
-
migrated++;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
// Upload do S3
|
|
73
|
-
const userId = attachment.addedById;
|
|
74
|
-
const uuid = crypto_1.default.randomUUID();
|
|
75
|
-
const safe = (mf.fileName || "file").replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
76
|
-
const storageKey = `users/${userId}/files/migrated_${uuid}_${safe}`;
|
|
77
|
-
await s3.send(new client_s3_1.PutObjectCommand({
|
|
78
|
-
Bucket: BUCKET,
|
|
79
|
-
Key: storageKey,
|
|
80
|
-
Body: buffer,
|
|
81
|
-
ContentType: mf.fileType || "application/octet-stream",
|
|
82
|
-
ContentLength: buffer.length,
|
|
83
|
-
}));
|
|
84
|
-
// Vytvor UserFile
|
|
85
|
-
const userFile = await prisma.userFile.create({
|
|
86
|
-
data: {
|
|
87
|
-
userId,
|
|
88
|
-
storageKey,
|
|
89
|
-
checksumSha256,
|
|
90
|
-
fileName: mf.fileName || "unknown",
|
|
91
|
-
fileType: mf.fileType || "application/octet-stream",
|
|
92
|
-
fileSize: buffer.length,
|
|
93
|
-
status: "STORED",
|
|
94
|
-
tags: [],
|
|
95
|
-
references: [],
|
|
96
|
-
createdAt: mf.uploadedAt,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
// Aktualizuj FolderItem: ATTACHMENT → USER_FILE
|
|
100
|
-
await prisma.folderItem.update({
|
|
101
|
-
where: { id: attachment.id },
|
|
102
|
-
data: { entityType: "USER_FILE", entityId: userFile.id },
|
|
103
|
-
});
|
|
104
|
-
console.log(`Migrovaný: ${mf.fileName} (${buffer.length} bytes) → ${storageKey}`);
|
|
105
|
-
migrated++;
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
console.error(`Chyba pri migrácii attachment ${attachment.id}:`, err);
|
|
109
|
-
errors++;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
console.log("\nVýsledok migrácie:");
|
|
113
|
-
console.log(` Migrovaných: ${migrated}`);
|
|
114
|
-
console.log(` Preskočených: ${skipped}`);
|
|
115
|
-
console.log(` Chýb: ${errors}`);
|
|
116
|
-
}
|
|
117
|
-
migrateMessageFiles()
|
|
118
|
-
.catch(console.error)
|
|
119
|
-
.finally(() => prisma.$disconnect());
|
|
120
|
-
//# sourceMappingURL=migrateMessageFiles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateMessageFiles.js","sourceRoot":"","sources":["../../src/migrations/migrateMessageFiles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;AAEH,oDAA0D;AAC1D,kDAAgE;AAChE,oDAA4B;AAE5B,MAAM,MAAM,GAAG,IAAI,kBAAY,EAAE,CAAC;AAElC,MAAM,EAAE,GAAG,IAAI,oBAAQ,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,qCAAqC;IACjF,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM;IAC9C,WAAW,EAAE;QACX,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,oBAA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