Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-11-01 00:09:31 +00:00
parent be1ea40ec4
commit 09237b02b5
4 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
# As discussed in https://github.com/rails/rails/issues/40687, this
# patch registers a few types to silence warnings when Rails comes
# across some PostgreSQL types it does not recognize.
module PostgreSQLAdapterCustomTypes
def initialize_type_map(m = type_map) # rubocop:disable Naming/MethodParameterName
m.register_type('xid', ActiveRecord::Type::Integer.new(limit: 8))
m.register_type('pg_node_tree', ActiveRecord::Type::String.new)
m.register_type('_aclitem', ActiveRecord::Type::String.new)
m.register_type('pg_lsn', ActiveRecord::Type::String.new)
super
end
end
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(PostgreSQLAdapterCustomTypes)

View File

@ -312,3 +312,16 @@ def down
remove_concurrent_index_by_name :ci_builds, INDEX_NAME
end
```
## Test database index changes locally
You must test the database index changes locally before creating a merge request.
### Verify indexes created asynchronously
Use the asynchronous index helpers on your local environment to test changes for creating an index:
1. Enable the feature flags by running `Feature.enable(:database_async_index_creation)` and `Feature.enable(:database_reindexing)` in the Rails console.
1. Run `bundle exec rails db:migrate` so that it creates an entry in the `postgres_async_indexes` table.
1. Run `bundle exec rails gitlab:db:reindex` so that the index is created asynchronously.
1. To verify the index, open the PostgreSQL console using the [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/postgresql.md) command `gdk psql` and run the command `\d <index_name>` to check that your newly created index exists.

View File

@ -58,7 +58,9 @@ For the bot:
- The name is set to the name of the token.
- The username is set to `project_{project_id}_bot` for the first access token, such as `project_123_bot`.
- The username is set to `project_{project_id}_bot{bot_count}` for further access tokens, such as `project_123_bot1`.
- The email is set to `project{project_id}_bot@example.com`, for example `project123_bot@example.com`.
- For additional access tokens in the same project, the username is set to `project_{project_id}_bot{bot_count}`, for example `project_123_bot1`.
- For additional acess tokens in the same project, the email is set to `project{project_id}_bot{bot_count}@example.com`, for example `project123_bot1@example.com`
API calls made with a project access token are associated with the corresponding bot user.

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'PostgreSQL registered types' do
subject(:types) { ApplicationRecord.connection.send(:type_map).keys }
# These can be obtained via SELECT oid, typname from pg_type
it 'includes custom and standard OIDs' do
expect(types).to include(28, 194, 1034, 3220, 23, 20)
end
it 'includes custom and standard types' do
expect(types).to include('xid', 'pg_node_tree', '_aclitem', 'pg_lsn', 'int4', 'int8')
end
end