Refactor the adventure database to better fit the model.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-06-19 22:40:39 +02:00
parent 96269cf84a
commit b6489e5a85
15 changed files with 497 additions and 337 deletions

View file

@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "eecd0da0c8ae6578a5d36c3b926c2fe8",
"identityHash": "95cb578b3b61a022ab4dda676d2e4645",
"entities": [
{
"tableName": "lexicon",
@ -320,51 +320,71 @@
"foreignKeys": []
},
{
"tableName": "adventures",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookTitle` TEXT NOT NULL, `adventureTitle` TEXT NOT NULL, `adventureCategory` TEXT, `bookIcon` TEXT, `adventureBackground` TEXT, `index` INTEGER NOT NULL, `revision` INTEGER NOT NULL, `documentId` TEXT NOT NULL, PRIMARY KEY(`bookTitle`, `adventureTitle`))",
"tableName": "AdventureBooks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`documentId` TEXT NOT NULL, `title` TEXT NOT NULL, `icon` TEXT, PRIMARY KEY(`documentId`))",
"fields": [
{
"fieldPath": "bookTitle",
"columnName": "bookTitle",
"fieldPath": "documentId",
"columnName": "documentId",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "adventureTitle",
"columnName": "adventureTitle",
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "adventureCategory",
"columnName": "adventureCategory",
"fieldPath": "icon",
"columnName": "icon",
"affinity": "TEXT",
"notNull": false
},
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"documentId"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "AdventureStory",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `category` TEXT, `background` TEXT, `revision` INTEGER NOT NULL, `index` INTEGER NOT NULL, `documentId` TEXT NOT NULL, PRIMARY KEY(`title`, `documentId`), FOREIGN KEY(`documentId`) REFERENCES `AdventureBooks`(`documentId`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "bookIcon",
"columnName": "bookIcon",
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "adventureBackground",
"columnName": "adventureBackground",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "index",
"columnName": "index",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "category",
"columnName": "category",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "background",
"columnName": "background",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "revision",
"columnName": "revision",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "index",
"columnName": "index",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "documentId",
"columnName": "documentId",
@ -375,29 +395,29 @@
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookTitle",
"adventureTitle"
"title",
"documentId"
]
},
"indices": [],
"foreignKeys": []
"foreignKeys": [
{
"table": "AdventureBooks",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"documentId"
],
"referencedColumns": [
"documentId"
]
}
]
},
{
"tableName": "adventuresStories",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookTitle` TEXT NOT NULL, `adventureTitle` TEXT NOT NULL, `index` INTEGER NOT NULL, `text` TEXT NOT NULL, `format` TEXT NOT NULL, PRIMARY KEY(`bookTitle`, `adventureTitle`, `index`), FOREIGN KEY(`bookTitle`, `adventureTitle`) REFERENCES `adventures`(`bookTitle`, `adventureTitle`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"tableName": "AdventureLine",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`index` INTEGER NOT NULL, `text` TEXT NOT NULL, `format` TEXT NOT NULL, `documentId` TEXT NOT NULL, `title` TEXT NOT NULL, PRIMARY KEY(`index`, `title`, `documentId`), FOREIGN KEY(`title`, `documentId`) REFERENCES `AdventureStory`(`title`, `documentId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "bookTitle",
"columnName": "bookTitle",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "adventureTitle",
"columnName": "adventureTitle",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "index",
"columnName": "index",
@ -415,29 +435,41 @@
"columnName": "format",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "documentId",
"columnName": "documentId",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "story",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookTitle",
"adventureTitle",
"index"
"index",
"title",
"documentId"
]
},
"indices": [],
"foreignKeys": [
{
"table": "adventures",
"table": "AdventureStory",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"bookTitle",
"adventureTitle"
"title",
"documentId"
],
"referencedColumns": [
"bookTitle",
"adventureTitle"
"title",
"documentId"
]
}
]
@ -446,7 +478,7 @@
"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, 'eecd0da0c8ae6578a5d36c3b926c2fe8')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '95cb578b3b61a022ab4dda676d2e4645')"
]
}
}