Draft: Migrate the database to schema v2
2 unresolved threads
2 unresolved threads
This is a partial rewrite of the database schema and the supporting application code. The goal is to prepare for larger future changes.
User impact
The only user-facing change of this patch is a fix for files
created between the 23rd of February, 2019 (when the new API was deployed) and
the 20th of April, 2019 (when a08978a9 was
deployed). The migration script ensures that every key
(now path
) in the
objects
table (now object
) has a leading slash. While this is technically a
breaking change, I do not have a reason to believe any existing client would be
affected.
Edited by Auri
Merge request reports
Activity
requested review from @dean
assigned to @aurieh
added 1 commit
- aafa8440 - fixup! sql/v1tov2: migrate the database to schema v2
- sql/v1tov2.sql 0 → 100644
34 -- reasonable use case. 35 CREATE DOMAIN url AS character varying(4096); 36 37 CREATE DOMAIN bucket_name AS character varying(32); 38 39 CREATE DOMAIN object_path AS character varying(4096); 40 41 -- Given '//foo/bar//baz', return '/foo/bar/baz'. 42 CREATE FUNCTION path_normalize(object_path) RETURNS object_path 43 IMMUTABLE STRICT 44 LANGUAGE SQL 45 AS $$SELECT regexp_replace($1, '/+', '/', 'g');$$; 46 47 -- Given '/foo/bar.baz.qux', return '/foo/bar'. 48 -- See bucket.enforce_unique_names and object.enforce_unique_name. 49 CREATE FUNCTION path_full_stem(object_path) RETURNS object_path changed this line in version 4 of the diff
- sql/v1tov2.sql 0 → 100644
206 -- should afford us about 9EB :) 207 ALTER COLUMN content_length SET DATA TYPE bigint, 208 ALTER COLUMN sha256_digest SET DATA TYPE sha256, 209 ALTER COLUMN md5_digest SET DATA TYPE md5, 210 ALTER COLUMN location DROP DEFAULT, 211 ALTER COLUMN location SET DATA TYPE url, 212 ALTER COLUMN owned_by DROP DEFAULT, 213 ALTER COLUMN owned_by SET DATA TYPE uuid USING owned_by::uuid, 214 -- Casting timestamp to timestamp with time zone is equivalent to: 215 -- USING (created_at as time zone current_setting('timezone')) 216 ALTER COLUMN created_at SET DATA TYPE timestamp with time zone, 217 ALTER COLUMN tombstoned_at SET DATA TYPE timestamp with time zone, 218 -- DEFAULT NULL is implied on nullable columns. 219 ALTER COLUMN tombstone_description DROP DEFAULT, 220 ADD FOREIGN KEY (owned_by) REFERENCES user_ (id), 221 ADD CHECK (content_length >= -1), changed this line in version 4 of the diff
Please register or sign in to reply