rake-db 2.0.1 → 2.0.3
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 +26 -4
- package/dist/index.esm.js +224 -196
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +225 -194
- 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 +2 -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 +2 -1
- 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 +28 -3
- 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,16 +1,19 @@
|
|
|
1
|
-
import { MaybeArray, AdapterOptions, ColumnTypes, EmptyObject, RawExpression, ColumnType, ColumnsShape, IndexColumnOptions, IndexOptions, TransactionAdapter, ForeignKeyOptions } from 'pqb';
|
|
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
12
|
declare const generate: (config: MigrationConfig, args: string[]) => Promise<void>;
|
|
13
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
|
+
|
|
14
17
|
declare function add(item: ColumnType, options?: {
|
|
15
18
|
dropMode?: DropMode;
|
|
16
19
|
}): ChangeItem;
|
|
@@ -67,9 +70,17 @@ declare type JoinTableOptions = {
|
|
|
67
70
|
comment?: string;
|
|
68
71
|
dropMode?: DropMode;
|
|
69
72
|
};
|
|
73
|
+
declare type ExtensionOptions = {
|
|
74
|
+
schema?: string;
|
|
75
|
+
version?: string;
|
|
76
|
+
cascade?: boolean;
|
|
77
|
+
};
|
|
70
78
|
declare class Migration extends TransactionAdapter {
|
|
71
79
|
up: boolean;
|
|
72
|
-
|
|
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>>;
|
|
73
84
|
createTable(tableName: string, options: TableOptions, fn: ColumnsShapeCallback): Promise<void>;
|
|
74
85
|
createTable(tableName: string, fn: ColumnsShapeCallback): Promise<void>;
|
|
75
86
|
dropTable(tableName: string, options: TableOptions, fn: ColumnsShapeCallback): Promise<void>;
|
|
@@ -94,6 +105,15 @@ declare class Migration extends TransactionAdapter {
|
|
|
94
105
|
name?: string;
|
|
95
106
|
}): Promise<void>;
|
|
96
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>>;
|
|
97
117
|
tableExists(tableName: string): Promise<boolean>;
|
|
98
118
|
columnExists(tableName: string, columnName: string): Promise<boolean>;
|
|
99
119
|
constraintExists(constraintName: string): Promise<boolean>;
|
|
@@ -101,4 +121,6 @@ declare class Migration extends TransactionAdapter {
|
|
|
101
121
|
|
|
102
122
|
declare const change: (fn: (db: Migration, up: boolean) => Promise<void>) => void;
|
|
103
123
|
|
|
104
|
-
|
|
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 };
|