@ftschopp/dynatable-migrations 1.3.1 → 2.0.0
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/CHANGELOG.md +50 -0
- package/README.md +2 -2
- package/USAGE.md +2 -2
- package/dist/cli.js +51 -68
- package/dist/cli.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +3 -2
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +12 -7
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/unlock.js +1 -1
- package/dist/commands/unlock.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +3 -2
- package/dist/commands/up.js.map +1 -1
- package/dist/core/config.d.ts +4 -23
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +72 -102
- package/dist/core/config.js.map +1 -1
- package/dist/core/loader.d.ts +16 -62
- package/dist/core/loader.d.ts.map +1 -1
- package/dist/core/loader.js +165 -216
- package/dist/core/loader.js.map +1 -1
- package/dist/core/runner.d.ts +2 -28
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +181 -218
- package/dist/core/runner.js.map +1 -1
- package/dist/core/tracker.d.ts +10 -65
- package/dist/core/tracker.d.ts.map +1 -1
- package/dist/core/tracker.js +229 -282
- package/dist/core/tracker.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/loader.js
CHANGED
|
@@ -33,11 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.createMigrationLoader = exports.calculateChecksum = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const crypto = __importStar(require("crypto"));
|
|
40
|
+
const module_1 = require("module");
|
|
40
41
|
const semver_1 = require("./semver");
|
|
42
|
+
const nodeRequire = (0, module_1.createRequire)(__filename);
|
|
41
43
|
/**
|
|
42
44
|
* Map a require/import failure to a human-readable category. The same
|
|
43
45
|
* thrown error covers wildly different operator-facing problems —
|
|
@@ -45,7 +47,7 @@ const semver_1 = require("./semver");
|
|
|
45
47
|
* code ran on import and threw" — and prefixing the message with the
|
|
46
48
|
* category cuts triage time significantly.
|
|
47
49
|
*/
|
|
48
|
-
|
|
50
|
+
const categorizeLoadError = (error) => {
|
|
49
51
|
const e = error;
|
|
50
52
|
const code = e?.code;
|
|
51
53
|
const name = e?.name;
|
|
@@ -57,237 +59,184 @@ function categorizeLoadError(error) {
|
|
|
57
59
|
return 'Syntax error';
|
|
58
60
|
}
|
|
59
61
|
return 'Runtime error';
|
|
60
|
-
}
|
|
62
|
+
};
|
|
61
63
|
/**
|
|
62
|
-
*
|
|
64
|
+
* Calculate checksum of a file
|
|
63
65
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
const calculateChecksum = (filePath) => {
|
|
67
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
68
|
+
return crypto.createHash('md5').update(content).digest('hex');
|
|
69
|
+
};
|
|
70
|
+
exports.calculateChecksum = calculateChecksum;
|
|
71
|
+
/**
|
|
72
|
+
* Register ts-node for TypeScript file loading.
|
|
73
|
+
*
|
|
74
|
+
* `ts-node` and `typescript` are declared as optional peerDependencies of
|
|
75
|
+
* this package — consumers who only ever write `.js` migrations don't pay
|
|
76
|
+
* the install cost. The lazy `require` here keeps the module out of the
|
|
77
|
+
* runtime graph until a `.ts` migration is actually loaded, so JS-only
|
|
78
|
+
* users never hit this path.
|
|
79
|
+
*/
|
|
80
|
+
const registerTsNode = async () => {
|
|
81
|
+
try {
|
|
82
|
+
// Check if ts-node is already registered
|
|
83
|
+
const tsNodeSymbol = Symbol.for('ts-node.register.instance');
|
|
84
|
+
if (process[tsNodeSymbol]) {
|
|
85
|
+
return; // Already registered
|
|
86
|
+
}
|
|
87
|
+
const tsNode = await Promise.resolve().then(() => __importStar(require('ts-node')));
|
|
88
|
+
tsNode.register({
|
|
89
|
+
transpileOnly: true,
|
|
90
|
+
skipProject: true, // Don't use project tsconfig
|
|
91
|
+
compilerOptions: {
|
|
92
|
+
module: 'commonjs',
|
|
93
|
+
target: 'ES2020',
|
|
94
|
+
esModuleInterop: true,
|
|
95
|
+
moduleResolution: 'node',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
77
98
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
101
|
+
throw new Error('ts-node is required to load TypeScript migrations but is not installed. ' +
|
|
102
|
+
'Install it as a dev dependency:\n' +
|
|
103
|
+
' npm install --save-dev ts-node typescript\n' +
|
|
104
|
+
' # or\n' +
|
|
105
|
+
' yarn add --dev ts-node typescript\n' +
|
|
106
|
+
'If your migrations are JavaScript only, rename them from .ts to .js.');
|
|
107
|
+
}
|
|
108
|
+
// Other errors might mean ts-node is already registered differently
|
|
109
|
+
console.warn(`Warning: Could not register ts-node: ${error.message}`);
|
|
84
110
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Validate migration file name format
|
|
114
|
+
* Expected: 1.0.0_migration_name.ts (semver format)
|
|
115
|
+
*/
|
|
116
|
+
const isValidMigrationFileName = (fileName) => /^\d+\.\d+\.\d+_[\w-]+\.(ts|js)$/.test(fileName);
|
|
117
|
+
/**
|
|
118
|
+
* Parse version and name from file name
|
|
119
|
+
*/
|
|
120
|
+
const parseMigrationFileName = (fileName) => {
|
|
121
|
+
const match = fileName.match(/^(\d+\.\d+\.\d+)_([\w-]+)\.(ts|js)$/);
|
|
122
|
+
if (!match || !match[1] || !match[2]) {
|
|
123
|
+
throw new Error(`Invalid migration file name format: ${fileName}. Expected: X.Y.Z_name.ts (semver)`);
|
|
91
124
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.readdirSync(this.migrationsDir)
|
|
104
|
-
.filter((f) => (f.endsWith('.ts') || f.endsWith('.js')) &&
|
|
105
|
-
!f.endsWith('.d.ts') &&
|
|
106
|
-
this.isValidMigrationFileName(f))
|
|
107
|
-
.sort((a, b) => {
|
|
108
|
-
// Sort by semver
|
|
109
|
-
const versionA = a.match(/^(\d+\.\d+\.\d+)/)?.[1] || '0.0.0';
|
|
110
|
-
const versionB = b.match(/^(\d+\.\d+\.\d+)/)?.[1] || '0.0.0';
|
|
111
|
-
return (0, semver_1.compareSemver)(versionA, versionB);
|
|
112
|
-
});
|
|
113
|
-
const migrations = [];
|
|
114
|
-
for (const file of files) {
|
|
115
|
-
const filePath = path.join(this.migrationsDir, file);
|
|
116
|
-
const migration = await this.loadMigration(filePath);
|
|
117
|
-
if (migration) {
|
|
118
|
-
migrations.push(migration);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
this.cachedMigrations = migrations;
|
|
122
|
-
return migrations;
|
|
125
|
+
return { version: match[1], name: match[2] };
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Validate migration structure
|
|
129
|
+
*/
|
|
130
|
+
const validateMigration = (migration, filePath) => {
|
|
131
|
+
if (!migration.version) {
|
|
132
|
+
throw new Error(`Migration ${filePath} is missing 'version' property`);
|
|
133
|
+
}
|
|
134
|
+
if (!migration.name) {
|
|
135
|
+
throw new Error(`Migration ${filePath} is missing 'name' property`);
|
|
123
136
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
if (typeof migration.up !== 'function') {
|
|
138
|
+
throw new Error(`Migration ${filePath} is missing 'up' function or it's not a function`);
|
|
139
|
+
}
|
|
140
|
+
if (typeof migration.down !== 'function') {
|
|
141
|
+
throw new Error(`Migration ${filePath} is missing 'down' function or it's not a function`);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const loadMigration = async (filePath) => {
|
|
145
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
146
|
+
? filePath
|
|
147
|
+
: path.resolve(process.cwd(), filePath);
|
|
148
|
+
const module = await (absolutePath.endsWith('.ts')
|
|
149
|
+
? (async () => {
|
|
150
|
+
await registerTsNode();
|
|
137
151
|
// Clear require cache to reload file
|
|
138
|
-
delete
|
|
152
|
+
delete nodeRequire.cache[absolutePath];
|
|
139
153
|
try {
|
|
140
|
-
|
|
154
|
+
return nodeRequire(absolutePath);
|
|
141
155
|
}
|
|
142
156
|
catch (error) {
|
|
143
|
-
|
|
157
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
158
|
+
throw new Error(`${categorizeLoadError(error)} loading TypeScript migration ${filePath}: ${message}`);
|
|
144
159
|
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// For JavaScript files, use dynamic import
|
|
160
|
+
})()
|
|
161
|
+
: (async () => {
|
|
148
162
|
try {
|
|
149
|
-
|
|
150
|
-
module = await Promise.resolve(`${fileUrl}`).then(s => __importStar(require(s)));
|
|
163
|
+
return await Promise.resolve(`${`file://${absolutePath}`}`).then(s => __importStar(require(s)));
|
|
151
164
|
}
|
|
152
165
|
catch (error) {
|
|
153
|
-
|
|
166
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
167
|
+
throw new Error(`${categorizeLoadError(error)} loading JavaScript migration ${filePath}: ${message}`);
|
|
154
168
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
// Validate migration structure
|
|
162
|
-
this.validateMigration(migration, filePath);
|
|
163
|
-
const fileName = path.basename(filePath);
|
|
164
|
-
const { version, name } = this.parseMigrationFileName(fileName);
|
|
165
|
-
// Calculate checksum
|
|
166
|
-
const checksum = this.calculateChecksum(absolutePath);
|
|
167
|
-
return {
|
|
168
|
-
version,
|
|
169
|
-
name,
|
|
170
|
-
filePath,
|
|
171
|
-
migration,
|
|
172
|
-
checksum,
|
|
173
|
-
};
|
|
169
|
+
})());
|
|
170
|
+
const migration = module.migration || module.default;
|
|
171
|
+
if (!migration) {
|
|
172
|
+
console.warn(`Warning: No migration export found in ${filePath}`);
|
|
173
|
+
return null;
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
moduleResolution: 'node',
|
|
199
|
-
},
|
|
200
|
-
});
|
|
175
|
+
validateMigration(migration, filePath);
|
|
176
|
+
const fileName = path.basename(filePath);
|
|
177
|
+
const { version, name } = parseMigrationFileName(fileName);
|
|
178
|
+
const checksum = (0, exports.calculateChecksum)(absolutePath);
|
|
179
|
+
return { version, name, filePath, migration, checksum };
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Create a migration loader for the given directory.
|
|
183
|
+
*
|
|
184
|
+
* Internally memoizes `loadMigrations()` — the runner consults the loader
|
|
185
|
+
* many times per command (per-version checksum check, per-rollback
|
|
186
|
+
* lookup, status display) — without this, each call re-runs `readdirSync`,
|
|
187
|
+
* re-imports every migration module, and re-md5s every file, turning an
|
|
188
|
+
* O(N) operation into O(N²) in IO and require()s. Call `invalidateCache()`
|
|
189
|
+
* if you need to pick up newly-added files mid-process.
|
|
190
|
+
*/
|
|
191
|
+
const createMigrationLoader = (migrationsDir) => {
|
|
192
|
+
let cachedMigrations = null;
|
|
193
|
+
const loadMigrations = async () => {
|
|
194
|
+
if (cachedMigrations)
|
|
195
|
+
return cachedMigrations;
|
|
196
|
+
if (!fs.existsSync(migrationsDir)) {
|
|
197
|
+
throw new Error(`Migrations directory not found: ${migrationsDir}`);
|
|
201
198
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
const files = fs
|
|
200
|
+
.readdirSync(migrationsDir)
|
|
201
|
+
.filter((f) => (f.endsWith('.ts') || f.endsWith('.js')) &&
|
|
202
|
+
!f.endsWith('.d.ts') &&
|
|
203
|
+
isValidMigrationFileName(f))
|
|
204
|
+
.sort((a, b) => {
|
|
205
|
+
const versionA = a.match(/^(\d+\.\d+\.\d+)/)?.[1] || '0.0.0';
|
|
206
|
+
const versionB = b.match(/^(\d+\.\d+\.\d+)/)?.[1] || '0.0.0';
|
|
207
|
+
return (0, semver_1.compareSemver)(versionA, versionB);
|
|
208
|
+
});
|
|
209
|
+
const loaded = await Promise.all(files.map((f) => loadMigration(path.join(migrationsDir, f))));
|
|
210
|
+
cachedMigrations = loaded.filter((m) => m !== null);
|
|
211
|
+
return cachedMigrations;
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
loadMigrations,
|
|
215
|
+
invalidateCache: () => {
|
|
216
|
+
cachedMigrations = null;
|
|
217
|
+
},
|
|
218
|
+
calculateChecksum: exports.calculateChecksum,
|
|
219
|
+
getPendingMigrations: async (appliedVersions) => {
|
|
220
|
+
const all = await loadMigrations();
|
|
221
|
+
return all.filter((m) => !appliedVersions.includes(m.version));
|
|
222
|
+
},
|
|
223
|
+
getMigration: async (version) => {
|
|
224
|
+
const all = await loadMigrations();
|
|
225
|
+
return all.find((m) => m.version === version) ?? null;
|
|
226
|
+
},
|
|
227
|
+
getNextVersion: async () => {
|
|
228
|
+
const migrations = await loadMigrations();
|
|
229
|
+
const last = migrations[migrations.length - 1];
|
|
230
|
+
if (!last)
|
|
231
|
+
return '0.1.0';
|
|
232
|
+
const parts = last.version.split('.');
|
|
233
|
+
if (parts.length === 3 && parts[0] && parts[1] && parts[2]) {
|
|
234
|
+
const [major, minor, patch] = parts.map((p) => parseInt(p, 10));
|
|
235
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
210
236
|
}
|
|
211
|
-
// Other errors might mean ts-node is already registered differently
|
|
212
|
-
console.warn(`Warning: Could not register ts-node: ${error.message}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Validate migration file name format
|
|
217
|
-
* Expected: 1.0.0_migration_name.ts (semver format)
|
|
218
|
-
*/
|
|
219
|
-
isValidMigrationFileName(fileName) {
|
|
220
|
-
// Match semver: 1.0.0_name.ts or 1.2.3_name.ts
|
|
221
|
-
return /^\d+\.\d+\.\d+_[\w-]+\.(ts|js)$/.test(fileName);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Parse version and name from file name
|
|
225
|
-
*/
|
|
226
|
-
parseMigrationFileName(fileName) {
|
|
227
|
-
const match = fileName.match(/^(\d+\.\d+\.\d+)_([\w-]+)\.(ts|js)$/);
|
|
228
|
-
if (!match || !match[1] || !match[2]) {
|
|
229
|
-
throw new Error(`Invalid migration file name format: ${fileName}. Expected: X.Y.Z_name.ts (semver)`);
|
|
230
|
-
}
|
|
231
|
-
const version = match[1];
|
|
232
|
-
const name = match[2];
|
|
233
|
-
return { version, name };
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Validate migration structure
|
|
237
|
-
*/
|
|
238
|
-
validateMigration(migration, filePath) {
|
|
239
|
-
if (!migration.version) {
|
|
240
|
-
throw new Error(`Migration ${filePath} is missing 'version' property`);
|
|
241
|
-
}
|
|
242
|
-
if (!migration.name) {
|
|
243
|
-
throw new Error(`Migration ${filePath} is missing 'name' property`);
|
|
244
|
-
}
|
|
245
|
-
if (typeof migration.up !== 'function') {
|
|
246
|
-
throw new Error(`Migration ${filePath} is missing 'up' function or it's not a function`);
|
|
247
|
-
}
|
|
248
|
-
if (typeof migration.down !== 'function') {
|
|
249
|
-
throw new Error(`Migration ${filePath} is missing 'down' function or it's not a function`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Get pending migrations (not yet applied)
|
|
254
|
-
*/
|
|
255
|
-
async getPendingMigrations(appliedVersions) {
|
|
256
|
-
const allMigrations = await this.loadMigrations();
|
|
257
|
-
return allMigrations.filter((m) => !appliedVersions.includes(m.version));
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Get migration by version
|
|
261
|
-
*/
|
|
262
|
-
async getMigration(version) {
|
|
263
|
-
const migrations = await this.loadMigrations();
|
|
264
|
-
return migrations.find((m) => m.version === version) || null;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Generate next version number (increments patch by default)
|
|
268
|
-
*/
|
|
269
|
-
async getNextVersion() {
|
|
270
|
-
const migrations = await this.loadMigrations();
|
|
271
|
-
if (migrations.length === 0) {
|
|
272
|
-
return '0.1.0';
|
|
273
|
-
}
|
|
274
|
-
// Get last version
|
|
275
|
-
const lastMigration = migrations[migrations.length - 1];
|
|
276
|
-
if (!lastMigration) {
|
|
277
237
|
return '0.1.0';
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (parts.length === 3 && parts[0] && parts[1] && parts[2]) {
|
|
283
|
-
const major = parseInt(parts[0], 10);
|
|
284
|
-
const minor = parseInt(parts[1], 10);
|
|
285
|
-
const patch = parseInt(parts[2], 10);
|
|
286
|
-
// Increment patch version
|
|
287
|
-
return `${major}.${minor}.${patch + 1}`;
|
|
288
|
-
}
|
|
289
|
-
return '0.1.0';
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
exports.MigrationLoader = MigrationLoader;
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
exports.createMigrationLoader = createMigrationLoader;
|
|
293
242
|
//# sourceMappingURL=loader.js.map
|
package/dist/core/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/core/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/core/loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AACjC,mCAAuC;AAEvC,qCAAyC;AAEzC,MAAM,WAAW,GAAG,IAAA,sBAAa,EAAC,UAAU,CAAC,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAU,EAAE;IACrD,MAAM,CAAC,GAAG,KAAkE,CAAC;IAC7E,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC;IACrB,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,CAAC;IACrB,MAAM,GAAG,GAAG,CAAC,EAAE,OAAO,IAAI,EAAE,CAAC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private tracker;
|
|
11
|
-
private loader;
|
|
12
|
-
constructor(client: DynamoDBDocumentClient, config: MigrationConfig);
|
|
13
|
-
/**
|
|
14
|
-
* Initialize migration system
|
|
15
|
-
*/
|
|
7
|
+
export interface MigrationRunnerHandle {
|
|
16
8
|
initialize(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Run all pending migrations
|
|
19
|
-
*/
|
|
20
9
|
up(options?: RunOptions): Promise<MigrationFile[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Rollback last migration
|
|
23
|
-
*/
|
|
24
10
|
down(steps?: number, dryRun?: boolean): Promise<MigrationFile[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Get migration status
|
|
27
|
-
*/
|
|
28
11
|
status(): Promise<MigrationStatus[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Get current version
|
|
31
|
-
*/
|
|
32
12
|
getCurrentVersion(): Promise<string | null>;
|
|
33
|
-
/**
|
|
34
|
-
* Reset all migrations (rollback everything)
|
|
35
|
-
*/
|
|
36
13
|
reset(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Create migration context
|
|
39
|
-
*/
|
|
40
|
-
private createContext;
|
|
41
14
|
}
|
|
15
|
+
export declare const createMigrationRunner: (client: DynamoDBDocumentClient, config: MigrationConfig) => MigrationRunnerHandle;
|
|
42
16
|
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAa/D,OAAO,EAAE,eAAe,EAAoB,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM7F,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAa/D,OAAO,EAAE,eAAe,EAAoB,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM7F,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACjE,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAwDD,eAAO,MAAM,qBAAqB,GAChC,QAAQ,sBAAsB,EAC9B,QAAQ,eAAe,KACtB,qBAiFF,CAAC"}
|