core: create triggers after resetting database

This commit is contained in:
Abdullah Atta
2024-05-21 09:54:33 +05:00
committed by Abdullah Atta
parent 9693c8ea54
commit f719bebe5a
4 changed files with 17 additions and 3 deletions

View File

@@ -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>,

View File

@@ -536,7 +536,6 @@ async function cleanup(...devices) {
await device.syncer.stop();
await device.user.logout();
device.eventManager.unsubscribeAll();
await device.reset();
}
EV.unsubscribeAll();
}

View File

@@ -250,6 +250,7 @@ class Database {
this.sql().withTables(),
new NNMigrationProvider()
);
await this.onInit(this.sql() as Kysely<RawDatabaseSchema>);
await this.initCollections();
return true;
}
@@ -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();
@@ -296,6 +297,10 @@ class Database {
}
}
private async onInit(db: Kysely<RawDatabaseSchema>) {
await createTriggers(db);
}
async initCollections() {
await this.legacySettings.init();
// collections

View File

@@ -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: {
@@ -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}"] : []),