Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whats-this
api
Commits
376b9fac
Commit
376b9fac
authored
2 years ago
by
Auri
Browse files
Options
Downloads
Patches
Plain Diff
fixup! fixup! fixup! sql/v1tov2: migrate the database to schema v2
parent
eabad463
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
Draft: Migrate the database to schema v2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/db/sql.go
+3
-3
3 additions, 3 deletions
lib/db/sql.go
sql/v1tov2.sql
+1
-12
1 addition, 12 deletions
sql/v1tov2.sql
with
4 additions
and
15 deletions
lib/db/sql.go
+
3
−
3
View file @
376b9fac
...
...
@@ -7,7 +7,7 @@ SELECT
email,
is_admin,
is_blocked,
v1.positive_or_null(
ratelimit_bucket_capacity
)
ratelimit_bucket_capacity
FROM
user_ u,
legacy_token t
...
...
@@ -84,7 +84,7 @@ SELECT
o.type::integer,
o.location,
o.content_type,
v1.positive_or_null(
o.content_length
)
,
o.content_length,
o.created_at,
o.tombstoned_at,
o.tombstone_description,
...
...
@@ -112,7 +112,7 @@ SELECT
o.type::integer,
o.location,
o.content_type,
v1.positive_or_null(
o.content_length
)
,
o.content_length,
o.created_at,
o.tombstoned_at,
o.tombstone_description,
...
...
This diff is collapsed.
Click to expand it.
sql/v1tov2.sql
+
1
−
12
View file @
376b9fac
...
...
@@ -78,11 +78,6 @@ CREATE FUNCTION path_directory(object_path) RETURNS object_path
END
$$
;
CREATE
FUNCTION
v1
.
positive_or_null
(
bigint
)
RETURNS
bigint
IMMUTABLE
STRICT
LANGUAGE
SQL
AS
$$
SELECT
(
CASE
WHEN
$
1
<
0
THEN
NULL
ELSE
$
1
END
);
$$
;
CREATE
FUNCTION
v1
.
object_type
(
integer
)
RETURNS
object_type
IMMUTABLE
STRICT
LANGUAGE
SQL
...
...
@@ -152,8 +147,6 @@ ALTER TABLE user_
ALTER
COLUMN
username
SET
DATA
TYPE
character
varying
(
256
)
COLLATE
"und-u-ks-level2-x-icu"
,
ALTER
COLUMN
email
SET
DATA
TYPE
emailaddr
,
ALTER
COLUMN
ratelimit_bucket_capacity
SET
NOT
NULL
,
ALTER
COLUMN
ratelimit_bucket_capacity
SET
DEFAULT
-
1
,
ADD
COLUMN
password
bytea
,
ADD
COLUMN
created_on
timestamp
with
time
zone
NOT
NULL
DEFAULT
now
(),
ADD
UNIQUE
(
username
);
...
...
@@ -202,9 +195,6 @@ ALTER TABLE object RENAME COLUMN delete_reason TO tombstone_description;
ALTER
INDEX
objects_associated_user
RENAME
TO
object_owned_by_idx
;
ALTER
INDEX
objects_sha256_hash_idx
RENAME
TO
object_sha256_digest_idx
;
-- Prepare for ALTER COLUMN content_length SET NOT NULL.
UPDATE
object
SET
content_length
=
-
1
WHERE
content_length
IS
NULL
;
ALTER
TABLE
object
-- Unused.
DROP
COLUMN
backend_file_id
,
...
...
@@ -215,7 +205,6 @@ ALTER TABLE object
-- Previously objects could be up to 2GB (and change) in size. bigint
-- should afford us about 9EB :)
ALTER
COLUMN
content_length
SET
DATA
TYPE
bigint
,
ALTER
COLUMN
content_length
SET
NOT
NULL
,
ALTER
COLUMN
sha256_digest
SET
DATA
TYPE
sha256
,
ALTER
COLUMN
md5_digest
SET
DATA
TYPE
md5
,
ALTER
COLUMN
location
DROP
DEFAULT
,
...
...
@@ -232,7 +221,7 @@ ALTER TABLE object
ADD
CHECK
(
content_length
>=
-
1
),
ADD
CONSTRAINT
object_is_valid_file_check
CHECK
(
type
!=
'file'
OR
content_type
IS
NOT
NULL
AND
content_length
>=
0
AND
COALESCE
(
content_length
,
-
1
)
>=
0
AND
sha256_digest
IS
NOT
NULL
AND
md5_digest
IS
NOT
NULL
),
ADD
CONSTRAINT
object_is_valid_redirect_check
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment