Skip to content

Commit

Permalink
core: create triggers after resetting database
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed May 21, 2024
1 parent 9693c8e commit f719beb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/core/__e2e__/__snapshots__/pricing.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ exports[`get web pricing tier > get monthly web tier > monthly-web-pricing 1`] =
}
`;
exports[`get web pricing tier > get monthly web tier > yearly-ios-pricing 1`] = `
{
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get web pricing tier > get yearly web tier > yearly-web-pricing 1`] = `
{
"country": Any<String>,
Expand Down
1 change: 0 additions & 1 deletion packages/core/__e2e__/sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ async function cleanup(...devices) {
await device.syncer.stop();
await device.user.logout();
device.eventManager.unsubscribeAll();
await device.reset();
}
EV.unsubscribeAll();
}
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class Database {
this.sql().withTables(),
new NNMigrationProvider()
);
await this.onInit(this.sql() as Kysely<RawDatabaseSchema>);
await this.initCollections();
return true;
}
Expand Down Expand Up @@ -282,7 +283,7 @@ class Database {
this._sql = (await createDatabase<RawDatabaseSchema>("notesnook", {
...this.options.sqliteOptions,
migrationProvider: new NNMigrationProvider(),
onInit: (db) => createTriggers(db)
onInit: (db) => this.onInit(db)
})) as unknown as Kysely<DatabaseSchema>;

await this.sanitizer.init();
Expand All @@ -296,6 +297,10 @@ class Database {
}
}

private async onInit(db: Kysely<RawDatabaseSchema>) {
await createTriggers(db);
}

async initCollections() {
await this.legacySettings.init();
// collections
Expand Down
3 changes: 2 additions & 1 deletion packages/core/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { defineConfig } from "vitest/config";

const IS_E2E = process.env.IS_E2E === "true";
const IS_CI = !!process.env.CI;

export default defineConfig({
test: {
Expand All @@ -30,7 +31,7 @@ export default defineConfig({
exclude: ["src/utils/templates/html/languages/*.js"],
include: ["src/**/*.ts"]
},
retry: 1,
retry: IS_CI ? 1 : 0,
exclude: ["__benches__/**/*.bench.ts"],
include: [
...(IS_E2E ? ["__e2e__/**/*.test.{js,ts}"] : []),
Expand Down

0 comments on commit f719beb

Please sign in to comment.