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 0000000000000000000000000000000000000000..f410b222edc5bdf4685e4f2943feceac3c6a6915 --- /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 2da606b2bce93ec7be03057d503ef0e968b886a9..1d4b0ce108bcb5d5012b213b295d31065cf53da6 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 f1dd2bf91742fcded5bd19783b1caf37d0779e20..987ec8721debe0d367a76f7e4a203f1904bc2cca 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 8a6f298269a5d97eeccab46ae5f525b79d845164..6f126a269b4b542e15befd10aa48a0d17c2e3c3d 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