@@ -183,7 +183,7 @@ export class DatabaseManager {
|
||||
|
||||
// @public
|
||||
export type DatabaseManagerOptions = {
|
||||
migrations: PluginDatabaseManager['migrations'];
|
||||
migrations?: PluginDatabaseManager['migrations'];
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -403,8 +403,8 @@ export type PluginCacheManager = {
|
||||
// @public
|
||||
export interface PluginDatabaseManager {
|
||||
getClient(): Promise<Knex>;
|
||||
migrations: {
|
||||
apply: boolean;
|
||||
migrations?: {
|
||||
skip?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -656,5 +656,5 @@ export function useHotMemoize<T>(_module: NodeModule, valueFactory: () => T): T;
|
||||
|
||||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/database/types.d.ts:26:12 - (tsdoc-undefined-tag) The TSDoc tag "@default" is not defined in this configuration
|
||||
// src/database/types.d.ts:23:12 - (tsdoc-undefined-tag) The TSDoc tag "@default" is not defined in this configuration
|
||||
```
|
||||
|
||||
@@ -63,17 +63,17 @@ describe('DatabaseManager', () => {
|
||||
const database = DatabaseManager.fromConfig(config);
|
||||
const client = database.forPlugin('test');
|
||||
|
||||
expect(client.migrations.apply).toBe(true);
|
||||
expect(client.migrations?.skip).toBe(false);
|
||||
});
|
||||
|
||||
it('handles migrations options', () => {
|
||||
const config = new ConfigReader(backendConfig);
|
||||
const database = DatabaseManager.fromConfig(config, {
|
||||
migrations: { apply: false },
|
||||
migrations: { skip: true },
|
||||
});
|
||||
const client = database.forPlugin('test');
|
||||
|
||||
expect(client.migrations.apply).toBe(false);
|
||||
expect(client.migrations?.skip).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ function pluginPath(pluginId: string): string {
|
||||
* @public
|
||||
*/
|
||||
export type DatabaseManagerOptions = {
|
||||
migrations: PluginDatabaseManager['migrations'];
|
||||
migrations?: PluginDatabaseManager['migrations'];
|
||||
};
|
||||
|
||||
/** @public */
|
||||
@@ -92,7 +92,7 @@ export class DatabaseManager {
|
||||
return _this.getDatabase(pluginId);
|
||||
},
|
||||
migrations: {
|
||||
apply: true,
|
||||
skip: false,
|
||||
..._this.options?.migrations,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -34,16 +34,13 @@ export interface PluginDatabaseManager {
|
||||
/**
|
||||
* This property is used to control the behavior of database migrations.
|
||||
*/
|
||||
migrations: {
|
||||
migrations?: {
|
||||
/**
|
||||
* apply can be used to determine if database migrations
|
||||
* should be performed.
|
||||
* skip database migrations. Useful if connecting to a read-only database.
|
||||
*
|
||||
* Useful if connecting to a read-only database.
|
||||
*
|
||||
* @default true
|
||||
* @default false
|
||||
*/
|
||||
apply: boolean;
|
||||
skip?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user