Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mysql/interfaces/mysql-webhook-store-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface MySqlWebhookStoreOptions {
* Apply the store's pending migrations at startup, one statement at a time under a lock (`GET_LOCK()`), so processes
* that start together migrate once, and a run that failed resumes where it stopped. With `false`, startup fails with
* a `WebhookSchemaError` while the schema is behind this version of the package: apply them with
* `npx nest-webhooks migrate`, or with your own migration tool (`MySqlWebhookStore.migrationStatements()`). Default:
* `true`, except when `NODE_ENV` is `production`.
* `npx @nestjs/webhooks migrate`, or with your own migration tool (`MySqlWebhookStore.migrationStatements()`).
* Default: `true`, except when `NODE_ENV` is `production`.
*/
migrate?: boolean;
}
2 changes: 1 addition & 1 deletion lib/postgres/errors/webhook-schema.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WebhooksError } from '../../errors/webhooks.error.js';
* await app.init();
* } catch (error) {
* if (error instanceof WebhookSchemaError) {
* console.error(`Run: npx nest-webhooks migrate --schema ${error.schema} (at ${error.version}, needs ${error.requiredVersion})`);
* console.error(`Run: npx @nestjs/webhooks migrate --schema ${error.schema} (at ${error.version}, needs ${error.requiredVersion})`);
* }
* throw error;
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface PostgresWebhookStoreOptions {
/**
* Apply the store's pending migrations at startup, in one transaction under an advisory lock, so processes that
* start together migrate once. With `false`, startup fails with a `WebhookSchemaError` while the schema is behind
* this version of the package: apply them with `npx nest-webhooks migrate`, or with your own migration tool
* this version of the package: apply them with `npx @nestjs/webhooks migrate`, or with your own migration tool
* (`PostgresWebhookStore.migrationSql()`). Default: `true`, except when `NODE_ENV` is `production`.
*/
migrate?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/mysql/migrations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('a MySQL schema behind the code, and one ahead of it', () => {
expect(error).toMatchObject({ name: 'WebhookSchemaError', schema: 'm_behind', version: 0, requiredVersion: 1 });
expect((error as Error).message).toBe(
'MySqlWebhookStore: schema "m_behind" is at version 0, and this version of @nestjs/webhooks needs version 1. Apply its migrations: ' +
'set `migrate: true` to apply them at startup, run `npx nest-webhooks migrate --url <database url> --schema m_behind`, ' +
'set `migrate: true` to apply them at startup, run `npx @nestjs/webhooks migrate --url <database url> --schema m_behind`, ' +
"or apply `MySqlWebhookStore.migrationSql({ schema: 'm_behind', from: 0 })` with your migration tool.",
);
await expect(behind.getEndpoint('any')).rejects.toThrow(WebhookSchemaError);
Expand Down
8 changes: 4 additions & 4 deletions tests/postgres/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('nest-webhooks', () => {
it('prints its usage for --help, and on stderr, exiting with 1, for no command, an unknown one or an unknown option', async () => {
const help = await run(['--help']);
expect(help).toMatchObject({ code: 0, err: '' });
expect(help.out).toMatch(/^Usage: nest-webhooks <command> \[options\]/);
expect(help.out).toMatch(/^Usage: npx @nestjs\/webhooks <command> \[options\]/);
expect(help.out).toContain("\n\nPostgresWebhookStore's schema (@nestjs/webhooks/postgres) or MySqlWebhookStore's (@nestjs/webhooks/mysql):\n\n migrate ");
expect(help.out).toContain('--schema <name> The store\'s schema. Default: nest_webhooks');
expect(await run([])).toEqual({ code: 1, out: '', err: help.out });
Expand All @@ -40,12 +40,12 @@ describe('nest-webhooks', () => {
});

it('needs the database for migrate and status: --url, else DATABASE_URL, of PostgreSQL or MySQL', async () => {
expect(await run(['migrate'])).toEqual({ code: 1, out: '', err: 'nest-webhooks migrate needs the database: pass --url, or set DATABASE_URL.\n' });
expect((await run(['status'])).err).toBe('nest-webhooks status needs the database: pass --url, or set DATABASE_URL.\n');
expect(await run(['migrate'])).toEqual({ code: 1, out: '', err: 'npx @nestjs/webhooks migrate needs the database: pass --url, or set DATABASE_URL.\n' });
expect((await run(['status'])).err).toBe('npx @nestjs/webhooks status needs the database: pass --url, or set DATABASE_URL.\n');
expect(await run(['migrate', '--url', 'sqlite:///tmp/shop.db'])).toEqual({
code: 1,
out: '',
err: 'nest-webhooks migrate takes a database URL that starts with postgres:// or postgresql:// or mysql://.\n',
err: 'npx @nestjs/webhooks migrate takes a database URL that starts with postgres:// or postgresql:// or mysql://.\n',
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/postgres/migrations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('a schema behind the code', () => {
expect(error).toMatchObject({ name: 'WebhookSchemaError', schema: 'm_behind', version: 0, requiredVersion: 1 });
expect((error as Error).message).toBe(
'PostgresWebhookStore: schema "m_behind" is at version 0, and this version of @nestjs/webhooks needs version 1. Apply its migrations: ' +
'set `migrate: true` to apply them at startup, run `npx nest-webhooks migrate --url <database url> --schema m_behind`, ' +
'set `migrate: true` to apply them at startup, run `npx @nestjs/webhooks migrate --url <database url> --schema m_behind`, ' +
"or apply `PostgresWebhookStore.migrationSql({ schema: 'm_behind', from: 0 })` with your migration tool.",
);
await expect(behind.getEndpoint('any')).rejects.toThrow(WebhookSchemaError);
Expand Down