Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
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
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Pierre Boudes
mastodon
Commits
a5f91a11
Unverified
Commit
a5f91a11
authored
3 years ago
by
Claire
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix older migrations on Ruby 3 (#16174)
parent
0ad240cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/application.rb
+1
-0
1 addition, 0 deletions
config/application.rb
lib/mastodon/migration_helpers.rb
+8
-8
8 additions, 8 deletions
lib/mastodon/migration_helpers.rb
lib/paperclip/schema_extensions.rb
+37
-0
37 additions, 0 deletions
lib/paperclip/schema_extensions.rb
with
46 additions
and
8 deletions
config/application.rb
+
1
−
0
View file @
a5f91a11
...
...
@@ -10,6 +10,7 @@ require_relative '../lib/exceptions'
require_relative
'../lib/enumerable'
require_relative
'../lib/sanitize_ext/sanitize_config'
require_relative
'../lib/redis/namespace_extensions'
require_relative
'../lib/paperclip/schema_extensions'
require_relative
'../lib/paperclip/validation_extensions'
require_relative
'../lib/paperclip/url_generator_extensions'
require_relative
'../lib/paperclip/attachment_extensions'
...
...
This diff is collapsed.
Click to expand it.
lib/mastodon/migration_helpers.rb
+
8
−
8
View file @
a5f91a11
...
...
@@ -95,7 +95,7 @@ module Mastodon
allow_null:
options
[
:null
]
)
else
add_column
(
table_name
,
column_name
,
:datetime_with_timezone
,
options
)
add_column
(
table_name
,
column_name
,
:datetime_with_timezone
,
**
options
)
end
end
end
...
...
@@ -120,7 +120,7 @@ module Mastodon
options
=
options
.
merge
({
algorithm: :concurrently
})
disable_statement_timeout
add_index
(
table_name
,
column_name
,
options
)
add_index
(
table_name
,
column_name
,
**
options
)
end
# Removes an existed index, concurrently when supported
...
...
@@ -144,7 +144,7 @@ module Mastodon
disable_statement_timeout
end
remove_index
(
table_name
,
options
.
merge
({
column:
column_name
}))
remove_index
(
table_name
,
**
options
.
merge
({
column:
column_name
}))
end
# Removes an existing index, concurrently when supported
...
...
@@ -168,7 +168,7 @@ module Mastodon
disable_statement_timeout
end
remove_index
(
table_name
,
options
.
merge
({
name:
index_name
}))
remove_index
(
table_name
,
**
options
.
merge
({
name:
index_name
}))
end
# Only available on Postgresql >= 9.2
...
...
@@ -472,7 +472,7 @@ module Mastodon
col_opts
[
:limit
]
=
old_col
.
limit
end
add_column
(
table
,
new
,
new_type
,
col_opts
)
add_column
(
table
,
new
,
new_type
,
**
col_opts
)
# We set the default value _after_ adding the column so we don't end up
# updating any existing data with the default value. This isn't
...
...
@@ -510,10 +510,10 @@ module Mastodon
new_pk_index_name
=
"index_
#{
table
}
_on_
#{
column
}
_cm"
unless
indexes_for
(
table
,
column
).
find
{
|
i
|
i
.
name
==
old_pk_index_name
}
add_concurrent_index
(
table
,
[
temp_column
],
{
add_concurrent_index
(
table
,
[
temp_column
],
unique:
true
,
name:
new_pk_index_name
}
)
)
end
end
end
...
...
@@ -763,7 +763,7 @@ module Mastodon
options
[
:using
]
=
index
.
using
if
index
.
using
options
[
:where
]
=
index
.
where
if
index
.
where
add_concurrent_index
(
table
,
new_columns
,
options
)
add_concurrent_index
(
table
,
new_columns
,
**
options
)
end
end
...
...
This diff is collapsed.
Click to expand it.
lib/paperclip/schema_extensions.rb
0 → 100644
+
37
−
0
View file @
a5f91a11
# frozen_string_literal: true
# Monkey-patch various Paperclip methods for Ruby 3.0 compatibility
module
Paperclip
module
Schema
module
StatementsExtensions
def
add_attachment
(
table_name
,
*
attachment_names
)
raise
ArgumentError
,
'Please specify attachment name in your add_attachment call in your migration.'
if
attachment_names
.
empty?
options
=
attachment_names
.
extract_options!
attachment_names
.
each
do
|
attachment_name
|
COLUMNS
.
each_pair
do
|
column_name
,
column_type
|
column_options
=
options
.
merge
(
options
[
column_name
.
to_sym
]
||
{})
add_column
(
table_name
,
"
#{
attachment_name
}
_
#{
column_name
}
"
,
column_type
,
**
column_options
)
end
end
end
end
module
TableDefinitionExtensions
def
attachment
(
*
attachment_names
)
options
=
attachment_names
.
extract_options!
attachment_names
.
each
do
|
attachment_name
|
COLUMNS
.
each_pair
do
|
column_name
,
column_type
|
column_options
=
options
.
merge
(
options
[
column_name
.
to_sym
]
||
{})
column
(
"
#{
attachment_name
}
_
#{
column_name
}
"
,
column_type
,
**
column_options
)
end
end
end
end
end
end
Paperclip
::
Schema
::
Statements
.
prepend
(
Paperclip
::
Schema
::
StatementsExtensions
)
Paperclip
::
Schema
::
TableDefinition
.
prepend
(
Paperclip
::
Schema
::
TableDefinitionExtensions
)
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