From f51236887cce3390899284fd617b53e4ed574888 Mon Sep 17 00:00:00 2001
From: ichung14 <34329462+IChung14@users.noreply.github.com>
Date: Mon, 21 Mar 2022 11:01:54 -0400
Subject: [PATCH] db column name changed. new column - notifyAt - inserted

---
 .../12.json                                   | 254 ++++++++++++++++++
 .../noteapplication/cs398/AddNoteActivity.kt  |   2 +-
 .../cs398/database/NoteDatabase.kt            |   2 +-
 .../noteapplication/cs398/database/Tables.kt  |  17 +-
 4 files changed, 265 insertions(+), 10 deletions(-)
 create mode 100644 NoteApplication/app/schemas/com.noteapplication.cs398.database.NoteDatabase/12.json

diff --git a/NoteApplication/app/schemas/com.noteapplication.cs398.database.NoteDatabase/12.json b/NoteApplication/app/schemas/com.noteapplication.cs398.database.NoteDatabase/12.json
new file mode 100644
index 0000000..f410b22
--- /dev/null
+++ b/NoteApplication/app/schemas/com.noteapplication.cs398.database.NoteDatabase/12.json
@@ -0,0 +1,254 @@
+{
+  "formatVersion": 1,
+  "database": {
+    "version": 12,
+    "identityHash": "e6bb62e2bcb6a5b4c51566481a9037bd",
+    "entities": [
+      {
+        "tableName": "Note",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `content` TEXT NOT NULL, `notify` INTEGER NOT NULL, `notifyAt` INTEGER NOT NULL, `folderId` INTEGER, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`folderId`) REFERENCES `Folder`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
+        "fields": [
+          {
+            "fieldPath": "title",
+            "columnName": "title",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "content",
+            "columnName": "content",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "notify",
+            "columnName": "notify",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "notifyAt",
+            "columnName": "notifyAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "folderId",
+            "columnName": "folderId",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "createdAt",
+            "columnName": "createdAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "updatedAt",
+            "columnName": "updatedAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": [
+          {
+            "table": "Folder",
+            "onDelete": "SET NULL",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "folderId"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          }
+        ]
+      },
+      {
+        "tableName": "Folder",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `parent` INTEGER, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, FOREIGN KEY(`parent`) REFERENCES `Folder`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+        "fields": [
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "parent",
+            "columnName": "parent",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "createdAt",
+            "columnName": "createdAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "updatedAt",
+            "columnName": "updatedAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": [
+          {
+            "table": "Folder",
+            "onDelete": "CASCADE",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "parent"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          }
+        ]
+      },
+      {
+        "tableName": "Tag",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL)",
+        "fields": [
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "createdAt",
+            "columnName": "createdAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "updatedAt",
+            "columnName": "updatedAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [
+          {
+            "name": "index_Tag_name",
+            "unique": true,
+            "columnNames": [
+              "name"
+            ],
+            "orders": [],
+            "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Tag_name` ON `${TABLE_NAME}` (`name`)"
+          }
+        ],
+        "foreignKeys": []
+      },
+      {
+        "tableName": "TagNoteCrossRef",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tagId` INTEGER NOT NULL, `noteId` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`tagId`, `noteId`), FOREIGN KEY(`tagId`) REFERENCES `Tag`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`noteId`) REFERENCES `Note`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
+        "fields": [
+          {
+            "fieldPath": "tagId",
+            "columnName": "tagId",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "noteId",
+            "columnName": "noteId",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "createdAt",
+            "columnName": "createdAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "updatedAt",
+            "columnName": "updatedAt",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "tagId",
+            "noteId"
+          ],
+          "autoGenerate": false
+        },
+        "indices": [],
+        "foreignKeys": [
+          {
+            "table": "Tag",
+            "onDelete": "CASCADE",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "tagId"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          },
+          {
+            "table": "Note",
+            "onDelete": "CASCADE",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "noteId"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          }
+        ]
+      }
+    ],
+    "views": [],
+    "setupQueries": [
+      "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e6bb62e2bcb6a5b4c51566481a9037bd')"
+    ]
+  }
+}
\ No newline at end of file
diff --git a/NoteApplication/app/src/main/java/com/noteapplication/cs398/AddNoteActivity.kt b/NoteApplication/app/src/main/java/com/noteapplication/cs398/AddNoteActivity.kt
index 2da606b..1d4b0ce 100644
--- a/NoteApplication/app/src/main/java/com/noteapplication/cs398/AddNoteActivity.kt
+++ b/NoteApplication/app/src/main/java/com/noteapplication/cs398/AddNoteActivity.kt
@@ -97,7 +97,7 @@ class AddNoteActivity : AppCompatActivity() {
                     title = binding.titleInput.text.toString(),
                     content = binding.contentInput.text.toString(),
                     notify = binding.idRmdSwitch.isChecked,
-                    updatedTime = Date().time
+                    updatedAt = Date().time
                 )
                 noteViewModel.updateNote(newNote, tagViewModel.getSelectedTags())
             } else {
diff --git a/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/NoteDatabase.kt b/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/NoteDatabase.kt
index f1dd2bf..987ec87 100644
--- a/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/NoteDatabase.kt
+++ b/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/NoteDatabase.kt
@@ -3,7 +3,7 @@ package com.noteapplication.cs398.database
 import android.content.Context
 import androidx.room.*
 
-@Database(entities = [Note::class, Folder::class, Tag::class, TagNoteCrossRef::class], version = 11)
+@Database(entities = [Note::class, Folder::class, Tag::class, TagNoteCrossRef::class], version = 12)
 abstract class NoteDatabase : RoomDatabase() {
     abstract fun getNoteDataAccess(): NoteDataAccess
 
diff --git a/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/Tables.kt b/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/Tables.kt
index 8a6f298..6f126a2 100644
--- a/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/Tables.kt
+++ b/NoteApplication/app/src/main/java/com/noteapplication/cs398/database/Tables.kt
@@ -17,9 +17,10 @@ data class Note (
     @ColumnInfo(name = "title") val title:String,
     @ColumnInfo(name = "content") val content:String,
     @ColumnInfo(name = "notify") val notify:Boolean,
+    @ColumnInfo(name = "notifyAt") val notifyAt:Long = Date().time,
     @ColumnInfo(name = "folderId") val folderId:Long?,
-    @ColumnInfo(name = "createdTime") val createdTime:Long = Date().time,
-    @ColumnInfo(name = "updatedTime") val updatedTime:Long = Date().time,
+    @ColumnInfo(name = "createdAt") val createdAt:Long = Date().time,
+    @ColumnInfo(name = "updatedAt") val updatedAt:Long = Date().time,
     @PrimaryKey(autoGenerate = true) var id: Long = 0,
 ): Serializable
 
@@ -35,8 +36,8 @@ data class Folder (
     @ColumnInfo(name = "name") val name:String,
     @ColumnInfo(name = "parent") val parent:Long? = null,
     @PrimaryKey(autoGenerate = true) var id: Long = 0,
-    @ColumnInfo(name = "createdTime") val createdTime:Long = Date().time,
-    @ColumnInfo(name = "updatedTime") val updatedTime:Long = Date().time,
+    @ColumnInfo(name = "createdAt") val createdAt:Long = Date().time,
+    @ColumnInfo(name = "updatedAt") val updatedAt:Long = Date().time,
 ): Serializable
 
 @Entity(tableName = "Tag",
@@ -48,8 +49,8 @@ data class Folder (
 data class Tag (
     @ColumnInfo(name = "name") val name:String,
     @PrimaryKey(autoGenerate = true) var id: Long = 0,
-    @ColumnInfo(name = "createdTime") val createdTime:Long = Date().time,
-    @ColumnInfo(name = "updatedTime") val updatedTime:Long = Date().time,
+    @ColumnInfo(name = "createdAt") val createdAt:Long = Date().time,
+    @ColumnInfo(name = "updatedAt") val updatedAt:Long = Date().time,
 )
 
 @Entity(tableName = "TagNoteCrossRef",
@@ -72,6 +73,6 @@ data class Tag (
 data class TagNoteCrossRef (
     val tagId:Long,
     val noteId:Long,
-    @ColumnInfo(name = "createdTime") val createdTime:Long = Date().time,
-    @ColumnInfo(name = "updatedTime") val updatedTime:Long = Date().time,
+    @ColumnInfo(name = "createdAt") val createdAt:Long = Date().time,
+    @ColumnInfo(name = "updatedAt") val updatedAt:Long = Date().time,
 )
\ No newline at end of file
-- 
GitLab