Skip to content

Commit

Permalink
move trigger until after the insert. not before
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswk committed Oct 6, 2023
1 parent 6f072a7 commit bd3ff7b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/lib/db/event-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ class EventStore implements IEventStore {

async batchStore(events: IBaseEvent[]): Promise<void> {
try {
await this.db(TABLE)
.insert(events.map(this.eventToDbRow))
.returning(EVENT_COLUMNS);
await this.db(TABLE).insert(events.map(this.eventToDbRow));
} catch (error: unknown) {
this.logger.warn(`Failed to store events: ${error}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createGetActiveUsers, type GetActiveUsers } from './getActiveUsers';
import dbInit, { type ITestDb } from '../../../test/e2e/helpers/database-init';
import getLogger from '../../../test/fixtures/no-logger';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.up = function(db, cb) {
$unleash_update_changes_counter$ LANGUAGE plpgsql;
CREATE TRIGGER unleash_update_stat_environment_changes
BEFORE INSERT ON events
AFTER INSERT ON events
FOR EACH ROW EXECUTE FUNCTION unleash_update_stat_environment_changes_counter();
`, cb);
};
Expand Down

0 comments on commit bd3ff7b

Please sign in to comment.