"createSql":"CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`dnsName` TEXT NOT NULL, `type` INTEGER NOT NULL, `records` TEXT NOT NULL, PRIMARY KEY(`dnsName`, `type`))",
"fields":[
{
"fieldPath":"dnsName",
"columnName":"dnsName",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"type",
"columnName":"type",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"records",
"columnName":"records",
"affinity":"TEXT",
"notNull":true
}
],
"primaryKey":{
"columnNames":[
"dnsName",
"type"
],
"autoGenerate":false
},
"indices":[],
"foreignKeys":[]
},
{
"tableName":"DnsQuery",
"createSql":"CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)",
"fields":[
{
"fieldPath":"id",
"columnName":"id",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"type",
"columnName":"type",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"name",
"columnName":"name",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"askedServer",
"columnName":"askedServer",
"affinity":"TEXT",
"notNull":false
},
{
"fieldPath":"responseSource",
"columnName":"responseSource",
"affinity":"TEXT",
"notNull":false
},
{
"fieldPath":"questionTime",
"columnName":"questionTime",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"responseTime",
"columnName":"responseTime",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"responses",
"columnName":"responses",
"affinity":"TEXT",
"notNull":true
}
],
"primaryKey":{
"columnNames":[
"id"
],
"autoGenerate":true
},
"indices":[],
"foreignKeys":[]
},
{
"tableName":"DnsRule",
"createSql":"CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `stagingType` INTEGER NOT NULL, `type` INTEGER NOT NULL, `host` TEXT NOT NULL, `target` TEXT NOT NULL, `ipv6Target` TEXT, `importedFrom` INTEGER, `isWildcard` INTEGER NOT NULL, FOREIGN KEY(`importedFrom`) REFERENCES `HostSource`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields":[
{
"fieldPath":"id",
"columnName":"id",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"stagingType",
"columnName":"stagingType",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"type",
"columnName":"type",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"host",
"columnName":"host",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"target",
"columnName":"target",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"ipv6Target",
"columnName":"ipv6Target",
"affinity":"TEXT",
"notNull":false
},
{
"fieldPath":"importedFrom",
"columnName":"importedFrom",
"affinity":"INTEGER",
"notNull":false
},
{
"fieldPath":"isWildcard",
"columnName":"isWildcard",
"affinity":"INTEGER",
"notNull":true
}
],
"primaryKey":{
"columnNames":[
"id"
],
"autoGenerate":true
},
"indices":[
{
"name":"index_DnsRule_importedFrom",
"unique":false,
"columnNames":[
"importedFrom"
],
"createSql":"CREATE INDEX `index_DnsRule_importedFrom` ON `${TABLE_NAME}` (`importedFrom`)"
},
{
"name":"index_DnsRule_host_type_stagingType",
"unique":true,
"columnNames":[
"host",
"type",
"stagingType"
],
"createSql":"CREATE UNIQUE INDEX `index_DnsRule_host_type_stagingType` ON `${TABLE_NAME}` (`host`, `type`, `stagingType`)"
}
],
"foreignKeys":[
{
"table":"HostSource",
"onDelete":"NO ACTION",
"onUpdate":"NO ACTION",
"columns":[
"importedFrom"
],
"referencedColumns":[
"id"
]
}
]
},
{
"tableName":"HostSource",
"createSql":"CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `enabled` INTEGER NOT NULL, `ruleCount` INTEGER, `checksum` TEXT, `name` TEXT NOT NULL, `source` TEXT NOT NULL, `whitelistSource` INTEGER NOT NULL)",
"fields":[
{
"fieldPath":"id",
"columnName":"id",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"enabled",
"columnName":"enabled",
"affinity":"INTEGER",
"notNull":true
},
{
"fieldPath":"ruleCount",
"columnName":"ruleCount",
"affinity":"INTEGER",
"notNull":false
},
{
"fieldPath":"checksum",
"columnName":"checksum",
"affinity":"TEXT",
"notNull":false
},
{
"fieldPath":"name",
"columnName":"name",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"source",
"columnName":"source",
"affinity":"TEXT",
"notNull":true
},
{
"fieldPath":"whitelistSource",
"columnName":"whitelistSource",
"affinity":"INTEGER",
"notNull":true
}
],
"primaryKey":{
"columnNames":[
"id"
],
"autoGenerate":true
},
"indices":[],
"foreignKeys":[]
}
],
"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, 'fb5d5231e14e3e9fbd2d47ee90178b0f')"
@@ -97,12 +97,21 @@ val MIGRATION_9_10 = migration(9, 10) {
Logger.logIfOpen("DB_MIGRATION","Migration from 9 to 10 completed")
}
valMIGRATION_10_11=migration(10,11){
Logger.logIfOpen("DB_MIGRATION","Migrating from 10 to 11")
it.execSQL("CREATE TABLE `DnsQuery_tmp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)")
it.execSQL("INSERT INTO `DnsQuery_tmp`(id, type, name, askedServer, questionTime, responseTime, responses, responseSource) SELECT id, type, name, askedServer, questionTime, responseTime, responses, CASE WHEN fromCache=1 THEN 'CACHE' else 'UPSTREAM' END as `responseSource` FROM DnsQuery")
it.execSQL("DROP TABLE `DnsQuery`")
it.execSQL("ALTER TABLE `DnsQuery_tmp` RENAME TO `DnsQuery`")
Logger.logIfOpen("DB_MIGRATION","Migration from 10 to 11 completed")