diff --git a/ormconfig.yml b/ormconfig.yml index 67ac59c..bfda4a2 100644 --- a/ormconfig.yml +++ b/ormconfig.yml @@ -3,6 +3,7 @@ library: type: sqlite database: ./test-paths/typeorm/library.db + cache: true entities: - ./src/main/entities/library/*.js migrations: diff --git a/src/main/core/database.ts b/src/main/core/database.ts index 7b0ce90..fef89cc 100644 --- a/src/main/core/database.ts +++ b/src/main/core/database.ts @@ -15,6 +15,7 @@ const connectionOptions: MyConnectionOptions = Object.values(Databases).reduce( prev[database] = { type: 'sqlite', database: path.resolve(databasePath, `${database}.db`), + cache: true, entities: [`./src/main/entities/${database}/*.js`], migrations: [`./src/main/migrations/${database}/*.js`], cli: { diff --git a/src/main/migrations/library/1587423043395-initial_migration.ts b/src/main/migrations/library/1587513640202-initial_migration.ts similarity index 99% rename from src/main/migrations/library/1587423043395-initial_migration.ts rename to src/main/migrations/library/1587513640202-initial_migration.ts index ec18c28..d12fd3b 100644 --- a/src/main/migrations/library/1587423043395-initial_migration.ts +++ b/src/main/migrations/library/1587513640202-initial_migration.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -export class initialMigration1587423043395 implements MigrationInterface { - name = 'initialMigration1587423043395'; +export class initialMigration1587513640202 implements MigrationInterface { + name = 'initialMigration1587513640202'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( @@ -683,9 +683,14 @@ export class initialMigration1587423043395 implements MigrationInterface { `CREATE INDEX "IDX_1f53233757f73a30345a845b36" ON "work_author_author_roles_author_role" ("authorRoleId") `, undefined ); + await queryRunner.query( + `CREATE TABLE "query-result-cache" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "identifier" varchar, "time" bigint NOT NULL, "duration" integer NOT NULL, "query" text NOT NULL, "result" text NOT NULL)`, + undefined + ); } public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE "query-result-cache"`, undefined); await queryRunner.query(`DROP INDEX "IDX_1f53233757f73a30345a845b36"`, undefined); await queryRunner.query(`DROP INDEX "IDX_ad6eb15a9e307bbc0071e45584"`, undefined); await queryRunner.query(