Fix upgrade script 03/152603/6
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 26 Sep 2017 11:53:30 +0000 (20:53 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 11 Oct 2017 11:57:02 +0000 (11:57 +0000)
- Invoke pkg_upgrade tool for updated RO packages
- Change schema of datacontrol table.
- Adjust order of inserting order of datacontrol table.

Change-Id: I218f79acbf89caab9f411b3b6173c6871a1b177c
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
data/updates/upgrade_to_30001.sh.in

index a509d0f..e01da76 100644 (file)
@@ -37,6 +37,34 @@ function migrate_parser_db() {
                "  FOREIGN KEY(app_id,app_control)\n" \
                "  REFERENCES package_app_app_control(app_id,app_control) ON DELETE CASCADE);" | sqlite3 $dbpath
 
+       echo -e "CREATE TABLE IF NOT EXISTS package_app_data_control_privilege (\n" \
+               "  providerid TEXT,\n" \
+               "  privilege TEXT NOT NULL,\n" \
+               "  type TEXT NOT NULL,\n" \
+               "  PRIMARY KEY(providerid, privilege, type)\n" \
+               "  FOREIGN KEY(providerid, type)\n" \
+               "  REFERENCES package_app_data_control(providerid, type) ON DELETE CASCADE);" | sqlite3 $dbpath
+
+       echo -e "ALTER TABLE package_app_data_control RENAME TO package_app_data_control_backup;" | sqlite3 $dbpath
+       echo -e "CREATE TABLE package_app_data_control (\n" \
+       "  app_id TEXT NOT NULL,\n" \
+       "  providerid TEXT NOT NULL,\n" \
+       "  access TEXT NOT NULL,\n" \
+       "  type TEXT NOT NULL,\n" \
+       "  trusted TEXT NOT NULL,\n" \
+       "  PRIMARY KEY(providerid, type)\n" \
+       "  FOREIGN KEY(app_id)\n" \
+       "  REFERENCES package_app_info(app_id) ON DELETE CASCADE);" | sqlite3 $dbpath
+
+       #seperate migration of app data control table by access type for backward compatibility.
+       echo -e "INSERT INTO package_app_data_control(app_id, providerid, access, type, trusted) " \
+       "  SELECT app_id, providerid, access, type, 'false' FROM package_app_data_control_backup WHERE access='readwrite' COLLATE NOCASE;" | sqlite3 $dbpath
+       echo -e "INSERT INTO package_app_data_control(app_id, providerid, access, type, trusted) " \
+       "  SELECT app_id, providerid, access, type, 'false' FROM package_app_data_control_backup WHERE access='writeonly' COLLATE NOCASE;" | sqlite3 $dbpath
+       echo -e "INSERT INTO package_app_data_control(app_id, providerid, access, type, trusted) " \
+       "  SELECT app_id, providerid, access, type, 'false' FROM package_app_data_control_backup WHERE access!='readwrite' COLLATE NOCASE AND access!='writeonly' COLLATE NOCASE;" | sqlite3 $dbpath
+       echo -e "DROP TABLE package_app_data_control_backup;" | sqlite3 $dbpath
+
        echo "DROP TABLE IF EXISTS package_app_icon_section_info;" | sqlite3 $dbpath
        echo "DROP TABLE IF EXISTS package_app_image_info;" | sqlite3 $dbpath
        echo "DROP TABLE IF EXISTS package_app_app_permission;" | sqlite3 $dbpath
@@ -59,3 +87,4 @@ migrate_parser_db $PARSER_DB_PATH
 migrate_user_db
 migrate_cert_db
 
+pkg_upgrade -rof