rake-db 2.0.0 → 2.0.2
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/.env +1 -3
- package/.env.local +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.esm.js +993 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +996 -21
- package/dist/index.js.map +1 -1
- package/migrations/20221017181504_createUser.ts +14 -0
- package/migrations/20221017200111_createProfile.ts +10 -0
- package/migrations/20221017200252_createChat.ts +9 -0
- package/migrations/20221017200326_createChatUser.ts +7 -0
- package/migrations/20221017200900_createMessage.ts +12 -0
- package/migrations/20221017201235_createGeoSchema.ts +5 -0
- package/migrations/{20221009210157_first.ts → 20221017210011_createCountry.ts} +2 -2
- package/migrations/20221017210133_createCity.ts +9 -0
- package/package.json +1 -1
- package/src/commands/generate.test.ts +6 -6
- package/src/commands/generate.ts +3 -3
- package/src/commands/migrateOrRollback.test.ts +20 -9
- package/src/commands/migrateOrRollback.ts +18 -6
- package/src/common.test.ts +13 -0
- package/src/common.ts +16 -3
- package/src/index.ts +4 -0
- package/src/migration/changeTable.ts +4 -2
- package/src/migration/createTable.ts +21 -16
- package/src/migration/migration.test.ts +93 -0
- package/src/migration/migration.ts +137 -2
- package/src/migration/migrationUtils.ts +17 -10
- package/src/rakeDb.ts +2 -2
- package/src/test-utils.ts +3 -1
- package/tsconfig.json +1 -1
- package/migrations/20221009210200_second.ts +0 -5
package/.env
CHANGED
package/.env.local
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
DATABASE_URL=postgres://
|
|
1
|
+
DATABASE_URL=postgres://postgres:@localhost:5432/porm
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { MaybeArray, AdapterOptions, ColumnTypes, EmptyObject, RawExpression, ColumnType,
|
|
1
|
+
import { QueryLogOptions, MaybeArray, AdapterOptions, ColumnTypes, EmptyObject, RawExpression, ColumnType, ColumnsShape, IndexColumnOptions, IndexOptions, TransactionAdapter, QueryLogObject, QueryResultRow, QueryInput, TypeParsers, QueryResult, QueryArraysResult, ForeignKeyOptions } from 'pqb';
|
|
2
2
|
|
|
3
3
|
declare type MigrationConfig = {
|
|
4
4
|
migrationsPath: string;
|
|
5
5
|
migrationsTable: string;
|
|
6
6
|
requireTs(path: string): void;
|
|
7
|
-
};
|
|
7
|
+
} & QueryLogOptions;
|
|
8
8
|
|
|
9
9
|
declare const createDb: (arg: MaybeArray<AdapterOptions>, config: MigrationConfig) => Promise<void>;
|
|
10
10
|
declare const dropDb: (arg: MaybeArray<AdapterOptions>) => Promise<void>;
|
|
11
11
|
|
|
12
|
+
declare const generate: (config: MigrationConfig, args: string[]) => Promise<void>;
|
|
13
|
+
|
|
14
|
+
declare const migrate: (options: MaybeArray<AdapterOptions>, config: MigrationConfig, args: string[]) => Promise<void>;
|
|
15
|
+
declare const rollback: (options: MaybeArray<AdapterOptions>, config: MigrationConfig, args: string[]) => Promise<void>;
|
|
16
|
+
|
|
12
17
|
declare function add(item: ColumnType, options?: {
|
|
13
18
|
dropMode?: DropMode;
|
|
14
19
|
}): ChangeItem;
|
|
@@ -52,14 +57,30 @@ declare type ChangeTableOptions = {
|
|
|
52
57
|
comment?: string | [string, string] | null;
|
|
53
58
|
};
|
|
54
59
|
declare type ChangeTableCallback = (t: TableChanger) => TableChangeData;
|
|
60
|
+
declare type ColumnIndex = {
|
|
61
|
+
columns: IndexColumnOptions[];
|
|
62
|
+
options: IndexOptions;
|
|
63
|
+
};
|
|
64
|
+
declare type ColumnComment = {
|
|
65
|
+
column: string;
|
|
66
|
+
comment: string | null;
|
|
67
|
+
};
|
|
55
68
|
declare type JoinTableOptions = {
|
|
56
69
|
tableName?: string;
|
|
57
70
|
comment?: string;
|
|
58
71
|
dropMode?: DropMode;
|
|
59
72
|
};
|
|
73
|
+
declare type ExtensionOptions = {
|
|
74
|
+
schema?: string;
|
|
75
|
+
version?: string;
|
|
76
|
+
cascade?: boolean;
|
|
77
|
+
};
|
|
60
78
|
declare class Migration extends TransactionAdapter {
|
|
61
79
|
up: boolean;
|
|
62
|
-
|
|
80
|
+
log?: QueryLogObject;
|
|
81
|
+
constructor(tx: TransactionAdapter, up: boolean, options: QueryLogOptions);
|
|
82
|
+
query<T extends QueryResultRow = any>(query: QueryInput, types?: TypeParsers, log?: QueryLogObject | undefined): Promise<QueryResult<T>>;
|
|
83
|
+
arrays<R extends any[] = any[]>(query: QueryInput, types?: TypeParsers, log?: QueryLogObject | undefined): Promise<QueryArraysResult<R>>;
|
|
63
84
|
createTable(tableName: string, options: TableOptions, fn: ColumnsShapeCallback): Promise<void>;
|
|
64
85
|
createTable(tableName: string, fn: ColumnsShapeCallback): Promise<void>;
|
|
65
86
|
dropTable(tableName: string, options: TableOptions, fn: ColumnsShapeCallback): Promise<void>;
|
|
@@ -84,6 +105,15 @@ declare class Migration extends TransactionAdapter {
|
|
|
84
105
|
name?: string;
|
|
85
106
|
}): Promise<void>;
|
|
86
107
|
renameColumn(tableName: string, from: string, to: string): Promise<void>;
|
|
108
|
+
createSchema(schemaName: string): Promise<QueryResult<any>>;
|
|
109
|
+
dropSchema(schemaName: string): Promise<QueryResult<any>>;
|
|
110
|
+
createExtension(name: string, options?: ExtensionOptions & {
|
|
111
|
+
ifNotExists?: boolean;
|
|
112
|
+
}): Promise<QueryResult<any>>;
|
|
113
|
+
dropExtension(name: string, options?: {
|
|
114
|
+
ifExists?: boolean;
|
|
115
|
+
cascade?: boolean;
|
|
116
|
+
}): Promise<QueryResult<any>>;
|
|
87
117
|
tableExists(tableName: string): Promise<boolean>;
|
|
88
118
|
columnExists(tableName: string, columnName: string): Promise<boolean>;
|
|
89
119
|
constraintExists(constraintName: string): Promise<boolean>;
|
|
@@ -91,4 +121,6 @@ declare class Migration extends TransactionAdapter {
|
|
|
91
121
|
|
|
92
122
|
declare const change: (fn: (db: Migration, up: boolean) => Promise<void>) => void;
|
|
93
123
|
|
|
94
|
-
|
|
124
|
+
declare const rakeDb: (options: MaybeArray<AdapterOptions>, partialConfig?: Partial<MigrationConfig>, args?: string[]) => Promise<void>;
|
|
125
|
+
|
|
126
|
+
export { ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnIndex, ColumnsShapeCallback, DropMode, ExtensionOptions, JoinTableOptions, Migration, TableOptions, change, createDb, dropDb, generate, migrate, rakeDb, rollback };
|