Update script to add database version 23/301023/3
authorSukhyungKang <shine.kang@samsung.com>
Tue, 7 Nov 2023 07:20:01 +0000 (16:20 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Thu, 9 Nov 2023 08:06:31 +0000 (17:06 +0900)
Change-Id: I6fc568d64b2a67b4ebe2535b8a0fae54ca8b1c7d
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
CMakeLists.txt
packaging/notification.spec
scripts/505.notification_upgrade.sh.in [moved from scripts/505.notification_upgrade.sh with 95% similarity]

index c07856c..e5e2ab9 100644 (file)
@@ -9,3 +9,9 @@ ENABLE_TESTING()
 SET(NOTIFICATION_UNIT_TESTS notification-unittests)
 ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS})
 ADD_DEPENDENCIES(${NOTIFICATION_UNIT_TESTS} notification)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/scripts/505.notification_upgrade.sh.in 505.notification_upgrade.sh @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/505.notification_upgrade.sh DESTINATION /usr/share/upgrade/scripts/)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/scripts/505.notification_upgrade.sh.in upgrade.sh @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/upgrade.sh DESTINATION /etc/notification/)
index 78087d9..5f08cd7 100644 (file)
@@ -121,9 +121,6 @@ mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
 sed -i -e 's/<NAME>/notification/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
 
-mkdir -p %{buildroot}%{upgrade_script_path}
-cp -f scripts/505.notification_upgrade.sh %{buildroot}%{upgrade_script_path}
-
 %clean
 rm -rf %{buildroot}
 
@@ -146,6 +143,7 @@ fi
 %{_bindir}/notification_init
 %attr(0755,root,root) %{upgrade_script_path}/505.notification_upgrade.sh
 #%{_bindir}/notification-test-app
+%attr(0755,root,root) /etc/notification/upgrade.sh
 
 %files devel
 %defattr(-,root,root,-)
similarity index 95%
rename from scripts/505.notification_upgrade.sh
rename to scripts/505.notification_upgrade.sh.in
index 95ed350..57541a0 100644 (file)
@@ -9,15 +9,18 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
 DB_DIR=/opt/dbspace
 DB_NOTIFICATION=$DB_DIR/.notification.db
+DB_VERSION=1
 
 CheckListTable() {
   ADDED_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep b_event_handler_click_on_button_7`
 
   CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_list)' | grep check_box`
 
+  CURRENT_VERSION=`sqlite3 $DB_NOTIFICATION 'PRAGMA user_version'`
+
   echo "## Check list table"
 
-  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
+  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}" ] || [ ${CURRENT_VERSION} -ne ${DB_VERSION} ]; then
     echo "column empty"
     return 1
   else
@@ -31,9 +34,11 @@ CheckTemplateTable() {
 
   CHECKBOX_COLUMN=`sqlite3 $DB_NOTIFICATION 'PRAGMA table_info(noti_template)' | grep check_box`
 
+  CURRENT_VERSION=`sqlite3 $DB_NOTIFICATION 'PRAGMA user_version'`
+
   echo "## Check template table"
 
-  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}"]; then
+  if [ -z "${ADDED_COLUMN}" ] || [ -z "${CHECKBOX_COLUMN}" ] || [ ${CURRENT_VERSION} -ne ${DB_VERSION} ]; then
     echo "column empty"
     return 1
   else
@@ -42,6 +47,13 @@ CheckTemplateTable() {
   fi
 }
 
+UpdateDBVersion() {
+sqlite3 $DB_NOTIFICATION << EOF
+
+PRAGMA user_version = ${DB_VERSION};
+EOF
+}
+
 UpdateListTable() {
 sqlite3 $DB_NOTIFICATION << EOF
 
@@ -224,6 +236,7 @@ UpdateNotiDB() {
   RESULT=$?
   if [ ${RESULT} == 1 ]; then
     UpdateListTable
+    UpdateDBVersion
     echo "update list table"
   else
     echo "list table already updated"