Debian Codegraph @

maintenance/sqlite/archives/patch-filearchive-fa_name.sql

raw
1 -- Modify fa_name and fa_storage_group to be BLOB and drop default from fa_deleted_timestamp and fa_timestamp
2 CREATE TABLE /*_*/filearchive_tmp (
3 fa_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
4 fa_name BLOB DEFAULT '' NOT NULL, fa_archive_name BLOB DEFAULT '',
5 fa_storage_group BLOB DEFAULT NULL,
6 fa_storage_key BLOB DEFAULT '', fa_deleted_user INTEGER DEFAULT NULL,
7 fa_deleted_timestamp BLOB DEFAULT NULL,
8 fa_deleted_reason_id BIGINT UNSIGNED NOT NULL,
9 fa_size INTEGER UNSIGNED DEFAULT 0,
10 fa_width INTEGER DEFAULT 0, fa_height INTEGER DEFAULT 0,
11 fa_metadata BLOB DEFAULT NULL, fa_bits INTEGER DEFAULT 0,
12 fa_media_type TEXT DEFAULT NULL, fa_major_mime TEXT DEFAULT 'unknown',
13 fa_minor_mime BLOB DEFAULT 'unknown',
14 fa_description_id BIGINT UNSIGNED NOT NULL,
15 fa_actor BIGINT UNSIGNED NOT NULL,
16 fa_timestamp BLOB DEFAULT NULL, fa_deleted SMALLINT UNSIGNED DEFAULT 0 NOT NULL,
17 fa_sha1 BLOB DEFAULT '' NOT NULL
18 );
19 INSERT INTO /*_*/filearchive_tmp (
20 fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key, fa_deleted_user, fa_deleted_timestamp,
21 fa_deleted_reason_id, fa_size, fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
22 fa_minor_mime, fa_description_id, fa_actor, fa_timestamp, fa_deleted, fa_sha1
23 )
24 SELECT fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key, fa_deleted_user, fa_deleted_timestamp,
25 fa_deleted_reason_id, fa_size, fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
26 fa_minor_mime, fa_description_id, fa_actor, fa_timestamp, fa_deleted, fa_sha1
27 FROM /*_*/filearchive;
28 DROP TABLE /*_*/filearchive;
29 ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
30
31 CREATE INDEX fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
32
33 CREATE INDEX fa_storage_group ON /*_*/filearchive (
34 fa_storage_group, fa_storage_key
35 );
36
37 CREATE INDEX fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
38
39 CREATE INDEX fa_actor_timestamp ON /*_*/filearchive (fa_actor, fa_timestamp);
40
41 CREATE INDEX fa_sha1 ON /*_*/filearchive (fa_sha1);