Closed RBusarow closed 3 years ago
@RBusarow, Now that I've merged your PR I have one question. This is generated code for table.field.affinity
change:
CREATE TABLE IF NOT EXISTS `indices_MERGE_TABLE` (`id` INTEGER NOT NULL, PRIMARY KEY(`id`))
INSERT INTO `indices_MERGE_TABLE` (`id`) SELECT CAST(`indices`.`id` AS INTEGER) FROM `indices`
DROP TABLE IF EXISTS `indices`
ALTER TABLE `indices_MERGE_TABLE` RENAME TO `indices`
CREATE INDEX IF NOT EXISTS `id_index` ON `indices` (`id`)
### code below comes from IndexDiff
DROP INDEX IF EXISTS id_index
CREATE INDEX IF NOT EXISTS `id_index` ON `indices` (`id`)
Table is dropped when any field affinity changes. Index is dropped with the table automatically and we recreate it afterwards for the new table. Is there really a need for indexed fields affinity check?
If the type/affinity of an indexed field changes between two schema versions, such as from
TEXT
toINTEGER
, the index is not recreated in the migration.The "index" object in the json doesn't actually include affinity information anywhere. It needs to be cross-referenced from the column info.