sqlmorpheus 0.1.8 → 0.1.9
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/dist/index.d.mts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +808 -789
- package/dist/index.mjs +808 -789
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -29,26 +29,31 @@ interface MigrationInstructions {
|
|
|
29
29
|
* Stores changes to column (0: name in the database, last: current name in code)
|
|
30
30
|
*/
|
|
31
31
|
renamedColumns: string[][];
|
|
32
|
-
allowedMigrations:
|
|
32
|
+
allowedMigrations: AllowedMigrations;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare class Migrations {
|
|
36
|
-
private
|
|
36
|
+
private toVersion;
|
|
37
37
|
private alwaysAllowed;
|
|
38
|
+
private fromVersion;
|
|
39
|
+
private migrationData;
|
|
40
|
+
private notAllowedChanges;
|
|
41
|
+
reset(dbInstructions: DatabaseInstructions, fromVersion: number): void;
|
|
38
42
|
private getEntry;
|
|
39
43
|
private getTableName;
|
|
40
|
-
|
|
44
|
+
verifyMigration(tableName: string, type: keyof AllowedMigrations): void;
|
|
45
|
+
checkIfAllowed(throwIfNotAllowed: boolean): boolean;
|
|
41
46
|
allowMigration(version: number, table: string | Class<BackendTable>, ...allowedMigrations: (keyof AllowedMigrations)[]): void;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
recreateTable(table: Class<BackendTable> | string): void;
|
|
47
|
+
renameTable(version: number, oldTableName: string, newTable: string | Class<BackendTable>): void;
|
|
48
|
+
renameColumn(version: number, table: string | Class<BackendTable>, oldColumn: string, newColumn: string): void;
|
|
49
|
+
recreateTableImp(table: Class<BackendTable> | string): void;
|
|
50
|
+
recreateTable(version: number, table: Class<BackendTable> | string): void;
|
|
46
51
|
getMigrationData(): Record<string, MigrationInstructions>;
|
|
47
52
|
loopRenamedColumns(tableName: string, callback: (oldColumnName: string, newColumnName: string) => void): void;
|
|
48
53
|
getUpdatedColumnName(tableName: string, oldColumnName: string): string;
|
|
49
54
|
willBeRecreated(tableName: string): boolean;
|
|
50
55
|
}
|
|
51
|
-
type PublicMigrations = Pick<Migrations, "recreateTable" | "renameTable" | "renameColumn" | "allowMigration"
|
|
56
|
+
type PublicMigrations = Pick<Migrations, "recreateTable" | "renameTable" | "renameColumn" | "allowMigration">;
|
|
52
57
|
|
|
53
58
|
interface SqlChanges {
|
|
54
59
|
up: string;
|
|
@@ -80,7 +85,9 @@ interface DatabaseInstructions {
|
|
|
80
85
|
tables: Class<BackendTable>[] | TableObjects;
|
|
81
86
|
version: number;
|
|
82
87
|
configPath: string;
|
|
88
|
+
throwIfNotAllowed: boolean;
|
|
83
89
|
loggerMode?: "silent" | "noLog" | "normal" | "debug";
|
|
90
|
+
alwaysAllowedMigrations?: AllowedMigrations;
|
|
84
91
|
/**
|
|
85
92
|
* Custom migrations that will run before any database changes are applied.
|
|
86
93
|
* @param migrations The migration object that will be validated after this.
|
|
@@ -118,10 +125,10 @@ declare function DbTable<T extends BackendTable>(tableName: string, primaryKey?:
|
|
|
118
125
|
*/
|
|
119
126
|
declare function ForeignKey<TOther extends BackendTable>(toTable: Class<TOther>, toColumn: keyof TOther, onDelete?: ForeignKeyActions, onUpdate?: ForeignKeyActions): (table: any, context: any) => void;
|
|
120
127
|
|
|
121
|
-
declare function prepareMigration(db: DatabaseAccess,
|
|
122
|
-
declare function runPreparedMigrations(db: DatabaseAccess,
|
|
128
|
+
declare function prepareMigration(db: DatabaseAccess, dbInstructions: DatabaseInstructions, overwriteExisting?: boolean): Promise<void>;
|
|
129
|
+
declare function runPreparedMigrations(db: DatabaseAccess, dbInstructions: DatabaseInstructions): Promise<void>;
|
|
123
130
|
declare function prepareAndRunMigration(db: DatabaseAccess, instructions: DatabaseInstructions, overwriteExisting?: boolean): Promise<void>;
|
|
124
|
-
declare function runMigrationWithoutHistory(db: DatabaseAccess,
|
|
125
|
-
declare function rollback(db: DatabaseAccess,
|
|
131
|
+
declare function runMigrationWithoutHistory(db: DatabaseAccess, dbInstructions: DatabaseInstructions): Promise<void>;
|
|
132
|
+
declare function rollback(db: DatabaseAccess, dbInstructions: DatabaseInstructions, toVersion: number): Promise<void>;
|
|
126
133
|
|
|
127
|
-
export { type DatabaseAccess, type DatabaseInstructions, DbTable, ForeignKey, prepareAndRunMigration, prepareMigration, rollback, runMigrationWithoutHistory, runPreparedMigrations };
|
|
134
|
+
export { type DatabaseAccess, type DatabaseInstructions, DbTable, ForeignKey, type PublicMigrations, type SqlChanges, prepareAndRunMigration, prepareMigration, rollback, runMigrationWithoutHistory, runPreparedMigrations };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,26 +29,31 @@ interface MigrationInstructions {
|
|
|
29
29
|
* Stores changes to column (0: name in the database, last: current name in code)
|
|
30
30
|
*/
|
|
31
31
|
renamedColumns: string[][];
|
|
32
|
-
allowedMigrations:
|
|
32
|
+
allowedMigrations: AllowedMigrations;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare class Migrations {
|
|
36
|
-
private
|
|
36
|
+
private toVersion;
|
|
37
37
|
private alwaysAllowed;
|
|
38
|
+
private fromVersion;
|
|
39
|
+
private migrationData;
|
|
40
|
+
private notAllowedChanges;
|
|
41
|
+
reset(dbInstructions: DatabaseInstructions, fromVersion: number): void;
|
|
38
42
|
private getEntry;
|
|
39
43
|
private getTableName;
|
|
40
|
-
|
|
44
|
+
verifyMigration(tableName: string, type: keyof AllowedMigrations): void;
|
|
45
|
+
checkIfAllowed(throwIfNotAllowed: boolean): boolean;
|
|
41
46
|
allowMigration(version: number, table: string | Class<BackendTable>, ...allowedMigrations: (keyof AllowedMigrations)[]): void;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
recreateTable(table: Class<BackendTable> | string): void;
|
|
47
|
+
renameTable(version: number, oldTableName: string, newTable: string | Class<BackendTable>): void;
|
|
48
|
+
renameColumn(version: number, table: string | Class<BackendTable>, oldColumn: string, newColumn: string): void;
|
|
49
|
+
recreateTableImp(table: Class<BackendTable> | string): void;
|
|
50
|
+
recreateTable(version: number, table: Class<BackendTable> | string): void;
|
|
46
51
|
getMigrationData(): Record<string, MigrationInstructions>;
|
|
47
52
|
loopRenamedColumns(tableName: string, callback: (oldColumnName: string, newColumnName: string) => void): void;
|
|
48
53
|
getUpdatedColumnName(tableName: string, oldColumnName: string): string;
|
|
49
54
|
willBeRecreated(tableName: string): boolean;
|
|
50
55
|
}
|
|
51
|
-
type PublicMigrations = Pick<Migrations, "recreateTable" | "renameTable" | "renameColumn" | "allowMigration"
|
|
56
|
+
type PublicMigrations = Pick<Migrations, "recreateTable" | "renameTable" | "renameColumn" | "allowMigration">;
|
|
52
57
|
|
|
53
58
|
interface SqlChanges {
|
|
54
59
|
up: string;
|
|
@@ -80,7 +85,9 @@ interface DatabaseInstructions {
|
|
|
80
85
|
tables: Class<BackendTable>[] | TableObjects;
|
|
81
86
|
version: number;
|
|
82
87
|
configPath: string;
|
|
88
|
+
throwIfNotAllowed: boolean;
|
|
83
89
|
loggerMode?: "silent" | "noLog" | "normal" | "debug";
|
|
90
|
+
alwaysAllowedMigrations?: AllowedMigrations;
|
|
84
91
|
/**
|
|
85
92
|
* Custom migrations that will run before any database changes are applied.
|
|
86
93
|
* @param migrations The migration object that will be validated after this.
|
|
@@ -118,10 +125,10 @@ declare function DbTable<T extends BackendTable>(tableName: string, primaryKey?:
|
|
|
118
125
|
*/
|
|
119
126
|
declare function ForeignKey<TOther extends BackendTable>(toTable: Class<TOther>, toColumn: keyof TOther, onDelete?: ForeignKeyActions, onUpdate?: ForeignKeyActions): (table: any, context: any) => void;
|
|
120
127
|
|
|
121
|
-
declare function prepareMigration(db: DatabaseAccess,
|
|
122
|
-
declare function runPreparedMigrations(db: DatabaseAccess,
|
|
128
|
+
declare function prepareMigration(db: DatabaseAccess, dbInstructions: DatabaseInstructions, overwriteExisting?: boolean): Promise<void>;
|
|
129
|
+
declare function runPreparedMigrations(db: DatabaseAccess, dbInstructions: DatabaseInstructions): Promise<void>;
|
|
123
130
|
declare function prepareAndRunMigration(db: DatabaseAccess, instructions: DatabaseInstructions, overwriteExisting?: boolean): Promise<void>;
|
|
124
|
-
declare function runMigrationWithoutHistory(db: DatabaseAccess,
|
|
125
|
-
declare function rollback(db: DatabaseAccess,
|
|
131
|
+
declare function runMigrationWithoutHistory(db: DatabaseAccess, dbInstructions: DatabaseInstructions): Promise<void>;
|
|
132
|
+
declare function rollback(db: DatabaseAccess, dbInstructions: DatabaseInstructions, toVersion: number): Promise<void>;
|
|
126
133
|
|
|
127
|
-
export { type DatabaseAccess, type DatabaseInstructions, DbTable, ForeignKey, prepareAndRunMigration, prepareMigration, rollback, runMigrationWithoutHistory, runPreparedMigrations };
|
|
134
|
+
export { type DatabaseAccess, type DatabaseInstructions, DbTable, ForeignKey, type PublicMigrations, type SqlChanges, prepareAndRunMigration, prepareMigration, rollback, runMigrationWithoutHistory, runPreparedMigrations };
|