From 3cf70c83f7a64a117e98673044957e4a12e5cc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 18 Feb 2019 15:27:39 +0100 Subject: [PATCH] MOBILE-2386 course: Migrate logs database schema --- src/core/course/providers/log-helper.ts | 64 +++++++++++++------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/core/course/providers/log-helper.ts b/src/core/course/providers/log-helper.ts index 24bde0ed5..02a9aa92b 100644 --- a/src/core/course/providers/log-helper.ts +++ b/src/core/course/providers/log-helper.ts @@ -13,7 +13,7 @@ // limitations under the License. import { Injectable } from '@angular/core'; -import { CoreSitesProvider } from '@providers/sites'; +import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites'; import { CoreTextUtilsProvider } from '@providers/utils/text'; import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; @@ -27,39 +27,43 @@ export class CoreCourseLogHelperProvider { // Variables for database. static ACTIVITY_LOG_TABLE = 'course_activity_log'; - protected tablesSchema = [ - { - name: CoreCourseLogHelperProvider.ACTIVITY_LOG_TABLE, - columns: [ - { - name: 'component', - type: 'TEXT' - }, - { - name: 'componentid', - type: 'INTEGER' - }, - { - name: 'ws', - type: 'TEXT' - }, - { - name: 'data', - type: 'TEXT' - }, - { - name: 'time', - type: 'INTEGER' - } - ], - primaryKeys: ['component', 'componentid', 'ws', 'time'] - } - ]; + protected siteSchema: CoreSiteSchema = { + name: 'CoreCourseOfflineProvider', + version: 1, + tables: [ + { + name: CoreCourseLogHelperProvider.ACTIVITY_LOG_TABLE, + columns: [ + { + name: 'component', + type: 'TEXT' + }, + { + name: 'componentid', + type: 'INTEGER' + }, + { + name: 'ws', + type: 'TEXT' + }, + { + name: 'data', + type: 'TEXT' + }, + { + name: 'time', + type: 'INTEGER' + } + ], + primaryKeys: ['component', 'componentid', 'ws', 'time'] + } + ] + }; constructor(protected sitesProvider: CoreSitesProvider, protected timeUtils: CoreTimeUtilsProvider, protected textUtils: CoreTextUtilsProvider, protected utils: CoreUtilsProvider, protected appProvider: CoreAppProvider) { - this.sitesProvider.createTablesFromSchema(this.tablesSchema); + this.sitesProvider.registerSiteSchema(this.siteSchema); } /**