@sqlml/ui 0.3.4
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/LICENSE +21 -0
- package/README.md +36 -0
- package/client/dist/assets/index-CpRgSqWF.js +672 -0
- package/client/dist/assets/index-DMcl7wPy.css +1 -0
- package/client/dist/favicon.svg +17 -0
- package/client/dist/index.html +14 -0
- package/package.json +66 -0
- package/server/dist/app.module.d.ts +2 -0
- package/server/dist/app.module.js +55 -0
- package/server/dist/app.module.js.map +1 -0
- package/server/dist/common/entities/workspace.entity.d.ts +42 -0
- package/server/dist/common/entities/workspace.entity.js +48 -0
- package/server/dist/common/entities/workspace.entity.js.map +1 -0
- package/server/dist/core/core.module.d.ts +2 -0
- package/server/dist/core/core.module.js +31 -0
- package/server/dist/core/core.module.js.map +1 -0
- package/server/dist/core/health.controller.d.ts +7 -0
- package/server/dist/core/health.controller.js +37 -0
- package/server/dist/core/health.controller.js.map +1 -0
- package/server/dist/core/root.controller.d.ts +4 -0
- package/server/dist/core/root.controller.js +95 -0
- package/server/dist/core/root.controller.js.map +1 -0
- package/server/dist/core/sqlml.service.d.ts +80 -0
- package/server/dist/core/sqlml.service.js +237 -0
- package/server/dist/core/sqlml.service.js.map +1 -0
- package/server/dist/main.d.ts +1 -0
- package/server/dist/main.js +45 -0
- package/server/dist/main.js.map +1 -0
- package/server/dist/modules/config/config.controller.d.ts +18 -0
- package/server/dist/modules/config/config.controller.js +76 -0
- package/server/dist/modules/config/config.controller.js.map +1 -0
- package/server/dist/modules/config/config.module.d.ts +2 -0
- package/server/dist/modules/config/config.module.js +27 -0
- package/server/dist/modules/config/config.module.js.map +1 -0
- package/server/dist/modules/config/config.service.d.ts +31 -0
- package/server/dist/modules/config/config.service.js +376 -0
- package/server/dist/modules/config/config.service.js.map +1 -0
- package/server/dist/modules/database/database-connection.entity.d.ts +17 -0
- package/server/dist/modules/database/database-connection.entity.js +78 -0
- package/server/dist/modules/database/database-connection.entity.js.map +1 -0
- package/server/dist/modules/database/database.controller.d.ts +103 -0
- package/server/dist/modules/database/database.controller.js +236 -0
- package/server/dist/modules/database/database.controller.js.map +1 -0
- package/server/dist/modules/database/database.module.d.ts +2 -0
- package/server/dist/modules/database/database.module.js +26 -0
- package/server/dist/modules/database/database.module.js.map +1 -0
- package/server/dist/modules/database/database.service.d.ts +102 -0
- package/server/dist/modules/database/database.service.js +415 -0
- package/server/dist/modules/database/database.service.js.map +1 -0
- package/server/dist/modules/migration/migration-history.entity.d.ts +14 -0
- package/server/dist/modules/migration/migration-history.entity.js +66 -0
- package/server/dist/modules/migration/migration-history.entity.js.map +1 -0
- package/server/dist/modules/migration/migration-template.entity.d.ts +10 -0
- package/server/dist/modules/migration/migration-template.entity.js +52 -0
- package/server/dist/modules/migration/migration-template.entity.js.map +1 -0
- package/server/dist/modules/migration/migration.controller.d.ts +60 -0
- package/server/dist/modules/migration/migration.controller.js +159 -0
- package/server/dist/modules/migration/migration.controller.js.map +1 -0
- package/server/dist/modules/migration/migration.module.d.ts +2 -0
- package/server/dist/modules/migration/migration.module.js +27 -0
- package/server/dist/modules/migration/migration.module.js.map +1 -0
- package/server/dist/modules/migration/migration.service.d.ts +65 -0
- package/server/dist/modules/migration/migration.service.js +195 -0
- package/server/dist/modules/migration/migration.service.js.map +1 -0
- package/server/dist/modules/schema/dbml-diff.util.d.ts +42 -0
- package/server/dist/modules/schema/dbml-diff.util.js +193 -0
- package/server/dist/modules/schema/dbml-diff.util.js.map +1 -0
- package/server/dist/modules/schema/schema-snapshot.entity.d.ts +13 -0
- package/server/dist/modules/schema/schema-snapshot.entity.js +62 -0
- package/server/dist/modules/schema/schema-snapshot.entity.js.map +1 -0
- package/server/dist/modules/schema/schema.controller.d.ts +62 -0
- package/server/dist/modules/schema/schema.controller.js +188 -0
- package/server/dist/modules/schema/schema.controller.js.map +1 -0
- package/server/dist/modules/schema/schema.module.d.ts +2 -0
- package/server/dist/modules/schema/schema.module.js +30 -0
- package/server/dist/modules/schema/schema.module.js.map +1 -0
- package/server/dist/modules/schema/schema.service.d.ts +53 -0
- package/server/dist/modules/schema/schema.service.js +276 -0
- package/server/dist/modules/schema/schema.service.js.map +1 -0
- package/server/dist/modules/system/process-info.entity.d.ts +8 -0
- package/server/dist/modules/system/process-info.entity.js +44 -0
- package/server/dist/modules/system/process-info.entity.js.map +1 -0
- package/server/dist/modules/system/system.controller.d.ts +25 -0
- package/server/dist/modules/system/system.controller.js +64 -0
- package/server/dist/modules/system/system.controller.js.map +1 -0
- package/server/dist/modules/system/system.module.d.ts +2 -0
- package/server/dist/modules/system/system.module.js +26 -0
- package/server/dist/modules/system/system.module.js.map +1 -0
- package/server/dist/modules/system/system.service.d.ts +25 -0
- package/server/dist/modules/system/system.service.js +100 -0
- package/server/dist/modules/system/system.service.js.map +1 -0
- package/server/dist/modules/workspace/workspace.controller.d.ts +35 -0
- package/server/dist/modules/workspace/workspace.controller.js +132 -0
- package/server/dist/modules/workspace/workspace.controller.js.map +1 -0
- package/server/dist/modules/workspace/workspace.dto.d.ts +9 -0
- package/server/dist/modules/workspace/workspace.dto.js +39 -0
- package/server/dist/modules/workspace/workspace.dto.js.map +1 -0
- package/server/dist/modules/workspace/workspace.module.d.ts +2 -0
- package/server/dist/modules/workspace/workspace.module.js +26 -0
- package/server/dist/modules/workspace/workspace.module.js.map +1 -0
- package/server/dist/modules/workspace/workspace.service.d.ts +44 -0
- package/server/dist/modules/workspace/workspace.service.js +93 -0
- package/server/dist/modules/workspace/workspace.service.js.map +1 -0
- package/server/dist/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MigrationController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const migration_service_1 = require("./migration.service");
|
|
19
|
+
let MigrationController = class MigrationController {
|
|
20
|
+
constructor(migrationService) {
|
|
21
|
+
this.migrationService = migrationService;
|
|
22
|
+
}
|
|
23
|
+
listMigrations() {
|
|
24
|
+
return this.migrationService.listMigrationFiles();
|
|
25
|
+
}
|
|
26
|
+
getHistory(workspaceId) {
|
|
27
|
+
return this.migrationService.getHistory(workspaceId);
|
|
28
|
+
}
|
|
29
|
+
getTemplates() {
|
|
30
|
+
return this.migrationService.getTemplates();
|
|
31
|
+
}
|
|
32
|
+
async getMigrationContent(version, direction) {
|
|
33
|
+
const migrations = await this.migrationService.listMigrationFiles();
|
|
34
|
+
const migration = migrations.find((m) => m.version === version);
|
|
35
|
+
if (!migration) {
|
|
36
|
+
return { content: null };
|
|
37
|
+
}
|
|
38
|
+
const filename = direction === 'up' ? migration.upFile : migration.downFile;
|
|
39
|
+
const content = await this.migrationService.getMigrationContent(filename);
|
|
40
|
+
return { version, direction, filename, content };
|
|
41
|
+
}
|
|
42
|
+
createTemplate(data) {
|
|
43
|
+
return this.migrationService.createTemplate(data);
|
|
44
|
+
}
|
|
45
|
+
deleteTemplate(name) {
|
|
46
|
+
return this.migrationService.deleteTemplate(name);
|
|
47
|
+
}
|
|
48
|
+
async generateMigration(data) {
|
|
49
|
+
return this.migrationService.generateMigration(data.name, data.dryRun);
|
|
50
|
+
}
|
|
51
|
+
async runMigrations(data) {
|
|
52
|
+
return this.migrationService.runMigrations(data.force, data.dryRun);
|
|
53
|
+
}
|
|
54
|
+
async revertMigrations(data) {
|
|
55
|
+
return this.migrationService.revertMigrations(data.steps, data.dryRun);
|
|
56
|
+
}
|
|
57
|
+
async getMigrationStatus() {
|
|
58
|
+
return this.migrationService.getMigrationStatus();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.MigrationController = MigrationController;
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, common_1.Get)(),
|
|
64
|
+
(0, swagger_1.ApiOperation)({ summary: 'List all migration files' }),
|
|
65
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'List of migrations' }),
|
|
66
|
+
__metadata("design:type", Function),
|
|
67
|
+
__metadata("design:paramtypes", []),
|
|
68
|
+
__metadata("design:returntype", void 0)
|
|
69
|
+
], MigrationController.prototype, "listMigrations", null);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, common_1.Get)('history'),
|
|
72
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get migration execution history' }),
|
|
73
|
+
(0, swagger_1.ApiQuery)({ name: 'workspaceId', description: 'Workspace UUID', required: false }),
|
|
74
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration history' }),
|
|
75
|
+
__param(0, (0, common_1.Query)('workspaceId')),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [String]),
|
|
78
|
+
__metadata("design:returntype", void 0)
|
|
79
|
+
], MigrationController.prototype, "getHistory", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_1.Get)('templates'),
|
|
82
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get migration templates' }),
|
|
83
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'List of templates' }),
|
|
84
|
+
__metadata("design:type", Function),
|
|
85
|
+
__metadata("design:paramtypes", []),
|
|
86
|
+
__metadata("design:returntype", void 0)
|
|
87
|
+
], MigrationController.prototype, "getTemplates", null);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, common_1.Get)(':version/:direction'),
|
|
90
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get migration content' }),
|
|
91
|
+
(0, swagger_1.ApiParam)({ name: 'version', description: 'Migration version' }),
|
|
92
|
+
(0, swagger_1.ApiParam)({ name: 'direction', description: 'up or down' }),
|
|
93
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration SQL content' }),
|
|
94
|
+
__param(0, (0, common_1.Param)('version')),
|
|
95
|
+
__param(1, (0, common_1.Param)('direction')),
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [String, String]),
|
|
98
|
+
__metadata("design:returntype", Promise)
|
|
99
|
+
], MigrationController.prototype, "getMigrationContent", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, common_1.Post)('templates'),
|
|
102
|
+
(0, swagger_1.ApiOperation)({ summary: 'Create a custom template' }),
|
|
103
|
+
(0, swagger_1.ApiResponse)({ status: 201, description: 'Template created' }),
|
|
104
|
+
__param(0, (0, common_1.Body)()),
|
|
105
|
+
__metadata("design:type", Function),
|
|
106
|
+
__metadata("design:paramtypes", [Object]),
|
|
107
|
+
__metadata("design:returntype", void 0)
|
|
108
|
+
], MigrationController.prototype, "createTemplate", null);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, common_1.Delete)('templates/:name'),
|
|
111
|
+
(0, swagger_1.ApiOperation)({ summary: 'Delete a custom template' }),
|
|
112
|
+
(0, swagger_1.ApiParam)({ name: 'name', description: 'Template name' }),
|
|
113
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Template deleted' }),
|
|
114
|
+
__param(0, (0, common_1.Param)('name')),
|
|
115
|
+
__metadata("design:type", Function),
|
|
116
|
+
__metadata("design:paramtypes", [String]),
|
|
117
|
+
__metadata("design:returntype", void 0)
|
|
118
|
+
], MigrationController.prototype, "deleteTemplate", null);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, common_1.Post)('generate'),
|
|
121
|
+
(0, swagger_1.ApiOperation)({ summary: 'Generate a new migration' }),
|
|
122
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration generation result' }),
|
|
123
|
+
__param(0, (0, common_1.Body)()),
|
|
124
|
+
__metadata("design:type", Function),
|
|
125
|
+
__metadata("design:paramtypes", [Object]),
|
|
126
|
+
__metadata("design:returntype", Promise)
|
|
127
|
+
], MigrationController.prototype, "generateMigration", null);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, common_1.Post)('run'),
|
|
130
|
+
(0, swagger_1.ApiOperation)({ summary: 'Run pending migrations' }),
|
|
131
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration run result' }),
|
|
132
|
+
__param(0, (0, common_1.Body)()),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [Object]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], MigrationController.prototype, "runMigrations", null);
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, common_1.Post)('revert'),
|
|
139
|
+
(0, swagger_1.ApiOperation)({ summary: 'Revert migrations' }),
|
|
140
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration revert result' }),
|
|
141
|
+
__param(0, (0, common_1.Body)()),
|
|
142
|
+
__metadata("design:type", Function),
|
|
143
|
+
__metadata("design:paramtypes", [Object]),
|
|
144
|
+
__metadata("design:returntype", Promise)
|
|
145
|
+
], MigrationController.prototype, "revertMigrations", null);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, common_1.Get)('status'),
|
|
148
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get migration status' }),
|
|
149
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Migration status' }),
|
|
150
|
+
__metadata("design:type", Function),
|
|
151
|
+
__metadata("design:paramtypes", []),
|
|
152
|
+
__metadata("design:returntype", Promise)
|
|
153
|
+
], MigrationController.prototype, "getMigrationStatus", null);
|
|
154
|
+
exports.MigrationController = MigrationController = __decorate([
|
|
155
|
+
(0, swagger_1.ApiTags)('migration'),
|
|
156
|
+
(0, common_1.Controller)('migrations'),
|
|
157
|
+
__metadata("design:paramtypes", [migration_service_1.MigrationService])
|
|
158
|
+
], MigrationController);
|
|
159
|
+
//# sourceMappingURL=migration.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.controller.js","sourceRoot":"","sources":["../../../src/modules/migration/migration.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,6CAAyF;AACzF,2DAAuD;AAIhD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAKnE,cAAc;QACZ,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;IACpD,CAAC;IAMD,UAAU,CAAuB,WAAoB;QACnD,OAAO,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC;IAKD,YAAY;QACV,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;IAC9C,CAAC;IAOK,AAAN,KAAK,CAAC,mBAAmB,CACL,OAAe,EACb,SAAwB;QAE5C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,CAAC;QACpE,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;QAEhE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,OAAO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AA,aAAI,GAAE,CAAA;;;;2DAGR;AAKK;IAHL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IACjD,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;;;;6DAG7D;8BAvGU,mBAAmB;IAF/B,IAAA,iBAAO,EAAC,WAAW,CAAC;IACpB,IAAA,mBAAU,EAAC,YAAY,CAAC;qCAEwB,oCAAgB;GADpD,mBAAmB,CAwG/B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MigrationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const migration_controller_1 = require("./migration.controller");
|
|
13
|
+
const migration_service_1 = require("./migration.service");
|
|
14
|
+
const migration_history_entity_1 = require("./migration-history.entity");
|
|
15
|
+
const migration_template_entity_1 = require("./migration-template.entity");
|
|
16
|
+
let MigrationModule = class MigrationModule {
|
|
17
|
+
};
|
|
18
|
+
exports.MigrationModule = MigrationModule;
|
|
19
|
+
exports.MigrationModule = MigrationModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([migration_history_entity_1.MigrationHistory, migration_template_entity_1.MigrationTemplate])],
|
|
22
|
+
controllers: [migration_controller_1.MigrationController],
|
|
23
|
+
providers: [migration_service_1.MigrationService],
|
|
24
|
+
exports: [migration_service_1.MigrationService],
|
|
25
|
+
})
|
|
26
|
+
], MigrationModule);
|
|
27
|
+
//# sourceMappingURL=migration.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.module.js","sourceRoot":"","sources":["../../../src/modules/migration/migration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,iEAA6D;AAC7D,2DAAuD;AACvD,yEAA8D;AAC9D,2EAAgE;AAQzD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAN3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,2CAAgB,EAAE,6CAAiB,CAAC,CAAC,CAAC;QAC1E,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { MigrationHistory } from './migration-history.entity';
|
|
3
|
+
import { MigrationTemplate } from './migration-template.entity';
|
|
4
|
+
import { SqlmlService } from '../../core/sqlml.service';
|
|
5
|
+
export interface MigrationFile {
|
|
6
|
+
version: string;
|
|
7
|
+
name: string;
|
|
8
|
+
upFile: string;
|
|
9
|
+
downFile: string;
|
|
10
|
+
hasUp: boolean;
|
|
11
|
+
hasDown: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class MigrationService {
|
|
14
|
+
private historyRepository;
|
|
15
|
+
private templateRepository;
|
|
16
|
+
private sqlmlService;
|
|
17
|
+
constructor(historyRepository: Repository<MigrationHistory>, templateRepository: Repository<MigrationTemplate>, sqlmlService: SqlmlService);
|
|
18
|
+
listMigrationFiles(): Promise<MigrationFile[]>;
|
|
19
|
+
getMigrationContent(filename: string): Promise<string | null>;
|
|
20
|
+
getHistory(workspaceId?: string): Promise<MigrationHistory[]>;
|
|
21
|
+
recordExecution(data: {
|
|
22
|
+
workspaceId: string;
|
|
23
|
+
version: string;
|
|
24
|
+
name: string;
|
|
25
|
+
direction: 'up' | 'down';
|
|
26
|
+
status: 'pending' | 'running' | 'success' | 'failed';
|
|
27
|
+
durationMs?: number;
|
|
28
|
+
sqlContent?: string;
|
|
29
|
+
errorMessage?: string;
|
|
30
|
+
}): Promise<MigrationHistory>;
|
|
31
|
+
getTemplates(): Promise<MigrationTemplate[]>;
|
|
32
|
+
getTemplate(name: string): Promise<MigrationTemplate | null>;
|
|
33
|
+
createTemplate(data: {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
upTemplate: string;
|
|
37
|
+
downTemplate?: string;
|
|
38
|
+
variables?: string[];
|
|
39
|
+
}): Promise<MigrationTemplate>;
|
|
40
|
+
deleteTemplate(name: string): Promise<void>;
|
|
41
|
+
generateMigration(name: string, dryRun?: boolean): Promise<{
|
|
42
|
+
success: boolean;
|
|
43
|
+
output: string;
|
|
44
|
+
error?: string;
|
|
45
|
+
}>;
|
|
46
|
+
runMigrations(force?: boolean, dryRun?: boolean): Promise<{
|
|
47
|
+
success: boolean;
|
|
48
|
+
output: string;
|
|
49
|
+
migrations: string[];
|
|
50
|
+
error?: string;
|
|
51
|
+
}>;
|
|
52
|
+
revertMigrations(steps?: number, dryRun?: boolean): Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
output: string;
|
|
55
|
+
migrations: string[];
|
|
56
|
+
error?: string;
|
|
57
|
+
}>;
|
|
58
|
+
getMigrationStatus(): Promise<{
|
|
59
|
+
success: boolean;
|
|
60
|
+
output: string;
|
|
61
|
+
pending: string[];
|
|
62
|
+
applied: string[];
|
|
63
|
+
error?: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MigrationService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const migration_history_entity_1 = require("./migration-history.entity");
|
|
20
|
+
const migration_template_entity_1 = require("./migration-template.entity");
|
|
21
|
+
const sqlml_service_1 = require("../../core/sqlml.service");
|
|
22
|
+
let MigrationService = class MigrationService {
|
|
23
|
+
constructor(historyRepository, templateRepository, sqlmlService) {
|
|
24
|
+
this.historyRepository = historyRepository;
|
|
25
|
+
this.templateRepository = templateRepository;
|
|
26
|
+
this.sqlmlService = sqlmlService;
|
|
27
|
+
}
|
|
28
|
+
async listMigrationFiles() {
|
|
29
|
+
const files = await this.sqlmlService.listMigrations();
|
|
30
|
+
const migrations = new Map();
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const match = file.match(/^(\d+)_(.+)\.(up|down)\.sql$/);
|
|
33
|
+
if (!match)
|
|
34
|
+
continue;
|
|
35
|
+
const [, version, name, direction] = match;
|
|
36
|
+
const key = `${version}_${name}`;
|
|
37
|
+
if (!migrations.has(key)) {
|
|
38
|
+
migrations.set(key, {
|
|
39
|
+
version,
|
|
40
|
+
name,
|
|
41
|
+
upFile: '',
|
|
42
|
+
downFile: '',
|
|
43
|
+
hasUp: false,
|
|
44
|
+
hasDown: false,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const migration = migrations.get(key);
|
|
48
|
+
if (direction === 'up') {
|
|
49
|
+
migration.upFile = file;
|
|
50
|
+
migration.hasUp = true;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
migration.downFile = file;
|
|
54
|
+
migration.hasDown = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return Array.from(migrations.values()).sort((a, b) => a.version.localeCompare(b.version));
|
|
58
|
+
}
|
|
59
|
+
async getMigrationContent(filename) {
|
|
60
|
+
return this.sqlmlService.readMigration(filename);
|
|
61
|
+
}
|
|
62
|
+
async getHistory(workspaceId) {
|
|
63
|
+
const where = workspaceId ? { workspaceId } : {};
|
|
64
|
+
return this.historyRepository.find({
|
|
65
|
+
where,
|
|
66
|
+
order: { executedAt: 'DESC' },
|
|
67
|
+
take: 100,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async recordExecution(data) {
|
|
71
|
+
const history = this.historyRepository.create(data);
|
|
72
|
+
return this.historyRepository.save(history);
|
|
73
|
+
}
|
|
74
|
+
async getTemplates() {
|
|
75
|
+
return this.templateRepository.find({
|
|
76
|
+
order: { isBuiltin: 'DESC', name: 'ASC' },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async getTemplate(name) {
|
|
80
|
+
return this.templateRepository.findOne({ where: { name } });
|
|
81
|
+
}
|
|
82
|
+
async createTemplate(data) {
|
|
83
|
+
const template = this.templateRepository.create({
|
|
84
|
+
...data,
|
|
85
|
+
isBuiltin: false,
|
|
86
|
+
});
|
|
87
|
+
return this.templateRepository.save(template);
|
|
88
|
+
}
|
|
89
|
+
async deleteTemplate(name) {
|
|
90
|
+
await this.templateRepository.delete({ name, isBuiltin: false });
|
|
91
|
+
}
|
|
92
|
+
async generateMigration(name, dryRun) {
|
|
93
|
+
let command = `migration:generate ${name}`;
|
|
94
|
+
if (dryRun) {
|
|
95
|
+
command += ' --dry-run';
|
|
96
|
+
}
|
|
97
|
+
const { stdout, stderr } = await this.sqlmlService.execCli(command);
|
|
98
|
+
const hasError = stderr.length > 0 &&
|
|
99
|
+
!stderr.toLowerCase().includes('warn') &&
|
|
100
|
+
!stderr.toLowerCase().includes('notice');
|
|
101
|
+
return {
|
|
102
|
+
success: !hasError,
|
|
103
|
+
output: stdout,
|
|
104
|
+
error: hasError ? stderr : undefined,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async runMigrations(force, dryRun) {
|
|
108
|
+
let command = 'migration:up --force';
|
|
109
|
+
if (dryRun) {
|
|
110
|
+
command += ' --dry-run';
|
|
111
|
+
}
|
|
112
|
+
const { stdout, stderr } = await this.sqlmlService.execCli(command);
|
|
113
|
+
const hasError = stderr.length > 0 &&
|
|
114
|
+
!stderr.toLowerCase().includes('warn') &&
|
|
115
|
+
!stderr.toLowerCase().includes('notice');
|
|
116
|
+
const migrations = [];
|
|
117
|
+
const migrationMatches = stdout.matchAll(/(?:running|applied|migrating|executed)\s+(\S+)/gi);
|
|
118
|
+
for (const m of migrationMatches) {
|
|
119
|
+
migrations.push(m[1]);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
success: !hasError,
|
|
123
|
+
output: stdout,
|
|
124
|
+
migrations,
|
|
125
|
+
error: hasError ? stderr : undefined,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async revertMigrations(steps, dryRun) {
|
|
129
|
+
let command = 'migration:down --force';
|
|
130
|
+
if (steps && steps > 0) {
|
|
131
|
+
command += ` --steps ${steps}`;
|
|
132
|
+
}
|
|
133
|
+
if (dryRun) {
|
|
134
|
+
command += ' --dry-run';
|
|
135
|
+
}
|
|
136
|
+
const { stdout, stderr } = await this.sqlmlService.execCli(command);
|
|
137
|
+
const hasError = stderr.length > 0 &&
|
|
138
|
+
!stderr.toLowerCase().includes('warn') &&
|
|
139
|
+
!stderr.toLowerCase().includes('notice');
|
|
140
|
+
const migrations = [];
|
|
141
|
+
const migrationMatches = stdout.matchAll(/(?:reverting|reverted|rolling back)\s+(\S+)/gi);
|
|
142
|
+
for (const m of migrationMatches) {
|
|
143
|
+
migrations.push(m[1]);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
success: !hasError,
|
|
147
|
+
output: stdout,
|
|
148
|
+
migrations,
|
|
149
|
+
error: hasError ? stderr : undefined,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async getMigrationStatus() {
|
|
153
|
+
const { stdout, stderr } = await this.sqlmlService.execCli('migration:status');
|
|
154
|
+
const hasError = stderr.length > 0 &&
|
|
155
|
+
!stderr.toLowerCase().includes('warn') &&
|
|
156
|
+
!stderr.toLowerCase().includes('notice');
|
|
157
|
+
const pending = [];
|
|
158
|
+
const applied = [];
|
|
159
|
+
const lines = stdout.split('\n');
|
|
160
|
+
for (const line of lines) {
|
|
161
|
+
const trimmed = line.trim();
|
|
162
|
+
if (trimmed.match(/pending/i) &&
|
|
163
|
+
!trimmed.toLowerCase().startsWith('status')) {
|
|
164
|
+
const nameMatch = trimmed.match(/^(\S+)/);
|
|
165
|
+
if (nameMatch) {
|
|
166
|
+
pending.push(nameMatch[1]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (trimmed.match(/applied|executed|done/i) &&
|
|
170
|
+
!trimmed.toLowerCase().startsWith('status')) {
|
|
171
|
+
const nameMatch = trimmed.match(/^(\S+)/);
|
|
172
|
+
if (nameMatch) {
|
|
173
|
+
applied.push(nameMatch[1]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
success: !hasError,
|
|
179
|
+
output: stdout,
|
|
180
|
+
pending,
|
|
181
|
+
applied,
|
|
182
|
+
error: hasError ? stderr : undefined,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
exports.MigrationService = MigrationService;
|
|
187
|
+
exports.MigrationService = MigrationService = __decorate([
|
|
188
|
+
(0, common_1.Injectable)(),
|
|
189
|
+
__param(0, (0, typeorm_1.InjectRepository)(migration_history_entity_1.MigrationHistory)),
|
|
190
|
+
__param(1, (0, typeorm_1.InjectRepository)(migration_template_entity_1.MigrationTemplate)),
|
|
191
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
192
|
+
typeorm_2.Repository,
|
|
193
|
+
sqlml_service_1.SqlmlService])
|
|
194
|
+
], MigrationService);
|
|
195
|
+
//# sourceMappingURL=migration.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.service.js","sourceRoot":"","sources":["../../../src/modules/migration/migration.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AACrC,yEAA8D;AAC9D,2EAAgE;AAChE,4DAAwD;AAYjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YAEU,iBAA+C,EAE/C,kBAAiD,EACjD,YAA0B;QAH1B,sBAAiB,GAAjB,iBAAiB,CAA8B;QAE/C,uBAAkB,GAAlB,kBAAkB,CAA+B;QACjD,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAKJ,KAAK,CAAC,kBAAkB;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;QAGvD,M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AAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,QAAQ;YAClB,MAAM,EAAE,MAAM;YACd,OAAO;YACP,OAAO;YACP,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACrC,CAAC;IACJ,CAAC;CACF,CAAA;AApSY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,2CAAgB,CAAC,CAAA;IAElC,WAAA,IAAA,0BAAgB,EAAC,6CAAiB,CAAC,CAAA;qCADT,oBAAU;QAET,oBAAU;QAChB,4BAAY;GANzB,gBAAgB,CAoS5B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface DbmlColumn {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
notNull: boolean;
|
|
5
|
+
primaryKey: boolean;
|
|
6
|
+
unique: boolean;
|
|
7
|
+
default?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DbmlTable {
|
|
10
|
+
name: string;
|
|
11
|
+
schema?: string;
|
|
12
|
+
columns: DbmlColumn[];
|
|
13
|
+
}
|
|
14
|
+
export interface ColumnDiff {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'added' | 'removed' | 'modified';
|
|
17
|
+
column: DbmlColumn;
|
|
18
|
+
oldColumn?: DbmlColumn;
|
|
19
|
+
changes?: {
|
|
20
|
+
field: string;
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
export interface TableDiff {
|
|
26
|
+
name: string;
|
|
27
|
+
schema?: string;
|
|
28
|
+
type: 'added' | 'removed' | 'modified';
|
|
29
|
+
columns?: DbmlColumn[];
|
|
30
|
+
columnDiffs?: ColumnDiff[];
|
|
31
|
+
}
|
|
32
|
+
export interface SchemaDiffResult {
|
|
33
|
+
tables: TableDiff[];
|
|
34
|
+
hasChanges: boolean;
|
|
35
|
+
summary: {
|
|
36
|
+
tablesAdded: number;
|
|
37
|
+
tablesRemoved: number;
|
|
38
|
+
tablesModified: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare function parseDbmlTables(content: string): DbmlTable[];
|
|
42
|
+
export declare function diffSchemas(oldContent: string, newContent: string): SchemaDiffResult;
|