27 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
28 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
29 Components.utils.import(
"resource://app/jsmodules/sbLocalDatabaseMigrationUtils.jsm");
30 Components.utils.import(
"resource://app/jsmodules/SBJobUtils.jsm");
32 const Cc = Components.classes;
33 const Ci = Components.interfaces;
34 const Cr = Components.results;
37 dump(
"----++++----++++sbLibraryMigration " +
40 "\n----++++----++++\n");
45 SBLocalDatabaseMigrationUtils.BaseMigrationHandler.call(
this);
47 this.fromVersion = 10;
49 this.versionString = this.fromVersion +
" to " +
58 __proto__: SBLocalDatabaseMigrationUtils.BaseMigrationHandler.prototype,
60 classDescription:
'Songbird Migration Handler, version ' + this.versionString,
61 classID: Components.ID(
"{62bb8fb0-8fd8-11dd-ad8b-0800200c9a66}"),
62 contractID: SBLocalDatabaseMigrationUtils.baseHandlerContractID +
"10 to 11",
64 _databaseLocation:
null,
69 migrate:
function sbLibraryMigration_migrate(aLibrary) {
70 this._databaseGUID = aLibrary.databaseGuid;
71 this._databaseLocation = aLibrary.databaseLocation;
73 var query = this._createQuery();
75 query.addQuery(
"begin");
78 query.addQuery(
"alter table resource_properties add obj_secondary_sortable text");
81 query.addQuery(
"drop index idx_resource_properties_property_id_obj_sortable_media_item_id");
82 query.addQuery(
"create index idx_resource_properties_property_id_obj_sortable_obj_secondary_sortable_media_item_id " +
83 "on resource_properties (property_id, obj_sortable, obj_secondary_sortable, media_item_id);");
86 query.addQuery(
"delete from sqlite_stat1");
87 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('simple_media_lists','idx_simple_media_lists_media_item_id_ordinal','10003 5002 1');");
88 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('simple_media_lists','idx_simple_media_lists_member_media_item_id','10003 2');");
89 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('simple_media_lists','idx_simple_media_lists_media_item_id_member_media_item_id','10003 5002 1 1');");
90 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('resource_properties','idx_resource_properties_property_id_obj_sortable_obj_secondary_sortable_media_item_id','133429 3707 6 4 1');");
91 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('resource_properties','sqlite_autoindex_resource_properties_1','133429 14 1');");
92 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('properties','sqlite_autoindex_properties_1','89 1');");
93 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('library_media_item','sqlite_autoindex_library_media_item_1','1 1');");
94 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('resource_properties_fts_all_segdir','sqlite_autoindex_resource_properties_fts_all_segdir_1','18 6 1');");
95 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_list_types','sqlite_autoindex_media_list_types_1','3 1');");
96 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_hidden_media_list_type_id','10009 5005 2');");
97 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_is_list','10009 5005');");
98 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_media_list_type_id','10009 2');");
99 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_content_url','10009 1');");
100 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_created','10009 12');");
101 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','idx_media_items_hidden','10009 5005');");
102 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('media_items','sqlite_autoindex_media_items_1','10009 1');");
103 query.addQuery(
"INSERT INTO sqlite_stat1 VALUES('library_metadata','sqlite_autoindex_library_metadata_1','2 1');");
106 query.addQuery(
"update library_metadata set value = '"
107 + this.toVersion +
"' where name = 'version'");
108 query.addQuery(
"commit");
111 query.addQuery(
"VACUUM");
114 query.setAsyncQuery(
true);
115 query.execute(retval);
117 var sip =
Cc[
"@mozilla.org/supports-interface-pointer;1"]
118 .createInstance(
Ci.nsISupportsInterfacePointer);
121 this._titleText =
"Library Migration Helper";
122 this._statusText =
"Optimizing sort performance...";
123 this.migrationQuery = query;
125 this.startNotificationTimer();
126 SBJobUtils.showProgressDialog(sip.data,
null, 0);
127 this.stopNotificationTimer();
133 var
prefs = Components.classes[
"@mozilla.org/preferences-service;1"]
134 .getService(Components.interfaces.nsIPrefBranch);
135 prefs.setBoolPref(
"songbird.propertycache." +
136 this._databaseGUID +
".invalidSortData",
true);
137 prefs.QueryInterface(
Ci.nsIPrefService).savePrefFile(
null);
140 _createQuery:
function sbLibraryMigration_createQuery() {
141 var query =
Cc[
"@songbirdnest.com/Songbird/DatabaseQuery;1"]
142 .createInstance(
Ci.sbIDatabaseQuery);
143 query.databaseLocation = this._databaseLocation;
144 query.setDatabaseGUID(this._databaseGUID);
156 return XPCOMUtils.generateModule([
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function sbLibraryMigration()
sbDeviceFirmwareAutoCheckForUpdate prototype classID