@ftschopp/dynatable-migrations 1.2.5 → 1.3.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 +14 -0
- package/README.md +12 -0
- package/dist/cli-utils.d.ts +8 -0
- package/dist/cli-utils.d.ts.map +1 -0
- package/dist/cli-utils.js +21 -0
- package/dist/cli-utils.js.map +1 -0
- package/dist/cli.js +25 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/down.d.ts +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +61 -1
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/unlock.d.ts +8 -0
- package/dist/commands/unlock.d.ts.map +1 -0
- package/dist/commands/unlock.js +87 -0
- package/dist/commands/unlock.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +14 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/loader.d.ts +7 -1
- package/dist/core/loader.d.ts.map +1 -1
- package/dist/core/loader.js +35 -6
- package/dist/core/loader.js.map +1 -1
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +6 -0
- package/dist/core/runner.js.map +1 -1
- package/dist/core/tracker.d.ts.map +1 -1
- package/dist/core/tracker.js +23 -12
- package/dist/core/tracker.js.map +1 -1
- package/package.json +35 -4
- package/.gitkeep +0 -0
- package/jest.config.js +0 -8
- package/migrations/.gitkeep +0 -0
- package/src/cli.ts +0 -111
- package/src/commands/create.ts +0 -111
- package/src/commands/down.ts +0 -26
- package/src/commands/init.ts +0 -37
- package/src/commands/status.ts +0 -75
- package/src/commands/up.ts +0 -26
- package/src/core/client.ts +0 -24
- package/src/core/config.ts +0 -140
- package/src/core/errors.ts +0 -55
- package/src/core/loader.ts +0 -256
- package/src/core/lock-heartbeat.test.ts +0 -78
- package/src/core/lock-heartbeat.ts +0 -48
- package/src/core/runner.ts +0 -303
- package/src/core/semver.test.ts +0 -33
- package/src/core/semver.ts +0 -26
- package/src/core/tracker.test.ts +0 -281
- package/src/core/tracker.ts +0 -559
- package/src/index.ts +0 -25
- package/src/templates/migration.ts +0 -92
- package/src/types/index.ts +0 -220
- package/tsconfig.json +0 -19
package/src/types/index.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
|
-
import type {
|
|
3
|
-
ScanCommand,
|
|
4
|
-
QueryCommand,
|
|
5
|
-
GetCommand,
|
|
6
|
-
PutCommand,
|
|
7
|
-
UpdateCommand,
|
|
8
|
-
DeleteCommand,
|
|
9
|
-
BatchGetCommand,
|
|
10
|
-
BatchWriteCommand,
|
|
11
|
-
TransactWriteCommand,
|
|
12
|
-
TransactGetCommand,
|
|
13
|
-
} from '@aws-sdk/lib-dynamodb';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* DynamoDB commands available in migrations
|
|
17
|
-
*/
|
|
18
|
-
export interface DynamoDBCommands {
|
|
19
|
-
ScanCommand: typeof ScanCommand;
|
|
20
|
-
QueryCommand: typeof QueryCommand;
|
|
21
|
-
GetCommand: typeof GetCommand;
|
|
22
|
-
PutCommand: typeof PutCommand;
|
|
23
|
-
UpdateCommand: typeof UpdateCommand;
|
|
24
|
-
DeleteCommand: typeof DeleteCommand;
|
|
25
|
-
BatchGetCommand: typeof BatchGetCommand;
|
|
26
|
-
BatchWriteCommand: typeof BatchWriteCommand;
|
|
27
|
-
TransactWriteCommand: typeof TransactWriteCommand;
|
|
28
|
-
TransactGetCommand: typeof TransactGetCommand;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Migration context provided to up/down functions
|
|
33
|
-
*/
|
|
34
|
-
export interface MigrationContext {
|
|
35
|
-
client: DynamoDBDocumentClient;
|
|
36
|
-
tableName: string;
|
|
37
|
-
tracker: MigrationTracker;
|
|
38
|
-
config: MigrationConfig;
|
|
39
|
-
dynamodb: DynamoDBCommands;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Schema change record for tracking evolution
|
|
44
|
-
*/
|
|
45
|
-
export interface SchemaChange {
|
|
46
|
-
entity: string;
|
|
47
|
-
changes: {
|
|
48
|
-
added?: string[];
|
|
49
|
-
removed?: string[];
|
|
50
|
-
modified?: Array<{
|
|
51
|
-
field: string;
|
|
52
|
-
from: any;
|
|
53
|
-
to: any;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Migration definition
|
|
60
|
-
*/
|
|
61
|
-
export interface Migration {
|
|
62
|
-
version: string;
|
|
63
|
-
name: string;
|
|
64
|
-
description?: string;
|
|
65
|
-
|
|
66
|
-
// Optional schema snapshot for documentation
|
|
67
|
-
schema?: Record<string, any>;
|
|
68
|
-
|
|
69
|
-
// Migration functions
|
|
70
|
-
up: (context: MigrationContext) => Promise<void>;
|
|
71
|
-
down: (context: MigrationContext) => Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Migration record stored in DynamoDB
|
|
76
|
-
*/
|
|
77
|
-
export interface MigrationRecord {
|
|
78
|
-
PK: string; // "SCHEMA#VERSION"
|
|
79
|
-
SK: string; // "v0001"
|
|
80
|
-
version: string;
|
|
81
|
-
name: string;
|
|
82
|
-
description?: string;
|
|
83
|
-
timestamp: string;
|
|
84
|
-
appliedAt: string;
|
|
85
|
-
status: 'applied' | 'rolled_back' | 'failed';
|
|
86
|
-
schemaDefinition?: Record<string, any>;
|
|
87
|
-
schemaChanges?: SchemaChange[];
|
|
88
|
-
checksum?: string; // Hash of migration file
|
|
89
|
-
error?: string; // Error message if failed
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Current schema pointer record
|
|
94
|
-
*/
|
|
95
|
-
export interface CurrentSchemaRecord {
|
|
96
|
-
GSI1PK: string; // "SCHEMA#CURRENT"
|
|
97
|
-
GSI1SK: string; // Current version
|
|
98
|
-
PK: string;
|
|
99
|
-
SK: string;
|
|
100
|
-
currentVersion: string;
|
|
101
|
-
updatedAt: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Migration configuration
|
|
106
|
-
*/
|
|
107
|
-
export interface MigrationConfig {
|
|
108
|
-
tableName: string;
|
|
109
|
-
client: {
|
|
110
|
-
endpoint?: string;
|
|
111
|
-
region: string;
|
|
112
|
-
credentials?: {
|
|
113
|
-
accessKeyId: string;
|
|
114
|
-
secretAccessKey: string;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
migrationsDir?: string;
|
|
118
|
-
trackingPrefix?: string; // Default: "_SCHEMA#VERSION"
|
|
119
|
-
gsi1Name?: string; // Default: "GSI1"
|
|
120
|
-
/**
|
|
121
|
-
* How long an acquired migration lock stays valid before another worker
|
|
122
|
-
* can take it over, in seconds. The runner sends a heartbeat every
|
|
123
|
-
* `lockTtlSeconds / 3` to extend it. Default: 300 (5 minutes).
|
|
124
|
-
*/
|
|
125
|
-
lockTtlSeconds?: number;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Migration tracker interface
|
|
130
|
-
*/
|
|
131
|
-
export interface MigrationTracker {
|
|
132
|
-
/**
|
|
133
|
-
* Initialize migration tracking table/items if needed
|
|
134
|
-
*/
|
|
135
|
-
initialize(): Promise<void>;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Get all applied migrations
|
|
139
|
-
*/
|
|
140
|
-
getAppliedMigrations(): Promise<MigrationRecord[]>;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get current schema version
|
|
144
|
-
*/
|
|
145
|
-
getCurrentVersion(): Promise<string | null>;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Acquire a distributed lock
|
|
149
|
-
*/
|
|
150
|
-
acquireLock(): Promise<boolean>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Release the distributed lock
|
|
154
|
-
*/
|
|
155
|
-
releaseLock(): Promise<void>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Extend the lock's expiration. Throws `ConditionalCheckFailedException`
|
|
159
|
-
* if the lock has already been taken by someone else.
|
|
160
|
-
*/
|
|
161
|
-
refreshLock(): Promise<void>;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Mark migration as applied
|
|
165
|
-
*/
|
|
166
|
-
markAsApplied(
|
|
167
|
-
version: string,
|
|
168
|
-
name: string,
|
|
169
|
-
schemaDefinition?: Record<string, any>,
|
|
170
|
-
schemaChanges?: SchemaChange[],
|
|
171
|
-
checksum?: string
|
|
172
|
-
): Promise<void>;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Mark migration as rolled back
|
|
176
|
-
*/
|
|
177
|
-
markAsRolledBack(version: string): Promise<void>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Mark migration as failed
|
|
181
|
-
*/
|
|
182
|
-
markAsFailed(version: string, error: string): Promise<void>;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Record schema changes
|
|
186
|
-
*/
|
|
187
|
-
recordSchemaChange(change: SchemaChange): Promise<void>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get migration by version
|
|
191
|
-
*/
|
|
192
|
-
getMigration(version: string): Promise<MigrationRecord | null>;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Check if migration was applied
|
|
196
|
-
*/
|
|
197
|
-
isApplied(version: string): Promise<boolean>;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Migration file info
|
|
202
|
-
*/
|
|
203
|
-
export interface MigrationFile {
|
|
204
|
-
version: string;
|
|
205
|
-
name: string;
|
|
206
|
-
filePath: string;
|
|
207
|
-
migration: Migration;
|
|
208
|
-
checksum?: string;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Migration status
|
|
213
|
-
*/
|
|
214
|
-
export interface MigrationStatus {
|
|
215
|
-
version: string;
|
|
216
|
-
name: string;
|
|
217
|
-
status: 'pending' | 'applied' | 'rolled_back' | 'failed';
|
|
218
|
-
appliedAt?: string;
|
|
219
|
-
error?: string;
|
|
220
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@repo/typescript-config/base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"target": "ES2020",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"moduleResolution": "node"
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*"],
|
|
18
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
19
|
-
}
|