Skip to content
Snippets Groups Projects
Commit f5123688 authored by ichung14's avatar ichung14
Browse files

db column name changed. new column - notifyAt - inserted

parent 00f2601a
No related branches found
No related tags found
No related merge requests found
{
"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
......@@ -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 {
......
......@@ -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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment