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
afa8fab9
Commit
afa8fab9
authored
Jul 29, 2021
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '288005-finalize-push-events-payloads-bigint-conversion-take-2' into 'master'"
This reverts merge request !65795
parent
9e44919c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
62 deletions
+4
-62
db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb
...24048_finalize_push_event_payloads_bigint_conversion_2.rb
+2
-60
db/structure.sql
db/structure.sql
+2
-2
No files found.
db/post_migrate/20210709024048_finalize_push_event_payloads_bigint_conversion_2.rb
View file @
afa8fab9
...
...
@@ -3,69 +3,11 @@
class
FinalizePushEventPayloadsBigintConversion2
<
ActiveRecord
::
Migration
[
6.1
]
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
TABLE_NAME
=
'push_event_payloads'
INDEX_NAME
=
'index_push_event_payloads_on_event_id_convert_to_bigint'
def
up
ensure_batched_background_migration_is_finished
(
job_class_name:
'CopyColumnUsingBackgroundMigrationJob'
,
table_name:
TABLE_NAME
,
column_name:
'event_id'
,
job_arguments:
[[
"event_id"
],
[
"event_id_convert_to_bigint"
]]
)
swap_columns
# no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/5256
end
def
down
swap_columns
end
private
def
swap_columns
add_concurrent_index
TABLE_NAME
,
:event_id_convert_to_bigint
,
unique:
true
,
name:
INDEX_NAME
# Add a foreign key on `event_id_convert_to_bigint` before we swap the columns and drop the old FK (fk_36c74129da)
add_concurrent_foreign_key
TABLE_NAME
,
:events
,
column: :event_id_convert_to_bigint
,
on_delete: :cascade
with_lock_retries
(
raise_on_exhaustion:
true
)
do
# We'll need ACCESS EXCLUSIVE lock on the related tables,
# lets make sure it can be acquired from the start
execute
"LOCK TABLE
#{
TABLE_NAME
}
, events IN ACCESS EXCLUSIVE MODE"
# Swap column names
temp_name
=
'event_id_tmp'
execute
"ALTER TABLE
#{
quote_table_name
(
TABLE_NAME
)
}
RENAME COLUMN
#{
quote_column_name
(
:event_id
)
}
TO
#{
quote_column_name
(
temp_name
)
}
"
execute
"ALTER TABLE
#{
quote_table_name
(
TABLE_NAME
)
}
RENAME COLUMN
#{
quote_column_name
(
:event_id_convert_to_bigint
)
}
TO
#{
quote_column_name
(
:event_id
)
}
"
execute
"ALTER TABLE
#{
quote_table_name
(
TABLE_NAME
)
}
RENAME COLUMN
#{
quote_column_name
(
temp_name
)
}
TO
#{
quote_column_name
(
:event_id_convert_to_bigint
)
}
"
# We need to update the trigger function in order to make PostgreSQL to
# regenerate the execution plan for it. This is to avoid type mismatch errors like
# "type of parameter 15 (bigint) does not match that when preparing the plan (integer)"
function_name
=
Gitlab
::
Database
::
UnidirectionalCopyTrigger
.
on_table
(
TABLE_NAME
).
name
(
:event_id
,
:event_id_convert_to_bigint
)
execute
"ALTER FUNCTION
#{
quote_table_name
(
function_name
)
}
RESET ALL"
# Swap defaults
change_column_default
TABLE_NAME
,
:event_id
,
nil
change_column_default
TABLE_NAME
,
:event_id_convert_to_bigint
,
0
# Swap PK constraint
execute
"ALTER TABLE
#{
TABLE_NAME
}
DROP CONSTRAINT push_event_payloads_pkey"
rename_index
TABLE_NAME
,
INDEX_NAME
,
'push_event_payloads_pkey'
execute
"ALTER TABLE
#{
TABLE_NAME
}
ADD CONSTRAINT push_event_payloads_pkey PRIMARY KEY USING INDEX push_event_payloads_pkey"
# Drop original FK on the old int4 `event_id` (fk_36c74129da)
remove_foreign_key
TABLE_NAME
,
name:
concurrent_foreign_key_name
(
TABLE_NAME
,
:event_id
)
# We swapped the columns but the FK for event_id is still using the old name for the event_id_convert_to_bigint column
# So we have to also swap the FK name now that we dropped the other one with the same
rename_constraint
(
TABLE_NAME
,
concurrent_foreign_key_name
(
TABLE_NAME
,
:event_id_convert_to_bigint
),
concurrent_foreign_key_name
(
TABLE_NAME
,
:event_id
)
)
end
# no-op due to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/5256
end
end
db/structure.sql
View file @
afa8fab9
...
...
@@ -17561,7 +17561,7 @@ ALTER SEQUENCE protected_tags_id_seq OWNED BY protected_tags.id;
CREATE TABLE push_event_payloads (
commit_count bigint NOT NULL,
event_id
_convert_to_bigint integer DEFAULT 0
NOT NULL,
event_id
integer
NOT NULL,
action smallint NOT NULL,
ref_type smallint NOT NULL,
commit_from bytea,
...
...
@@ -17569,7 +17569,7 @@ CREATE TABLE push_event_payloads (
ref text,
commit_title character varying(70),
ref_count integer,
event_id
bigint
NOT NULL
event_id
_convert_to_bigint bigint DEFAULT 0
NOT NULL
);
CREATE TABLE push_rules (
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