@zintrust/core 0.1.36 → 0.1.38
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/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +8 -3
- package/src/boot/bootstrap.js +13 -11
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +2 -1
- package/src/cli/services/VersionChecker.d.ts +8 -0
- package/src/cli/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +58 -5
- package/src/index.js +3 -3
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.js +36 -4
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +0 -5
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +3 -3
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +2 -2
package/package.json
CHANGED
package/src/boot/Server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAG9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;AAkED;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,YAAY,SAAS,MAAM,SAAS,MAAM,WAAU,OAAO,GAAG,IAAI,GAAU,OAAO;EA4D/F,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/boot/Server.js
CHANGED
|
@@ -24,19 +24,24 @@ const getContentSecurityPolicyForPath = () => {
|
|
|
24
24
|
"img-src 'self' data:; " +
|
|
25
25
|
"font-src 'self' https://fonts.gstatic.com;");
|
|
26
26
|
};
|
|
27
|
-
const setSecurityHeaders = (res) => {
|
|
27
|
+
const setSecurityHeaders = (res, contentType) => {
|
|
28
28
|
res.setHeader(HTTP_HEADERS.X_POWERED_BY, 'ZinTrust');
|
|
29
29
|
res.setHeader(HTTP_HEADERS.X_CONTENT_TYPE_OPTIONS, 'nosniff');
|
|
30
30
|
res.setHeader(HTTP_HEADERS.X_FRAME_OPTIONS, 'DENY');
|
|
31
31
|
res.setHeader(HTTP_HEADERS.X_XSS_PROTECTION, '1; mode=block');
|
|
32
32
|
res.setHeader(HTTP_HEADERS.REFERRER_POLICY, 'strict-origin-when-cross-origin');
|
|
33
|
-
|
|
33
|
+
// Only apply CSP to HTML responses, not API endpoints
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
35
|
+
if (contentType !== undefined && contentType !== null && contentType.includes('text/html')) {
|
|
36
|
+
res.setHeader(HTTP_HEADERS.CONTENT_SECURITY_POLICY, getContentSecurityPolicyForPath());
|
|
37
|
+
}
|
|
34
38
|
};
|
|
35
39
|
const handleRequest = async (params, req, res) => {
|
|
36
40
|
let request;
|
|
37
41
|
let response;
|
|
38
42
|
try {
|
|
39
|
-
|
|
43
|
+
const contentType = req?.headers['content-type'];
|
|
44
|
+
setSecurityHeaders(res, contentType);
|
|
40
45
|
if (!req) {
|
|
41
46
|
throw ErrorFactory.createConnectionError('Request object is missing');
|
|
42
47
|
}
|
package/src/boot/bootstrap.js
CHANGED
|
@@ -145,18 +145,20 @@ async function useWorkerStarter() {
|
|
|
145
145
|
const { createRequire } = await import('../node-singletons/module.js');
|
|
146
146
|
const require = createRequire(import.meta.url);
|
|
147
147
|
const workers = require('@zintrust/workers');
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
if (workers?.WorkerInit !== undefined) {
|
|
149
|
+
workerInit = workers.WorkerInit;
|
|
150
|
+
await workers.WorkerInit.initialize({
|
|
151
|
+
enableResourceMonitoring: true,
|
|
152
|
+
enableHealthMonitoring: true,
|
|
153
|
+
enableAutoScaling: false, // Disabled by default, enable via config
|
|
154
|
+
registerShutdownHandlers: true,
|
|
155
|
+
resourceMonitoringInterval: 60000,
|
|
156
|
+
});
|
|
157
|
+
Logger.info('Worker management system initialized');
|
|
158
|
+
}
|
|
157
159
|
}
|
|
158
|
-
catch
|
|
159
|
-
Logger.warn('Worker management system initialization failed (non-fatal)', error);
|
|
160
|
+
catch {
|
|
161
|
+
// Logger.warn('Worker management system initialization failed (non-fatal)', error as Error);
|
|
160
162
|
// Non-fatal - application can still run without worker management
|
|
161
163
|
}
|
|
162
164
|
if (workerInit?.autoStartPersistedWorkers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA6ZrE;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EAUtB,CAAC"}
|
|
@@ -33,7 +33,8 @@ const addMigrateOptions = (command) => {
|
|
|
33
33
|
};
|
|
34
34
|
const getInteractive = (options) => options['interactive'] !== false;
|
|
35
35
|
const getMigrationDirs = () => {
|
|
36
|
-
const
|
|
36
|
+
const fromEnv = readEnvString('MIGRATIONS_GLOBAL_DIR', databaseConfig.migrations.directory);
|
|
37
|
+
const globalDir = fromEnv.trim() === '' ? databaseConfig.migrations.directory : fromEnv;
|
|
37
38
|
const extension = databaseConfig.migrations.extension;
|
|
38
39
|
const separateTrackingRaw = readEnvString('MIGRATIONS_SEPARATE_TRACKING', '').trim();
|
|
39
40
|
const separateTracking = separateTrackingRaw === '1' || separateTrackingRaw.toLowerCase() === 'true';
|
|
@@ -33,6 +33,14 @@ export declare const VersionChecker: Readonly<{
|
|
|
33
33
|
* Check if version check should be performed
|
|
34
34
|
*/
|
|
35
35
|
shouldCheckVersion(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch cached version if available and fresh
|
|
38
|
+
*/
|
|
39
|
+
getCachedVersion(checkInterval: number): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Cache the latest version and timestamp
|
|
42
|
+
*/
|
|
43
|
+
cacheLatestVersion(version: string): void;
|
|
36
44
|
/**
|
|
37
45
|
* Fetch latest version from npm registry
|
|
38
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionChecker.d.ts","sourceRoot":"","sources":["../../../../src/cli/services/VersionChecker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,aAA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AAC,aAAa,CAAC;IAQpD;;OAEG;uBACgB,MAAM;IAIzB;;OAEG;qCAC8B,OAAO,GAAG,MAAM;IAuBjD;;OAEG;8BACuB,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAInE;;OAEG;uCACgC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;IAY1E;;OAEG;oCAC6B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;IAQvE;;OAEG;6BACsB,MAAM,UAAU,MAAM,GAAG,MAAM;IAuBxD;;OAEG;oBACmB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAyBxD;;OAEG;sCAC+B,kBAAkB,GAAG,IAAI;IA4B3D;;OAEG;uBACsB,OAAO,CAAC,IAAI,CAAC;EAUtC,CAAC"}
|
|
@@ -64,7 +64,11 @@ export const VersionChecker = Object.freeze({
|
|
|
64
64
|
}
|
|
65
65
|
// Skip for version commands
|
|
66
66
|
const args = new Set(process.argv.slice(2));
|
|
67
|
-
if (args.has('-v') ||
|
|
67
|
+
if (args.has('-v') ||
|
|
68
|
+
args.has('--version') ||
|
|
69
|
+
args.has('help') ||
|
|
70
|
+
args.has('new') ||
|
|
71
|
+
args.has('migrate')) {
|
|
68
72
|
return false;
|
|
69
73
|
}
|
|
70
74
|
// Check last check time
|
|
@@ -80,17 +84,69 @@ export const VersionChecker = Object.freeze({
|
|
|
80
84
|
}
|
|
81
85
|
return true;
|
|
82
86
|
},
|
|
87
|
+
/**
|
|
88
|
+
* Fetch cached version if available and fresh
|
|
89
|
+
*/
|
|
90
|
+
getCachedVersion(checkInterval) {
|
|
91
|
+
const LAST_CHECK_KEY = 'zintrust_last_version_check';
|
|
92
|
+
const CACHED_VERSION_KEY = 'zintrust_cached_latest_version';
|
|
93
|
+
try {
|
|
94
|
+
const ls = globalThis.localStorage;
|
|
95
|
+
if (!ls?.getItem)
|
|
96
|
+
return null;
|
|
97
|
+
const last = ls.getItem(LAST_CHECK_KEY);
|
|
98
|
+
const cached = ls.getItem(CACHED_VERSION_KEY);
|
|
99
|
+
if (last === null || cached === null)
|
|
100
|
+
return null;
|
|
101
|
+
const lastTime = Number.parseInt(last, 10);
|
|
102
|
+
if (Number.isNaN(lastTime))
|
|
103
|
+
return null;
|
|
104
|
+
const hoursSince = (Date.now() - lastTime) / (1000 * 60 * 60);
|
|
105
|
+
return hoursSince < checkInterval ? cached : null;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Ignore localStorage failures
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Cache the latest version and timestamp
|
|
114
|
+
*/
|
|
115
|
+
cacheLatestVersion(version) {
|
|
116
|
+
const LAST_CHECK_KEY = 'zintrust_last_version_check';
|
|
117
|
+
const CACHED_VERSION_KEY = 'zintrust_cached_latest_version';
|
|
118
|
+
try {
|
|
119
|
+
const ls = globalThis.localStorage;
|
|
120
|
+
if (ls?.setItem) {
|
|
121
|
+
ls.setItem(CACHED_VERSION_KEY, version);
|
|
122
|
+
ls.setItem(LAST_CHECK_KEY, Date.now().toString());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Best-effort caching
|
|
127
|
+
}
|
|
128
|
+
},
|
|
83
129
|
/**
|
|
84
130
|
* Fetch latest version from npm registry
|
|
85
131
|
*/
|
|
86
132
|
async fetchLatestVersion() {
|
|
87
133
|
try {
|
|
134
|
+
const cfg = this.getConfig();
|
|
135
|
+
// Try to get cached version first
|
|
136
|
+
const cachedVersion = this.getCachedVersion(cfg.checkInterval);
|
|
137
|
+
if (cachedVersion !== null) {
|
|
138
|
+
return cachedVersion;
|
|
139
|
+
}
|
|
140
|
+
// Fetch from network
|
|
88
141
|
const response = await this.fetchFromNpmRegistry();
|
|
89
142
|
if (!response.ok) {
|
|
90
143
|
return this.handleHttpError();
|
|
91
144
|
}
|
|
92
145
|
const data = await response.json();
|
|
93
|
-
|
|
146
|
+
const latest = this.extractVersionFromResponse(data);
|
|
147
|
+
// Cache for future use
|
|
148
|
+
this.cacheLatestVersion(latest);
|
|
149
|
+
return latest;
|
|
94
150
|
}
|
|
95
151
|
catch {
|
|
96
152
|
// For network errors or other issues, don't block CLI usage
|
|
@@ -199,9 +255,6 @@ export const VersionChecker = Object.freeze({
|
|
|
199
255
|
const comparison = this.compareVersions(currentVersion, latestVersion);
|
|
200
256
|
const isOutdated = comparison < 0;
|
|
201
257
|
const updateAvailable = isOutdated;
|
|
202
|
-
// Update last check time
|
|
203
|
-
const lastCheckKey = 'zintrust_last_version_check';
|
|
204
|
-
globalThis.localStorage?.setItem?.(lastCheckKey, Date.now().toString());
|
|
205
258
|
return {
|
|
206
259
|
currentVersion,
|
|
207
260
|
latestVersion,
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.1.
|
|
2
|
+
* @zintrust/core v0.1.38
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-01-
|
|
8
|
+
* Built: 2026-01-29T12:40:27.475Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.23';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-01-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-01-29T12:40:27.435Z'; // Replaced during build
|
|
25
25
|
import { Application } from './boot/Application.js';
|
|
26
26
|
import { AwsSigV4 } from './common/index.js';
|
|
27
27
|
import { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationDiscovery.d.ts","sourceRoot":"","sources":["../../../src/migrations/MigrationDiscovery.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;4BACL,MAAM,OAAO,MAAM,GAAG,MAAM;4BAI5B,MAAM,aAAa,MAAM,GAAG,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"MigrationDiscovery.d.ts","sourceRoot":"","sources":["../../../src/migrations/MigrationDiscovery.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;4BACL,MAAM,OAAO,MAAM,GAAG,MAAM;4BAI5B,MAAM,aAAa,MAAM,GAAG,MAAM,EAAE;EAiD5D,CAAC"}
|
|
@@ -8,9 +8,41 @@ export const MigrationDiscovery = Object.freeze({
|
|
|
8
8
|
if (!fs.existsSync(dir))
|
|
9
9
|
return [];
|
|
10
10
|
const files = fs.readdirSync(dir);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// Only consider files that match the timestamped migration naming convention
|
|
12
|
+
// e.g. 20260109074544_create_users_table.ts — avoids importing stray files.
|
|
13
|
+
const migrationNameRe = /^\d{14,}_.+$/;
|
|
14
|
+
const normalizeExt = (ext) => (ext.startsWith('.') ? ext : `.${ext}`);
|
|
15
|
+
const ext = normalizeExt(extension);
|
|
16
|
+
const pick = (extToPick) => files.filter((f) => f.endsWith(extToPick) && !f.startsWith('index.') && migrationNameRe.test(f));
|
|
17
|
+
const primary = pick(ext);
|
|
18
|
+
if (primary.length > 0) {
|
|
19
|
+
return primary.toSorted((a, b) => a.localeCompare(b)).map((f) => path.join(dir, f));
|
|
20
|
+
}
|
|
21
|
+
// Fallback to JS/TS variants to support compiled migrations in dist builds.
|
|
22
|
+
let fallbackExts;
|
|
23
|
+
switch (ext) {
|
|
24
|
+
case '.ts':
|
|
25
|
+
fallbackExts = ['.js', '.mjs', '.cjs'];
|
|
26
|
+
break;
|
|
27
|
+
case '.js':
|
|
28
|
+
fallbackExts = ['.mjs', '.cjs', '.ts'];
|
|
29
|
+
break;
|
|
30
|
+
case '.mjs':
|
|
31
|
+
fallbackExts = ['.js', '.cjs', '.ts'];
|
|
32
|
+
break;
|
|
33
|
+
case '.cjs':
|
|
34
|
+
fallbackExts = ['.js', '.mjs', '.ts'];
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
fallbackExts = ['.ts', '.js', '.mjs', '.cjs'];
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
for (const candidate of fallbackExts) {
|
|
41
|
+
const found = pick(candidate);
|
|
42
|
+
if (found.length > 0) {
|
|
43
|
+
return found.toSorted((a, b) => a.localeCompare(b)).map((f) => path.join(dir, f));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [];
|
|
15
47
|
},
|
|
16
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/orm/Database.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/orm/Database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQxD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,IAAI,OAAO,CAAC;IACvB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OA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,CAAC;AAIH,eAAO,MAAM,oBAAoB,GAC/B,SAAQ,cAAc,GAAG,SAAqB,EAC9C,uBAA0B,KACzB,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAMxC,CAAC;AAEF,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,UAAU,SAAY,GAAG,SAAS,CAgBtF;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAWnD"}
|
package/src/orm/Database.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Database Manager
|
|
3
3
|
* Central database connection management and query execution
|
|
4
4
|
*/
|
|
5
|
-
import Logger from '../config/logger.js';
|
|
6
5
|
import { OpenTelemetry } from '../observability/OpenTelemetry.js';
|
|
7
6
|
import { Env } from '../config/env.js';
|
|
8
7
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
@@ -178,10 +177,6 @@ const createQueryHandlers = (writeAdapter, _readAdapters, eventEmitter, connecte
|
|
|
178
177
|
if (registry.length === 0) {
|
|
179
178
|
throw ErrorFactory.createConfigError('No database adapters are registered. Call DatabaseAdapterRegistry.register() during startup to register database adapters.');
|
|
180
179
|
}
|
|
181
|
-
Logger.debug('Using DB adapter', {
|
|
182
|
-
type: adapter?.getType?.(),
|
|
183
|
-
hasRegistry: registry,
|
|
184
|
-
});
|
|
185
180
|
return executeQuery(adapter, eventEmitter, sql, parameters, 'query');
|
|
186
181
|
},
|
|
187
182
|
async queryOne(sql, parameters = [], isRead = false) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IDatabase } from '@zintrust/core
|
|
1
|
+
import { MigrationSchema, type Blueprint } from '@zintrust/core';
|
|
2
|
+
import type { IDatabase } from '@zintrust/core';
|
|
3
3
|
|
|
4
4
|
export interface Migration {
|
|
5
5
|
up(db: IDatabase): Promise<void>;
|
|
@@ -15,7 +15,7 @@ export const migration: Migration = {
|
|
|
15
15
|
table.string('title');
|
|
16
16
|
table.text('description').nullable();
|
|
17
17
|
table.string('status').default('pending');
|
|
18
|
-
table.
|
|
18
|
+
table.integer('user_id');
|
|
19
19
|
table.foreign('user_id').references('id').on('users').onDelete('CASCADE');
|
|
20
20
|
table.timestamps();
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IDatabase } from '@zintrust/core
|
|
1
|
+
import { MigrationSchema, type Blueprint } from '@zintrust/core';
|
|
2
|
+
import type { IDatabase } from '@zintrust/core';
|
|
3
3
|
|
|
4
4
|
export interface Migration {
|
|
5
5
|
up(db: IDatabase): Promise<void>;
|