Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d0b3ba56
Commit
d0b3ba56
authored
Sep 01, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase pypi required_python size to 255
Adds migration to increase column limit and update specs.
parent
8e43527d
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
78 additions
and
8 deletions
+78
-8
app/models/packages/pypi/metadatum.rb
app/models/packages/pypi/metadatum.rb
+1
-1
changelogs/unreleased/241492-increase-pypi-version-size.yml
changelogs/unreleased/241492-increase-pypi-version-size.yml
+5
-0
db/migrate/20200901214416_change_pypi_python_version_type.rb
db/migrate/20200901214416_change_pypi_python_version_type.rb
+18
-0
db/post_migrate/20200909194014_change_pypi_python_version_type_cleanup.rb
...20200909194014_change_pypi_python_version_type_cleanup.rb
+18
-0
db/post_migrate/20200909194524_increase_pypi_version_size.rb
db/post_migrate/20200909194524_increase_pypi_version_size.rb
+17
-0
db/schema_migrations/20200901214416
db/schema_migrations/20200901214416
+1
-0
db/schema_migrations/20200909194014
db/schema_migrations/20200909194014
+1
-0
db/schema_migrations/20200909194524
db/schema_migrations/20200909194524
+1
-0
db/structure.sql
db/structure.sql
+3
-1
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+2
-2
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+9
-2
spec/requests/api/pypi_packages_spec.rb
spec/requests/api/pypi_packages_spec.rb
+1
-1
spec/services/packages/pypi/create_package_service_spec.rb
spec/services/packages/pypi/create_package_service_spec.rb
+1
-1
No files found.
app/models/packages/pypi/metadatum.rb
View file @
d0b3ba56
...
...
@@ -6,7 +6,7 @@ class Packages::Pypi::Metadatum < ApplicationRecord
belongs_to
:package
,
->
{
where
(
package_type: :pypi
)
},
inverse_of: :pypi_metadatum
validates
:package
,
presence:
true
validates
:required_python
,
length:
{
maximum:
50
},
allow_blank:
true
validates
:required_python
,
length:
{
maximum:
255
},
allow_blank:
true
validate
:pypi_package_type
...
...
changelogs/unreleased/241492-increase-pypi-version-size.yml
0 → 100644
View file @
d0b3ba56
---
title
:
Increase Pypi required_version limit to
255
merge_request
:
41018
author
:
type
:
changed
db/migrate/20200901214416_change_pypi_python_version_type.rb
0 → 100644
View file @
d0b3ba56
# frozen_string_literal: true
class
ChangePypiPythonVersionType
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
change_column_type_concurrently
:packages_pypi_metadata
,
:required_python
,
:text
,
batch_column_name: :package_id
# rubocop:disable Migration/AddLimitToTextColumns
end
def
down
cleanup_concurrent_column_type_change
(
:packages_pypi_metadata
,
:required_python
)
change_column_null
:packages_pypi_metadata
,
:required_python
,
false
end
end
db/post_migrate/20200909194014_change_pypi_python_version_type_cleanup.rb
0 → 100644
View file @
d0b3ba56
# frozen_string_literal: true
class
ChangePypiPythonVersionTypeCleanup
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
cleanup_concurrent_column_type_change
(
:packages_pypi_metadata
,
:required_python
)
end
def
down
execute
(
'UPDATE packages_pypi_metadata SET required_python = substring(required_python from 1 for 50)'
)
change_column_type_concurrently
:packages_pypi_metadata
,
:required_python
,
'varchar(50)'
,
batch_column_name: :package_id
end
end
db/post_migrate/20200909194524_increase_pypi_version_size.rb
0 → 100644
View file @
d0b3ba56
# frozen_string_literal: true
class
IncreasePypiVersionSize
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_text_limit
:packages_pypi_metadata
,
:required_python
,
255
end
def
down
remove_text_limit
:packages_pypi_metadata
,
:required_python
end
end
db/schema_migrations/20200901214416
0 → 100644
View file @
d0b3ba56
b196c8ce85631432e712a977b09cdba70872f42b16bca53eda1bc8558f57ea24
\ No newline at end of file
db/schema_migrations/20200909194014
0 → 100644
View file @
d0b3ba56
9579a789ed6256a513a7afb51eeaf11661d1ef2e5d8312e28a69579eb39d8960
\ No newline at end of file
db/schema_migrations/20200909194524
0 → 100644
View file @
d0b3ba56
c0f798f6ffd8d67137e6076242f5fb0004736f03c9cde5556dec228eefa75cb1
\ No newline at end of file
db/structure.sql
View file @
d0b3ba56
...
...
@@ -14084,7 +14084,9 @@ ALTER SEQUENCE public.packages_packages_id_seq OWNED BY public.packages_packages
CREATE
TABLE
public
.
packages_pypi_metadata
(
package_id
bigint
NOT
NULL
,
required_python
character
varying
(
50
)
NOT
NULL
required_python
text
,
CONSTRAINT
check_0d9aed55b2
CHECK
((
required_python
IS
NOT
NULL
)),
CONSTRAINT
check_379019d5da
CHECK
((
char_length
(
required_python
)
<=
255
))
);
CREATE
TABLE
public
.
packages_tags
(
...
...
lib/gitlab/database/migration_helpers.rb
View file @
d0b3ba56
...
...
@@ -538,10 +538,10 @@ module Gitlab
# table - The table containing the column.
# column - The name of the column to change.
# new_type - The new column type.
def
change_column_type_concurrently
(
table
,
column
,
new_type
,
type_cast_function:
nil
)
def
change_column_type_concurrently
(
table
,
column
,
new_type
,
type_cast_function:
nil
,
batch_column_name: :id
)
temp_column
=
"
#{
column
}
_for_type_change"
rename_column_concurrently
(
table
,
column
,
temp_column
,
type:
new_type
,
type_cast_function:
type_cast_function
)
rename_column_concurrently
(
table
,
column
,
temp_column
,
type:
new_type
,
type_cast_function:
type_cast_function
,
batch_column_name:
batch_column_name
)
end
# Performs cleanup of a concurrent type change.
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
d0b3ba56
...
...
@@ -903,15 +903,22 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
describe
'#change_column_type_concurrently'
do
it
'changes the column type'
do
expect
(
model
).
to
receive
(
:rename_column_concurrently
)
.
with
(
'users'
,
'username'
,
'username_for_type_change'
,
type: :text
,
type_cast_function:
nil
)
.
with
(
'users'
,
'username'
,
'username_for_type_change'
,
type: :text
,
type_cast_function:
nil
,
batch_column_name: :id
)
model
.
change_column_type_concurrently
(
'users'
,
'username'
,
:text
)
end
it
'passed the batch column name'
do
expect
(
model
).
to
receive
(
:rename_column_concurrently
)
.
with
(
'users'
,
'username'
,
'username_for_type_change'
,
type: :text
,
type_cast_function:
nil
,
batch_column_name: :user_id
)
model
.
change_column_type_concurrently
(
'users'
,
'username'
,
:text
,
batch_column_name: :user_id
)
end
context
'with type cast'
do
it
'changes the column type with casting the value to the new type'
do
expect
(
model
).
to
receive
(
:rename_column_concurrently
)
.
with
(
'users'
,
'username'
,
'username_for_type_change'
,
type: :text
,
type_cast_function:
'JSON'
)
.
with
(
'users'
,
'username'
,
'username_for_type_change'
,
type: :text
,
type_cast_function:
'JSON'
,
batch_column_name: :id
)
model
.
change_column_type_concurrently
(
'users'
,
'username'
,
:text
,
type_cast_function:
'JSON'
)
end
...
...
spec/requests/api/pypi_packages_spec.rb
View file @
d0b3ba56
...
...
@@ -176,7 +176,7 @@ RSpec.describe API::PypiPackages do
end
context
'with required_python too big'
do
let
(
:requires_python
)
{
'x'
*
51
}
let
(
:requires_python
)
{
'x'
*
256
}
let
(
:token
)
{
personal_access_token
.
token
}
let
(
:user_headers
)
{
basic_auth_header
(
user
.
username
,
token
)
}
let
(
:headers
)
{
user_headers
.
merge
(
workhorse_header
)
}
...
...
spec/services/packages/pypi/create_package_service_spec.rb
View file @
d0b3ba56
...
...
@@ -40,7 +40,7 @@ RSpec.describe Packages::Pypi::CreatePackageService do
end
context
'with an invalid metadata'
do
let
(
:requires_python
)
{
'x'
*
51
}
let
(
:requires_python
)
{
'x'
*
256
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment