3
/* Move type column from base images table
4
* to be records in image_properties table */
5
CREATE TEMPORARY TABLE tmp_type_records (id INTEGER NOT NULL, type VARCHAR(30) NOT NULL);
6
INSERT INTO tmp_type_records
9
WHERE type IS NOT NULL;
11
REPLACE INTO image_properties
12
(image_id, key, value, created_at, deleted)
13
SELECT id, 'type', type, date('now'), 0
14
FROM tmp_type_records;
16
DROP TABLE tmp_type_records;
18
/* Make changes to the base images table */
19
CREATE TEMPORARY TABLE images_backup (
23
status VARCHAR(30) NOT NULL,
24
is_public BOOLEAN NOT NULL,
26
created_at DATETIME NOT NULL,
29
deleted BOOLEAN NOT NULL,
33
INSERT INTO images_backup
34
SELECT id, name, size, status, is_public, location, created_at, updated_at, deleted_at, deleted
43
status VARCHAR(30) NOT NULL,
44
is_public BOOLEAN NOT NULL,
46
created_at DATETIME NOT NULL,
49
deleted BOOLEAN NOT NULL,
50
disk_format VARCHAR(20),
51
container_format VARCHAR(20),
53
CHECK (is_public IN (0, 1)),
54
CHECK (deleted IN (0, 1))
56
CREATE INDEX ix_images_deleted ON images (deleted);
57
CREATE INDEX ix_images_is_public ON images (is_public);
59
INSERT INTO images (id, name, size, status, is_public, location, created_at, updated_at, deleted_at, deleted)
60
SELECT id, name, size, status, is_public, location, created_at, updated_at, deleted_at, deleted
63
DROP TABLE images_backup;