Commit 54d2e98d authored by Yannis Roussos's avatar Yannis Roussos Committed by Mayra Cabrera

Enforce text columns with a limit on migrations

- Add Migration/String cop to enforce usage of the text
  data type instead of string
- Remove the existing Migration/AddLimitToStringColumns
  cop and its rspec tests as strings are no longer allowed
- Add Migration/Text cop to enforce limit on text columns
- Add rspec tests for the Migration/String and
  the Migration/Text cops
- Disable the offenses caused by existing migrations with
  strings or texts without limits
parent ed84d447
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/AbcSize
# rubocop:disable Migration/AddConcurrentForeignKey # rubocop:disable Migration/AddConcurrentForeignKey
# rubocop:disable Style/WordArray # rubocop:disable Style/WordArray
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
# rubocop:disable Migration/Datetime # rubocop:disable Migration/Datetime
class InitSchema < ActiveRecord::Migration[4.2] class InitSchema < ActiveRecord::Migration[4.2]
...@@ -1854,4 +1855,5 @@ class InitSchema < ActiveRecord::Migration[4.2] ...@@ -1854,4 +1855,5 @@ class InitSchema < ActiveRecord::Migration[4.2]
raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable" raise ActiveRecord::IrreversibleMigration, "The initial migration is not revertable"
end end
end end
# rubocop:enable Migration/AddLimitToStringColumns # rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
class CreatePrometheusMetrics < ActiveRecord::Migration[4.2] class CreatePrometheusMetrics < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :prometheus_metrics do |t| create_table :prometheus_metrics do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
t.string :title, null: false t.string :title, null: false
...@@ -15,6 +15,6 @@ class CreatePrometheusMetrics < ActiveRecord::Migration[4.2] ...@@ -15,6 +15,6 @@ class CreatePrometheusMetrics < ActiveRecord::Migration[4.2]
t.integer :group, null: false, index: true t.integer :group, null: false, index: true
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -10,7 +10,7 @@ class CreateLfsFileLocks < ActiveRecord::Migration[4.2] ...@@ -10,7 +10,7 @@ class CreateLfsFileLocks < ActiveRecord::Migration[4.2]
t.references :project, null: false, foreign_key: { on_delete: :cascade } t.references :project, null: false, foreign_key: { on_delete: :cascade }
t.references :user, null: false, index: true, foreign_key: { on_delete: :cascade } t.references :user, null: false, index: true, foreign_key: { on_delete: :cascade }
t.datetime :created_at, null: false # rubocop:disable Migration/Datetime t.datetime :created_at, null: false # rubocop:disable Migration/Datetime
t.string :path, limit: 511 t.string :path, limit: 511 # rubocop:disable Migration/PreventStrings
end end
add_index :lfs_file_locks, [:project_id, :path], unique: true add_index :lfs_file_locks, [:project_id, :path], unique: true
......
...@@ -7,7 +7,9 @@ class AddAutoDevopsDomainToApplicationSettings < ActiveRecord::Migration[4.2] ...@@ -7,7 +7,9 @@ class AddAutoDevopsDomainToApplicationSettings < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :auto_devops_domain, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :auto_devops_domain, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,10 +7,10 @@ class AddUploadsBuilderContext < ActiveRecord::Migration[4.2] ...@@ -7,10 +7,10 @@ class AddUploadsBuilderContext < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
add_column :uploads, :mount_point, :string add_column :uploads, :mount_point, :string
add_column :uploads, :secret, :string add_column :uploads, :secret, :string
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -9,7 +9,7 @@ class CreateChatopsTables < ActiveRecord::Migration[4.2] ...@@ -9,7 +9,7 @@ class CreateChatopsTables < ActiveRecord::Migration[4.2]
create_table :ci_pipeline_chat_data, id: :bigserial do |t| create_table :ci_pipeline_chat_data, id: :bigserial do |t|
t.integer :pipeline_id, null: false t.integer :pipeline_id, null: false
t.references :chat_name, foreign_key: { on_delete: :cascade }, null: false t.references :chat_name, foreign_key: { on_delete: :cascade }, null: false
t.text :response_url, null: false t.text :response_url, null: false # rubocop:disable Migration/AddLimitToTextColumns
# A pipeline can only contain one row in this table, hence this index is # A pipeline can only contain one row in this table, hence this index is
# unique. # unique.
......
...@@ -3,7 +3,9 @@ class AddExternalIpToClustersApplicationsIngress < ActiveRecord::Migration[4.2] ...@@ -3,7 +3,9 @@ class AddExternalIpToClustersApplicationsIngress < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :clusters_applications_ingress, :external_ip, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :clusters_applications_ingress, :external_ip, :string
end end
# rubocop:enable Migration/PreventStrings
end end
class CreateBadges < ActiveRecord::Migration[4.2] class CreateBadges < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :badges do |t| create_table :badges do |t|
t.string :link_url, null: false t.string :link_url, null: false
t.string :image_url, null: false t.string :image_url, null: false
...@@ -12,9 +12,10 @@ class CreateBadges < ActiveRecord::Migration[4.2] ...@@ -12,9 +12,10 @@ class CreateBadges < ActiveRecord::Migration[4.2]
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
end end
# rubocop:enable Migration/AddLimitToStringColumns
# rubocop:disable Migration/AddConcurrentForeignKey # rubocop:disable Migration/AddConcurrentForeignKey
add_foreign_key :badges, :namespaces, column: :group_id, on_delete: :cascade add_foreign_key :badges, :namespaces, column: :group_id, on_delete: :cascade
# rubocop:enable Migration/AddConcurrentForeignKey
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -13,8 +13,8 @@ class CreateClustersApplicationsRunners < ActiveRecord::Migration[4.2] ...@@ -13,8 +13,8 @@ class CreateClustersApplicationsRunners < ActiveRecord::Migration[4.2]
t.index :cluster_id, unique: true t.index :cluster_id, unique: true
t.integer :status, null: false t.integer :status, null: false
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.string :version, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :version, null: false # rubocop:disable Migration/PreventStrings
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
end end
add_concurrent_foreign_key :clusters_applications_runners, :ci_runners, add_concurrent_foreign_key :clusters_applications_runners, :ci_runners,
......
...@@ -3,6 +3,6 @@ class AddPagesDomainVerification < ActiveRecord::Migration[4.2] ...@@ -3,6 +3,6 @@ class AddPagesDomainVerification < ActiveRecord::Migration[4.2]
def change def change
add_column :pages_domains, :verified_at, :datetime_with_timezone add_column :pages_domains, :verified_at, :datetime_with_timezone
add_column :pages_domains, :verification_code, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :pages_domains, :verification_code, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -4,6 +4,6 @@ class AddIpAddressToRunner < ActiveRecord::Migration[4.2] ...@@ -4,6 +4,6 @@ class AddIpAddressToRunner < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :ci_runners, :ip_address, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :ci_runners, :ip_address, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -3,9 +3,11 @@ class AddUserInternalRegexToApplicationSetting < ActiveRecord::Migration[4.2] ...@@ -3,9 +3,11 @@ class AddUserInternalRegexToApplicationSetting < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :application_settings, :user_default_internal_regex, :string, null: true # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :user_default_internal_regex, :string, null: true
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :application_settings, :user_default_internal_regex remove_column :application_settings, :user_default_internal_regex
......
...@@ -6,6 +6,7 @@ class AddHeaderAndFooterBannersToAppearancesTable < ActiveRecord::Migration[4.2] ...@@ -6,6 +6,7 @@ class AddHeaderAndFooterBannersToAppearancesTable < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
# rubocop:disable Migration/AddLimitToTextColumns
add_column :appearances, :header_message, :text add_column :appearances, :header_message, :text
add_column :appearances, :header_message_html, :text add_column :appearances, :header_message_html, :text
...@@ -14,5 +15,6 @@ class AddHeaderAndFooterBannersToAppearancesTable < ActiveRecord::Migration[4.2] ...@@ -14,5 +15,6 @@ class AddHeaderAndFooterBannersToAppearancesTable < ActiveRecord::Migration[4.2]
add_column :appearances, :message_background_color, :text add_column :appearances, :message_background_color, :text
add_column :appearances, :message_font_color, :text add_column :appearances, :message_font_color, :text
# rubocop:enable Migration/AddLimitToTextColumns
end end
end end
class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration[4.2] class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
add_column :application_settings, add_column :application_settings,
:external_auth_client_cert, :text :external_auth_client_cert, :text
add_column :application_settings, add_column :application_settings,
...@@ -13,6 +14,7 @@ class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration[ ...@@ -13,6 +14,7 @@ class AddExternalAuthMutualTlsFieldsToProjectSettings < ActiveRecord::Migration[
:encrypted_external_auth_client_key_pass, :string :encrypted_external_auth_client_key_pass, :string
add_column :application_settings, add_column :application_settings,
:encrypted_external_auth_client_key_pass_iv, :string :encrypted_external_auth_client_key_pass_iv, :string
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
class CreateDeployTokens < ActiveRecord::Migration[4.2] class CreateDeployTokens < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :deploy_tokens do |t| create_table :deploy_tokens do |t|
t.boolean :revoked, default: false t.boolean :revoked, default: false
t.boolean :read_repository, null: false, default: false t.boolean :read_repository, null: false, default: false
...@@ -16,6 +16,6 @@ class CreateDeployTokens < ActiveRecord::Migration[4.2] ...@@ -16,6 +16,6 @@ class CreateDeployTokens < ActiveRecord::Migration[4.2]
t.index [:token, :expires_at, :id], where: "(revoked IS FALSE)" t.index [:token, :expires_at, :id], where: "(revoked IS FALSE)"
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ class CreateApplicationSettingTerms < ActiveRecord::Migration[4.2] ...@@ -3,6 +3,7 @@ class CreateApplicationSettingTerms < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :application_setting_terms do |t| create_table :application_setting_terms do |t|
t.integer :cached_markdown_version t.integer :cached_markdown_version
...@@ -10,4 +11,5 @@ class CreateApplicationSettingTerms < ActiveRecord::Migration[4.2] ...@@ -10,4 +11,5 @@ class CreateApplicationSettingTerms < ActiveRecord::Migration[4.2]
t.text :terms_html t.text :terms_html
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -3,7 +3,8 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2] ...@@ -3,7 +3,8 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def up def up
if table_exists?(:project_mirror_data) if table_exists?(:project_mirror_data)
add_column :project_mirror_data, :status, :string unless column_exists?(:project_mirror_data, :status) add_column :project_mirror_data, :status, :string unless column_exists?(:project_mirror_data, :status)
...@@ -18,7 +19,8 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2] ...@@ -18,7 +19,8 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2]
end end
end end
end end
# rubocop:enable Migration/AddLimitToStringColumns # rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :project_mirror_data, :status remove_column :project_mirror_data, :status
......
...@@ -5,7 +5,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2] ...@@ -5,7 +5,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
def up def up
return if table_exists?(:remote_mirrors) return if table_exists?(:remote_mirrors)
...@@ -20,7 +20,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2] ...@@ -20,7 +20,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2]
t.string :last_error t.string :last_error
t.boolean :only_protected_branches, default: false, null: false t.boolean :only_protected_branches, default: false, null: false
t.string :remote_name t.string :remote_name
t.text :encrypted_credentials t.text :encrypted_credentials # rubocop:disable Migration/AddLimitToTextColumns
t.string :encrypted_credentials_iv t.string :encrypted_credentials_iv
t.string :encrypted_credentials_salt t.string :encrypted_credentials_salt
...@@ -28,7 +28,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2] ...@@ -28,7 +28,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2]
t.timestamps null: false t.timestamps null: false
end end
end end
# rubocop:enable Migration/AddLimitToStringColumns # rubocop:enable Migration/PreventStrings
def down def down
# ee/db/migrate/20160321161032_create_remote_mirrors_ee.rb will remove the table # ee/db/migrate/20160321161032_create_remote_mirrors_ee.rb will remove the table
......
...@@ -3,11 +3,15 @@ class EnsureMissingColumnsToProjectMirrorData < ActiveRecord::Migration[4.2] ...@@ -3,11 +3,15 @@ class EnsureMissingColumnsToProjectMirrorData < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
# rubocop:disable Migration/PreventStrings
def up def up
add_column :project_mirror_data, :status, :string unless column_exists?(:project_mirror_data, :status) # rubocop:disable Migration/AddLimitToStringColumns add_column :project_mirror_data, :status, :string unless column_exists?(:project_mirror_data, :status)
add_column :project_mirror_data, :jid, :string unless column_exists?(:project_mirror_data, :jid) # rubocop:disable Migration/AddLimitToStringColumns add_column :project_mirror_data, :jid, :string unless column_exists?(:project_mirror_data, :jid)
add_column :project_mirror_data, :last_error, :text unless column_exists?(:project_mirror_data, :last_error) add_column :project_mirror_data, :last_error, :text unless column_exists?(:project_mirror_data, :last_error)
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddLimitToTextColumns
def down def down
# db/migrate/20180502122856_create_project_mirror_data.rb will remove the table # db/migrate/20180502122856_create_project_mirror_data.rb will remove the table
......
...@@ -6,20 +6,20 @@ class CreateClustersApplicationsJupyter < ActiveRecord::Migration[4.2] ...@@ -6,20 +6,20 @@ class CreateClustersApplicationsJupyter < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :clusters_applications_jupyter do |t| create_table :clusters_applications_jupyter do |t|
t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
t.references :oauth_application, foreign_key: { on_delete: :nullify } t.references :oauth_application, foreign_key: { on_delete: :nullify }
t.integer :status, null: false t.integer :status, null: false
t.string :version, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :version, null: false
t.string :hostname # rubocop:disable Migration/AddLimitToStringColumns t.string :hostname
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,8 +3,9 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2] ...@@ -3,8 +3,9 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/AddLimitToTextColumns
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :note_diff_files do |t| create_table :note_diff_files do |t|
t.references :diff_note, references: :notes, null: false, index: { unique: true } t.references :diff_note, references: :notes, null: false, index: { unique: true }
t.text :diff, null: false t.text :diff, null: false
...@@ -19,6 +20,8 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2] ...@@ -19,6 +20,8 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2]
# rubocop:disable Migration/AddConcurrentForeignKey # rubocop:disable Migration/AddConcurrentForeignKey
add_foreign_key :note_diff_files, :notes, column: :diff_note_id, on_delete: :cascade add_foreign_key :note_diff_files, :notes, column: :diff_note_id, on_delete: :cascade
# rubocop:enable Migration/AddLimitToStringColumns # rubocop:enable Migration/AddConcurrentForeignKey
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -5,10 +5,11 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2] ...@@ -5,10 +5,11 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up
# rubocop:disable Migration/Datetime # rubocop:disable Migration/Datetime
# rubocop:disable Migration/PreventStrings
def up
add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at) add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at)
add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name) # rubocop:disable Migration/AddLimitToStringColumns add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name)
unless column_exists?(:remote_mirrors, :only_protected_branches) unless column_exists?(:remote_mirrors, :only_protected_branches)
add_column_with_default(:remote_mirrors, add_column_with_default(:remote_mirrors,
...@@ -18,6 +19,8 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2] ...@@ -18,6 +19,8 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2]
allow_null: false) allow_null: false)
end end
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/Datetime
def down def down
# db/migrate/20180503131624_create_remote_mirrors.rb will remove the table # db/migrate/20180503131624_create_remote_mirrors.rb will remove the table
......
...@@ -3,8 +3,8 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2] ...@@ -3,8 +3,8 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
# rubocop:disable Migration/AddLimitToStringColumns
create_table(:programming_languages) do |t| create_table(:programming_languages) do |t|
t.string :name, null: false t.string :name, null: false
t.string :color, null: false t.string :color, null: false
...@@ -20,8 +20,8 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2] ...@@ -20,8 +20,8 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2]
add_index :programming_languages, :name, unique: true add_index :programming_languages, :name, unique: true
add_index :repository_languages, [:project_id, :programming_language_id], add_index :repository_languages, [:project_id, :programming_language_id],
unique: true, name: "index_repository_languages_on_project_and_languages_id" unique: true, name: "index_repository_languages_on_project_and_languages_id"
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
def down def down
drop_table :repository_languages drop_table :repository_languages
......
...@@ -7,6 +7,6 @@ class AddPushEventsBranchFilterToWebHooks < ActiveRecord::Migration[4.2] ...@@ -7,6 +7,6 @@ class AddPushEventsBranchFilterToWebHooks < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :web_hooks, :push_events_branch_filter, :text add_column :web_hooks, :push_events_branch_filter, :text # rubocop:disable Migration/AddLimitToTextColumns
end end
end end
...@@ -4,9 +4,11 @@ class AddColumnsForHelmTillerCertificates < ActiveRecord::Migration[4.2] ...@@ -4,9 +4,11 @@ class AddColumnsForHelmTillerCertificates < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :clusters_applications_helm, :encrypted_ca_key, :text add_column :clusters_applications_helm, :encrypted_ca_key, :text
add_column :clusters_applications_helm, :encrypted_ca_key_iv, :text add_column :clusters_applications_helm, :encrypted_ca_key_iv, :text
add_column :clusters_applications_helm, :ca_cert, :text add_column :clusters_applications_helm, :ca_cert, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -7,8 +7,8 @@ class CreateCiBuildsRunnerSession < ActiveRecord::Migration[4.2] ...@@ -7,8 +7,8 @@ class CreateCiBuildsRunnerSession < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :ci_builds_runner_session, id: :bigserial do |t| create_table :ci_builds_runner_session, id: :bigserial do |t|
t.integer :build_id, null: false t.integer :build_id, null: false
t.string :url, null: false t.string :url, null: false
...@@ -18,6 +18,6 @@ class CreateCiBuildsRunnerSession < ActiveRecord::Migration[4.2] ...@@ -18,6 +18,6 @@ class CreateCiBuildsRunnerSession < ActiveRecord::Migration[4.2]
t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade
t.index :build_id, unique: true t.index :build_id, unique: true
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
class CreateImportExportUploads < ActiveRecord::Migration[4.2] class CreateImportExportUploads < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :import_export_uploads do |t| create_table :import_export_uploads do |t|
t.datetime_with_timezone :updated_at, null: false t.datetime_with_timezone :updated_at, null: false
...@@ -13,4 +14,5 @@ class CreateImportExportUploads < ActiveRecord::Migration[4.2] ...@@ -13,4 +14,5 @@ class CreateImportExportUploads < ActiveRecord::Migration[4.2]
add_index :import_export_uploads, :updated_at add_index :import_export_uploads, :updated_at
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -5,8 +5,8 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2] ...@@ -5,8 +5,8 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :user_statuses, id: false, primary_key: :user_id do |t| create_table :user_statuses, id: false, primary_key: :user_id do |t|
t.references :user, t.references :user,
foreign_key: { on_delete: :cascade }, foreign_key: { on_delete: :cascade },
...@@ -17,6 +17,6 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2] ...@@ -17,6 +17,6 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2]
t.string :message, limit: 100 t.string :message, limit: 100
t.string :message_html t.string :message_html
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -27,11 +27,11 @@ class AddCommitEmailToUsers < ActiveRecord::Migration[4.2] ...@@ -27,11 +27,11 @@ class AddCommitEmailToUsers < ActiveRecord::Migration[4.2]
# comments: # comments:
# disable_ddl_transaction! # disable_ddl_transaction!
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddColumnsToWideTables # rubocop:disable Migration/AddColumnsToWideTables
def change def change
add_column :users, :commit_email, :string add_column :users, :commit_email, :string
end end
# rubocop:enable Migration/AddLimitToStringColumns
# rubocop:enable Migration/AddColumnsToWideTables # rubocop:enable Migration/AddColumnsToWideTables
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddOutboundRequestsWhitelistToApplicationSettings < ActiveRecord::Migration[5.1] class AddOutboundRequestsWhitelistToApplicationSettings < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :outbound_local_requests_whitelist, :string, array: true, limit: 255 add_column :application_settings, :outbound_local_requests_whitelist, :string, array: true, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -6,6 +6,6 @@ class AddIdentifierToPrometheusMetric < ActiveRecord::Migration[4.2] ...@@ -6,6 +6,6 @@ class AddIdentifierToPrometheusMetric < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :prometheus_metrics, :identifier, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :prometheus_metrics, :identifier, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class AddResourceLabelEventReferenceFields < ActiveRecord::Migration[4.2] class AddResourceLabelEventReferenceFields < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :resource_label_events, :cached_markdown_version, :integer add_column :resource_label_events, :cached_markdown_version, :integer
add_column :resource_label_events, :reference, :text add_column :resource_label_events, :reference, :text
add_column :resource_label_events, :reference_html, :text add_column :resource_label_events, :reference_html, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -5,13 +5,13 @@ class AddAttrEncryptedColumnsToWebHook < ActiveRecord::Migration[4.2] ...@@ -5,13 +5,13 @@ class AddAttrEncryptedColumnsToWebHook < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
add_column :web_hooks, :encrypted_token, :string add_column :web_hooks, :encrypted_token, :string
add_column :web_hooks, :encrypted_token_iv, :string add_column :web_hooks, :encrypted_token_iv, :string
add_column :web_hooks, :encrypted_url, :string add_column :web_hooks, :encrypted_url, :string
add_column :web_hooks, :encrypted_url_iv, :string add_column :web_hooks, :encrypted_url_iv, :string
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,7 +8,7 @@ class AddTokenDigestToPersonalAccessTokens < ActiveRecord::Migration[4.2] ...@@ -8,7 +8,7 @@ class AddTokenDigestToPersonalAccessTokens < ActiveRecord::Migration[4.2]
def up def up
change_column :personal_access_tokens, :token, :string, null: true change_column :personal_access_tokens, :token, :string, null: true
add_column :personal_access_tokens, :token_digest, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :personal_access_tokens, :token_digest, :string # rubocop:disable Migration/PreventStrings
end end
def down def down
......
...@@ -5,8 +5,8 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2] ...@@ -5,8 +5,8 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table "clusters_applications_knative" do |t| create_table "clusters_applications_knative" do |t|
t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
...@@ -15,8 +15,8 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2] ...@@ -15,8 +15,8 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2]
t.integer "status", null: false t.integer "status", null: false
t.string "version", null: false t.string "version", null: false
t.string "hostname" t.string "hostname"
t.text "status_reason" t.text "status_reason" # rubocop:disable Migration/AddLimitToTextColumns
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -4,8 +4,8 @@ class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2] ...@@ -4,8 +4,8 @@ class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
INDEX_NAME = 'kubernetes_namespaces_cluster_and_namespace' INDEX_NAME = 'kubernetes_namespaces_cluster_and_namespace'
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :clusters_kubernetes_namespaces, id: :bigserial do |t| create_table :clusters_kubernetes_namespaces, id: :bigserial do |t|
t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade } t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade }
t.references :project, index: true, foreign_key: { on_delete: :nullify } t.references :project, index: true, foreign_key: { on_delete: :nullify }
...@@ -17,10 +17,10 @@ class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2] ...@@ -17,10 +17,10 @@ class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2]
t.string :namespace, null: false t.string :namespace, null: false
t.string :service_account_name t.string :service_account_name
t.text :encrypted_service_account_token t.text :encrypted_service_account_token # rubocop:disable Migration/AddLimitToTextColumns
t.index [:cluster_id, :namespace], name: INDEX_NAME, unique: true t.index [:cluster_id, :namespace], name: INDEX_NAME, unique: true
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,7 +5,7 @@ class AddShardsTable < ActiveRecord::Migration[4.2] ...@@ -5,7 +5,7 @@ class AddShardsTable < ActiveRecord::Migration[4.2]
def change def change
create_table :shards do |t| create_table :shards do |t|
t.string :name, null: false, index: { unique: true } # rubocop:disable Migration/AddLimitToStringColumns t.string :name, null: false, index: { unique: true } # rubocop:disable Migration/PreventStrings
end end
end end
end end
...@@ -6,7 +6,7 @@ class AddRepositoriesTable < ActiveRecord::Migration[4.2] ...@@ -6,7 +6,7 @@ class AddRepositoriesTable < ActiveRecord::Migration[4.2]
def change def change
create_table :repositories, id: :bigserial do |t| create_table :repositories, id: :bigserial do |t|
t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
t.string :disk_path, null: false, index: { unique: true } # rubocop:disable Migration/AddLimitToStringColumns t.string :disk_path, null: false, index: { unique: true } # rubocop:disable Migration/PreventStrings
end end
add_column :projects, :pool_repository_id, :bigint # rubocop:disable Migration/AddColumnsToWideTables add_column :projects, :pool_repository_id, :bigint # rubocop:disable Migration/AddColumnsToWideTables
......
...@@ -5,7 +5,9 @@ class AddPrivateCommitEmailHostnameToApplicationSettings < ActiveRecord::Migrati ...@@ -5,7 +5,9 @@ class AddPrivateCommitEmailHostnameToApplicationSettings < ActiveRecord::Migrati
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column(:application_settings, :commit_email_hostname, :string, null: true) # rubocop:disable Migration/AddLimitToStringColumns add_column(:application_settings, :commit_email_hostname, :string, null: true)
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -10,7 +10,6 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2] ...@@ -10,7 +10,6 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2]
end end
def down def down
# rubocop:disable Migration/AddLimitToStringColumns
create_table :gcp_clusters do |t| create_table :gcp_clusters do |t|
# Order columns by best align scheme # Order columns by best align scheme
t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
...@@ -50,6 +49,5 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2] ...@@ -50,6 +49,5 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2]
t.text :encrypted_gcp_token t.text :encrypted_gcp_token
t.string :encrypted_gcp_token_iv t.string :encrypted_gcp_token_iv
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
end end
...@@ -5,17 +5,17 @@ class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2] ...@@ -5,17 +5,17 @@ class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :clusters_applications_cert_managers do |t| create_table :clusters_applications_cert_managers do |t|
t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade } t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
t.integer :status, null: false t.integer :status, null: false
t.string :version, null: false t.string :version, null: false
t.string :email, null: false t.string :email, null: false
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
t.index :cluster_id, unique: true t.index :cluster_id, unique: true
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,7 +5,9 @@ class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration[4.2] ...@@ -5,7 +5,9 @@ class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :runners_registration_token_encrypted, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :runners_registration_token_encrypted, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,7 +8,9 @@ class KnativeExternalIp < ActiveRecord::Migration[4.2] ...@@ -8,7 +8,9 @@ class KnativeExternalIp < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :clusters_applications_knative, :external_ip, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :clusters_applications_knative, :external_ip, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,7 +5,9 @@ class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration[4.2] ...@@ -5,7 +5,9 @@ class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :namespaces, :runners_token_encrypted, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :namespaces, :runners_token_encrypted, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -6,10 +6,10 @@ class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration[4.2] ...@@ -6,10 +6,10 @@ class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables # rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
def change def change
add_column :projects, :runners_token_encrypted, :string add_column :projects, :runners_token_encrypted, :string
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables # rubocop:enable Migration/AddColumnsToWideTables
# rubocop:enable Migration/AddLimitToStringColumns
end end
...@@ -6,6 +6,6 @@ class AddTokenEncryptedToCiRunners < ActiveRecord::Migration[4.2] ...@@ -6,6 +6,6 @@ class AddTokenEncryptedToCiRunners < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :ci_runners, :token_encrypted, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :ci_runners, :token_encrypted, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -11,7 +11,7 @@ class CreateProjectRepositories < ActiveRecord::Migration[5.0] ...@@ -11,7 +11,7 @@ class CreateProjectRepositories < ActiveRecord::Migration[5.0]
def change def change
create_table :project_repositories, id: :bigserial do |t| create_table :project_repositories, id: :bigserial do |t|
t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
t.string :disk_path, null: false, index: { unique: true } # rubocop:disable Migration/AddLimitToStringColumns t.string :disk_path, null: false, index: { unique: true } # rubocop:disable Migration/PreventStrings
t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
end end
end end
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
class CreateSuggestions < ActiveRecord::Migration[5.0] class CreateSuggestions < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :suggestions, id: :bigserial do |t| create_table :suggestions, id: :bigserial do |t|
t.references :note, foreign_key: { on_delete: :cascade }, null: false t.references :note, foreign_key: { on_delete: :cascade }, null: false
t.integer :relative_order, null: false, limit: 2 t.integer :relative_order, null: false, limit: 2
t.boolean :applied, null: false, default: false t.boolean :applied, null: false, default: false
t.string :commit_id # rubocop:disable Migration/AddLimitToStringColumns t.string :commit_id
t.text :from_content, null: false t.text :from_content, null: false
t.text :to_content, null: false t.text :to_content, null: false
...@@ -17,4 +19,6 @@ class CreateSuggestions < ActiveRecord::Migration[5.0] ...@@ -17,4 +19,6 @@ class CreateSuggestions < ActiveRecord::Migration[5.0]
unique: true unique: true
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,13 +7,17 @@ class AddStateToPoolRepository < ActiveRecord::Migration[5.0] ...@@ -7,13 +7,17 @@ class AddStateToPoolRepository < ActiveRecord::Migration[5.0]
# Given the table is empty, and the non concurrent methods are chosen so # Given the table is empty, and the non concurrent methods are chosen so
# the transactions don't have to be disabled # the transactions don't have to be disabled
# rubocop: disable Migration/AddConcurrentForeignKey, Migration/AddIndex # rubocop:disable Migration/AddConcurrentForeignKey
# rubocop:disable Migration/AddIndex
# rubocop:disable Migration/PreventStrings
def change def change
add_column(:pool_repositories, :state, :string, null: true) # rubocop:disable Migration/AddLimitToStringColumns add_column(:pool_repositories, :state, :string, null: true)
add_column :pool_repositories, :source_project_id, :integer add_column :pool_repositories, :source_project_id, :integer
add_index :pool_repositories, :source_project_id, unique: true add_index :pool_repositories, :source_project_id, unique: true
add_foreign_key :pool_repositories, :projects, column: :source_project_id, on_delete: :nullify add_foreign_key :pool_repositories, :projects, column: :source_project_id, on_delete: :nullify
end end
# rubocop: enable Migration/AddConcurrentForeignKey, Migration/AddIndex # rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddIndex
# rubocop:enable Migration/AddConcurrentForeignKey
end end
...@@ -6,10 +6,10 @@ class AddTokenEncryptedToCiBuilds < ActiveRecord::Migration[5.0] ...@@ -6,10 +6,10 @@ class AddTokenEncryptedToCiBuilds < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables # rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
def change def change
add_column :ci_builds, :token_encrypted, :string add_column :ci_builds, :token_encrypted, :string
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables # rubocop:enable Migration/AddColumnsToWideTables
# rubocop:enable Migration/AddLimitToStringColumns
end end
...@@ -4,10 +4,10 @@ class AddProjectBfgObjectMapColumn < ActiveRecord::Migration[5.0] ...@@ -4,10 +4,10 @@ class AddProjectBfgObjectMapColumn < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables # rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/AddLimitToStringColumns # rubocop:disable Migration/PreventStrings
def change def change
add_column :projects, :bfg_object_map, :string add_column :projects, :bfg_object_map, :string
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables # rubocop:enable Migration/AddColumnsToWideTables
# rubocop:enable Migration/AddLimitToStringColumns
end end
...@@ -5,9 +5,11 @@ class AddNameAuthorIdAndShaToReleases < ActiveRecord::Migration[5.0] ...@@ -5,9 +5,11 @@ class AddNameAuthorIdAndShaToReleases < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :releases, :author_id, :integer add_column :releases, :author_id, :integer
add_column :releases, :name, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :releases, :name, :string
add_column :releases, :sha, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :releases, :sha, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,8 +5,8 @@ class CreateErrorTrackingSettings < ActiveRecord::Migration[5.0] ...@@ -5,8 +5,8 @@ class CreateErrorTrackingSettings < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :project_error_tracking_settings, id: :int, primary_key: :project_id, default: nil do |t| create_table :project_error_tracking_settings, id: :int, primary_key: :project_id, default: nil do |t|
t.boolean :enabled, null: false, default: true t.boolean :enabled, null: false, default: true
t.string :api_url, null: false t.string :api_url, null: false
...@@ -14,6 +14,6 @@ class CreateErrorTrackingSettings < ActiveRecord::Migration[5.0] ...@@ -14,6 +14,6 @@ class CreateErrorTrackingSettings < ActiveRecord::Migration[5.0]
t.string :encrypted_token_iv t.string :encrypted_token_iv
t.foreign_key :projects, column: :project_id, on_delete: :cascade t.foreign_key :projects, column: :project_id, on_delete: :cascade
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,8 +5,8 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0] ...@@ -5,8 +5,8 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :release_links, id: :bigserial do |t| create_table :release_links, id: :bigserial do |t|
t.references :release, null: false, index: false, foreign_key: { on_delete: :cascade } t.references :release, null: false, index: false, foreign_key: { on_delete: :cascade }
t.string :url, null: false t.string :url, null: false
...@@ -16,6 +16,6 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0] ...@@ -16,6 +16,6 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0]
t.index [:release_id, :url], unique: true t.index [:release_id, :url], unique: true
t.index [:release_id, :name], unique: true t.index [:release_id, :name], unique: true
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -11,7 +11,7 @@ class AddMergeRequestExternalDiffs < ActiveRecord::Migration[5.0] ...@@ -11,7 +11,7 @@ class AddMergeRequestExternalDiffs < ActiveRecord::Migration[5.0]
def change def change
# Allow the merge request diff to store details about an external file # Allow the merge request diff to store details about an external file
add_column :merge_request_diffs, :external_diff, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :merge_request_diffs, :external_diff, :string # rubocop:disable Migration/PreventStrings
add_column :merge_request_diffs, :external_diff_store, :integer add_column :merge_request_diffs, :external_diff_store, :integer
add_column :merge_request_diffs, :stored_externally, :boolean add_column :merge_request_diffs, :stored_externally, :boolean
......
...@@ -4,6 +4,6 @@ class AddDomainToCluster < ActiveRecord::Migration[5.0] ...@@ -4,6 +4,6 @@ class AddDomainToCluster < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :clusters, :domain, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :clusters, :domain, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -5,12 +5,14 @@ class AddColumnsProjectErrorTrackingSettings < ActiveRecord::Migration[5.0] ...@@ -5,12 +5,14 @@ class AddColumnsProjectErrorTrackingSettings < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :project_error_tracking_settings, :project_name, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_error_tracking_settings, :project_name, :string
add_column :project_error_tracking_settings, :organization_name, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_error_tracking_settings, :organization_name, :string
change_column_default :project_error_tracking_settings, :enabled, from: true, to: false change_column_default :project_error_tracking_settings, :enabled, from: true, to: false
change_column_null :project_error_tracking_settings, :api_url, true change_column_null :project_error_tracking_settings, :api_url, true
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -9,10 +9,12 @@ class AddSortingFieldsToUserPreference < ActiveRecord::Migration[5.0] ...@@ -9,10 +9,12 @@ class AddSortingFieldsToUserPreference < ActiveRecord::Migration[5.0]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :user_preferences, :issues_sort, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :user_preferences, :issues_sort, :string
add_column :user_preferences, :merge_requests_sort, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :user_preferences, :merge_requests_sort, :string
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :user_preferences, :issues_sort remove_column :user_preferences, :issues_sort
......
...@@ -6,11 +6,15 @@ class AddAssetProxySettings < ActiveRecord::Migration[5.0] ...@@ -6,11 +6,15 @@ class AddAssetProxySettings < ActiveRecord::Migration[5.0]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :application_settings, :asset_proxy_enabled, :boolean, default: false, null: false add_column :application_settings, :asset_proxy_enabled, :boolean, default: false, null: false
add_column :application_settings, :asset_proxy_url, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :asset_proxy_url, :string
add_column :application_settings, :asset_proxy_whitelist, :text add_column :application_settings, :asset_proxy_whitelist, :text
add_column :application_settings, :encrypted_asset_proxy_secret_key, :text add_column :application_settings, :encrypted_asset_proxy_secret_key, :text
add_column :application_settings, :encrypted_asset_proxy_secret_key_iv, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :encrypted_asset_proxy_secret_key_iv, :string
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
class AddExternalHostnameToIngressAndKnative < ActiveRecord::Migration[5.0] class AddExternalHostnameToIngressAndKnative < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :clusters_applications_ingress, :external_hostname, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :clusters_applications_ingress, :external_hostname, :string
add_column :clusters_applications_knative, :external_hostname, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :clusters_applications_knative, :external_hostname, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -9,7 +9,9 @@ class AddLetsEncryptNotificationEmailToApplicationSettings < ActiveRecord::Migra ...@@ -9,7 +9,9 @@ class AddLetsEncryptNotificationEmailToApplicationSettings < ActiveRecord::Migra
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :lets_encrypt_notification_email, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :lets_encrypt_notification_email, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -11,7 +11,7 @@ class AddFieldsToUserPreferences < ActiveRecord::Migration[5.0] ...@@ -11,7 +11,7 @@ class AddFieldsToUserPreferences < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
def up def up
add_column(:user_preferences, :timezone, :string) # rubocop:disable Migration/AddLimitToStringColumns add_column(:user_preferences, :timezone, :string) # rubocop:disable Migration/PreventStrings
add_column(:user_preferences, :time_display_relative, :boolean) add_column(:user_preferences, :time_display_relative, :boolean)
add_column(:user_preferences, :time_format_in_24h, :boolean) add_column(:user_preferences, :time_format_in_24h, :boolean)
end end
......
...@@ -5,7 +5,9 @@ class AddNotificationEmailToNotificationSettings < ActiveRecord::Migration[5.0] ...@@ -5,7 +5,9 @@ class AddNotificationEmailToNotificationSettings < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :notification_settings, :notification_email, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :notification_settings, :notification_email, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/AbcSize
# rubocop: disable Migration/Datetime # rubocop: disable Migration/Datetime
# rubocop: disable Migration/AddLimitToStringColumns # rubocop: disable Migration/PreventStrings
# rubocop: disable Migration/AddLimitToTextColumns
class BackportEnterpriseSchema < ActiveRecord::Migration[5.0] class BackportEnterpriseSchema < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
...@@ -2188,4 +2189,5 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0] ...@@ -2188,4 +2189,5 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0]
end end
# rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/AbcSize
# rubocop: enable Migration/Datetime # rubocop: enable Migration/Datetime
# rubocop: enable Migration/AddLimitToStringColumns # rubocop: enable Migration/PreventStrings
# rubocop: enable Migration/AddLimitToTextColumns
...@@ -10,7 +10,7 @@ class AddNameToGeoNodes < ActiveRecord::Migration[5.0] ...@@ -10,7 +10,7 @@ class AddNameToGeoNodes < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
def up def up
add_column :geo_nodes, :name, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :geo_nodes, :name, :string # rubocop:disable Migration/PreventStrings
# url is also unique, and its type and size is identical to the name column, # url is also unique, and its type and size is identical to the name column,
# so this is safe. # so this is safe.
......
...@@ -5,7 +5,7 @@ class AddCommentToVulnerabilityFeedback < ActiveRecord::Migration[5.1] ...@@ -5,7 +5,7 @@ class AddCommentToVulnerabilityFeedback < ActiveRecord::Migration[5.1]
def up def up
add_column :vulnerability_feedback, :comment_author_id, :integer add_column :vulnerability_feedback, :comment_author_id, :integer
add_column :vulnerability_feedback, :comment, :text add_column :vulnerability_feedback, :comment, :text # rubocop:disable Migration/AddLimitToTextColumns
add_column :vulnerability_feedback, :comment_timestamp, :datetime_with_timezone add_column :vulnerability_feedback, :comment_timestamp, :datetime_with_timezone
end end
......
...@@ -7,7 +7,7 @@ class CreateProjectMetricsSettings < ActiveRecord::Migration[5.0] ...@@ -7,7 +7,7 @@ class CreateProjectMetricsSettings < ActiveRecord::Migration[5.0]
def change def change
create_table :project_metrics_settings, id: :int, primary_key: :project_id, default: nil do |t| create_table :project_metrics_settings, id: :int, primary_key: :project_id, default: nil do |t|
t.string :external_dashboard_url, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :external_dashboard_url, null: false # rubocop:disable Migration/PreventStrings
t.foreign_key :projects, column: :project_id, on_delete: :cascade t.foreign_key :projects, column: :project_id, on_delete: :cascade
end end
end end
......
...@@ -9,8 +9,9 @@ class CreatePagesDomainAcmeOrders < ActiveRecord::Migration[5.1] ...@@ -9,8 +9,9 @@ class CreatePagesDomainAcmeOrders < ActiveRecord::Migration[5.1]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :pages_domain_acme_orders do |t| create_table :pages_domain_acme_orders do |t|
t.references :pages_domain, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer t.references :pages_domain, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer
...@@ -25,6 +26,7 @@ class CreatePagesDomainAcmeOrders < ActiveRecord::Migration[5.1] ...@@ -25,6 +26,7 @@ class CreatePagesDomainAcmeOrders < ActiveRecord::Migration[5.1]
t.text :encrypted_private_key, null: false t.text :encrypted_private_key, null: false
t.text :encrypted_private_key_iv, null: false t.text :encrypted_private_key_iv, null: false
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,8 +8,8 @@ class CreateIssueTrackerData < ActiveRecord::Migration[5.1] ...@@ -8,8 +8,8 @@ class CreateIssueTrackerData < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :issue_tracker_data do |t| create_table :issue_tracker_data do |t|
t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
t.timestamps_with_timezone t.timestamps_with_timezone
...@@ -20,6 +20,6 @@ class CreateIssueTrackerData < ActiveRecord::Migration[5.1] ...@@ -20,6 +20,6 @@ class CreateIssueTrackerData < ActiveRecord::Migration[5.1]
t.string :encrypted_new_issue_url t.string :encrypted_new_issue_url
t.string :encrypted_new_issue_url_iv t.string :encrypted_new_issue_url_iv
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,8 +8,8 @@ class CreateJiraTrackerData < ActiveRecord::Migration[5.1] ...@@ -8,8 +8,8 @@ class CreateJiraTrackerData < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :jira_tracker_data do |t| create_table :jira_tracker_data do |t|
t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
t.timestamps_with_timezone t.timestamps_with_timezone
...@@ -23,6 +23,6 @@ class CreateJiraTrackerData < ActiveRecord::Migration[5.1] ...@@ -23,6 +23,6 @@ class CreateJiraTrackerData < ActiveRecord::Migration[5.1]
t.string :encrypted_password_iv t.string :encrypted_password_iv
t.string :jira_issue_transition_id t.string :jira_issue_transition_id
end end
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -12,7 +12,7 @@ class CreateIpRestriction < ActiveRecord::Migration[5.1] ...@@ -12,7 +12,7 @@ class CreateIpRestriction < ActiveRecord::Migration[5.1]
type: :integer, type: :integer,
null: false, null: false,
index: true index: true
t.string :range, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :range, null: false # rubocop:disable Migration/PreventStrings
end end
add_foreign_key(:ip_restrictions, :namespaces, column: :group_id, on_delete: :cascade) # rubocop: disable Migration/AddConcurrentForeignKey add_foreign_key(:ip_restrictions, :namespaces, column: :group_id, on_delete: :cascade) # rubocop: disable Migration/AddConcurrentForeignKey
......
...@@ -9,8 +9,10 @@ class AddLetsEncryptPrivateKeyToApplicationSettings < ActiveRecord::Migration[5. ...@@ -9,8 +9,10 @@ class AddLetsEncryptPrivateKeyToApplicationSettings < ActiveRecord::Migration[5.
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :application_settings, :encrypted_lets_encrypt_private_key, :text add_column :application_settings, :encrypted_lets_encrypt_private_key, :text
add_column :application_settings, :encrypted_lets_encrypt_private_key_iv, :text add_column :application_settings, :encrypted_lets_encrypt_private_key_iv, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -9,7 +9,9 @@ class AddRequiredTemplateNameToApplicationSettings < ActiveRecord::Migration[5.1 ...@@ -9,7 +9,9 @@ class AddRequiredTemplateNameToApplicationSettings < ActiveRecord::Migration[5.1
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :required_instance_ci_template, :string, null: true # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :required_instance_ci_template, :string, null: true
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,7 +5,9 @@ class AddTokenEncryptedToOperationsFeatureFlagsClients < ActiveRecord::Migration ...@@ -5,7 +5,9 @@ class AddTokenEncryptedToOperationsFeatureFlagsClients < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :operations_feature_flags_clients, :token_encrypted, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :operations_feature_flags_clients, :token_encrypted, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -6,6 +6,6 @@ class AddNameToBadges < ActiveRecord::Migration[5.0] ...@@ -6,6 +6,6 @@ class AddNameToBadges < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :badges, :name, :string, null: true, limit: 255 add_column :badges, :name, :string, null: true, limit: 255 # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -5,10 +5,14 @@ class AddTargetProjectIdToMergeTrains < ActiveRecord::Migration[5.1] ...@@ -5,10 +5,14 @@ class AddTargetProjectIdToMergeTrains < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Rails/NotNullColumn
# rubocop:disable Migration/AddReference
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
# rubocop:disable Rails/NotNullColumn, Migration/AddReference
add_reference :merge_trains, :target_project, null: false, index: true, foreign_key: { on_delete: :cascade, to_table: :projects }, type: :integer add_reference :merge_trains, :target_project, null: false, index: true, foreign_key: { on_delete: :cascade, to_table: :projects }, type: :integer
add_column :merge_trains, :target_branch, :text, null: false add_column :merge_trains, :target_branch, :text, null: false
# rubocop:enable Rails/NotNullColumn, Migration/AddReference
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/AddReference
# rubocop:enable Rails/NotNullColumn
end end
...@@ -4,6 +4,6 @@ class AddUsernameToDeployTokens < ActiveRecord::Migration[5.1] ...@@ -4,6 +4,6 @@ class AddUsernameToDeployTokens < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :deploy_tokens, :username, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :deploy_tokens, :username, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -8,7 +8,7 @@ class CreateProjectAliases < ActiveRecord::Migration[5.1] ...@@ -8,7 +8,7 @@ class CreateProjectAliases < ActiveRecord::Migration[5.1]
def change def change
create_table :project_aliases do |t| create_table :project_aliases do |t|
t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer
t.string :name, null: false, index: { unique: true } # rubocop:disable Migration/AddLimitToStringColumns t.string :name, null: false, index: { unique: true } # rubocop:disable Migration/PreventStrings
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
end end
......
...@@ -4,6 +4,6 @@ class AddMergeRequestRebaseJid < ActiveRecord::Migration[5.1] ...@@ -4,6 +4,6 @@ class AddMergeRequestRebaseJid < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :merge_requests, :rebase_jid, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :merge_requests, :rebase_jid, :string # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -7,12 +7,12 @@ class AddGrafanaUrlToSettings < ActiveRecord::Migration[5.1] ...@@ -7,12 +7,12 @@ class AddGrafanaUrlToSettings < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
# rubocop:disable Migration/AddLimitToStringColumns
add_column_with_default(:application_settings, :grafana_url, :string, add_column_with_default(:application_settings, :grafana_url, :string,
default: '/-/grafana', allow_null: false) default: '/-/grafana', allow_null: false)
# rubocop:enable Migration/AddLimitToStringColumns
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column(:application_settings, :grafana_url) remove_column(:application_settings, :grafana_url)
......
...@@ -9,6 +9,6 @@ class AddDescriptionToServices < ActiveRecord::Migration[5.1] ...@@ -9,6 +9,6 @@ class AddDescriptionToServices < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :services, :description, :string, limit: 500 add_column :services, :description, :string, limit: 500 # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -9,8 +9,9 @@ class CreateJobVariables < ActiveRecord::Migration[5.1] ...@@ -9,8 +9,9 @@ class CreateJobVariables < ActiveRecord::Migration[5.1]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
# rubocop:disable Migration/AddLimitToStringColumns
create_table :ci_job_variables do |t| create_table :ci_job_variables do |t|
t.string :key, null: false t.string :key, null: false
t.text :encrypted_value t.text :encrypted_value
...@@ -18,8 +19,9 @@ class CreateJobVariables < ActiveRecord::Migration[5.1] ...@@ -18,8 +19,9 @@ class CreateJobVariables < ActiveRecord::Migration[5.1]
t.references :job, null: false, index: true, foreign_key: { to_table: :ci_builds, on_delete: :cascade } t.references :job, null: false, index: true, foreign_key: { to_table: :ci_builds, on_delete: :cascade }
t.integer :variable_type, null: false, limit: 2, default: 1 t.integer :variable_type, null: false, limit: 2, default: 1
end end
# rubocop:enable Migration/AddLimitToStringColumns
add_index :ci_job_variables, [:key, :job_id], unique: true add_index :ci_job_variables, [:key, :job_id], unique: true
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,7 +5,9 @@ class AddTokenEncryptedToDeployTokens < ActiveRecord::Migration[5.1] ...@@ -5,7 +5,9 @@ class AddTokenEncryptedToDeployTokens < ActiveRecord::Migration[5.1]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :deploy_tokens, :token_encrypted, :string, limit: 255 add_column :deploy_tokens, :token_encrypted, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -26,7 +26,7 @@ class CreateAnalyticsCycleAnalyticsProjectStages < ActiveRecord::Migration[5.2] ...@@ -26,7 +26,7 @@ class CreateAnalyticsCycleAnalyticsProjectStages < ActiveRecord::Migration[5.2]
}) })
t.boolean :hidden, default: false, null: false t.boolean :hidden, default: false, null: false
t.boolean :custom, default: true, null: false t.boolean :custom, default: true, null: false
t.string :name, null: false, limit: 255 t.string :name, null: false, limit: 255 # rubocop:disable Migration/PreventStrings
end end
add_index :analytics_cycle_analytics_project_stages, [:project_id, :name], unique: true, name: INDEX_PREFIX + 'on_project_id_and_name' add_index :analytics_cycle_analytics_project_stages, [:project_id, :name], unique: true, name: INDEX_PREFIX + 'on_project_id_and_name'
......
...@@ -8,9 +8,13 @@ class AddStaticObjectTokenToUsers < ActiveRecord::Migration[5.2] ...@@ -8,9 +8,13 @@ class AddStaticObjectTokenToUsers < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/PreventStrings
def up def up
add_column :users, :static_object_token, :string, limit: 255 # rubocop:disable Migration/AddColumnsToWideTables add_column :users, :static_object_token, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables
def down def down
remove_column :users, :static_object_token remove_column :users, :static_object_token
......
...@@ -7,8 +7,10 @@ class AddStaticObjectsExternalStorageColumnsToApplicationSettings < ActiveRecord ...@@ -7,8 +7,10 @@ class AddStaticObjectsExternalStorageColumnsToApplicationSettings < ActiveRecord
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :static_objects_external_storage_url, :string, limit: 255 add_column :application_settings, :static_objects_external_storage_url, :string, limit: 255
add_column :application_settings, :static_objects_external_storage_auth_token, :string, limit: 255 add_column :application_settings, :static_objects_external_storage_auth_token, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -16,7 +16,7 @@ class CreateAllowedEmailDomainsForGroups < ActiveRecord::Migration[5.2] ...@@ -16,7 +16,7 @@ class CreateAllowedEmailDomainsForGroups < ActiveRecord::Migration[5.2]
null: false, null: false,
index: true index: true
t.foreign_key :namespaces, column: :group_id, on_delete: :cascade t.foreign_key :namespaces, column: :group_id, on_delete: :cascade
t.string :domain, null: false, limit: 255 t.string :domain, null: false, limit: 255 # rubocop:disable Migration/PreventStrings
end end
end end
end end
...@@ -26,7 +26,7 @@ class CreateAnalyticsCycleAnalyticsGroupStages < ActiveRecord::Migration[5.2] ...@@ -26,7 +26,7 @@ class CreateAnalyticsCycleAnalyticsGroupStages < ActiveRecord::Migration[5.2]
}) })
t.boolean :hidden, default: false, null: false t.boolean :hidden, default: false, null: false
t.boolean :custom, default: true, null: false t.boolean :custom, default: true, null: false
t.string :name, null: false, limit: 255 t.string :name, null: false, limit: 255 # rubocop:disable Migration/PreventStrings
end end
add_index :analytics_cycle_analytics_group_stages, [:group_id, :name], unique: true, name: INDEX_PREFIX + 'on_group_id_and_name' add_index :analytics_cycle_analytics_group_stages, [:group_id, :name], unique: true, name: INDEX_PREFIX + 'on_group_id_and_name'
......
...@@ -11,7 +11,7 @@ class AddBuildNeed < ActiveRecord::Migration[5.2] ...@@ -11,7 +11,7 @@ class AddBuildNeed < ActiveRecord::Migration[5.2]
def change def change
create_table :ci_build_needs, id: :serial do |t| create_table :ci_build_needs, id: :serial do |t|
t.integer :build_id, null: false t.integer :build_id, null: false
t.text :name, null: false t.text :name, null: false # rubocop:disable Migration/AddLimitToTextColumns
t.index [:build_id, :name], unique: true t.index [:build_id, :name], unique: true
t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade
......
...@@ -16,10 +16,12 @@ class AddThrottleProtectedPathColumns < ActiveRecord::Migration[5.2] ...@@ -16,10 +16,12 @@ class AddThrottleProtectedPathColumns < ActiveRecord::Migration[5.2]
'/import/github/personal_access_token' '/import/github/personal_access_token'
] ]
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :throttle_protected_paths_enabled, :boolean, default: true, null: false add_column :application_settings, :throttle_protected_paths_enabled, :boolean, default: true, null: false
add_column :application_settings, :throttle_protected_paths_requests_per_period, :integer, default: 10, null: false add_column :application_settings, :throttle_protected_paths_requests_per_period, :integer, default: 10, null: false
add_column :application_settings, :throttle_protected_paths_period_in_seconds, :integer, default: 60, null: false add_column :application_settings, :throttle_protected_paths_period_in_seconds, :integer, default: 60, null: false
add_column :application_settings, :protected_paths, :string, array: true, limit: 255, default: DEFAULT_PROTECTED_PATHS add_column :application_settings, :protected_paths, :string, array: true, limit: 255, default: DEFAULT_PROTECTED_PATHS
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class AddProjectsSortingFieldToUserPreferences < ActiveRecord::Migration[5.2] class AddProjectsSortingFieldToUserPreferences < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :user_preferences, :projects_sort, :string, limit: 64 add_column :user_preferences, :projects_sort, :string, limit: 64
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :user_preferences, :projects_sort remove_column :user_preferences, :projects_sort
......
...@@ -8,9 +8,11 @@ class AddFirstLastNameToUser < ActiveRecord::Migration[5.2] ...@@ -8,9 +8,11 @@ class AddFirstLastNameToUser < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables # rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/PreventStrings
def change def change
add_column(:users, :first_name, :string, null: true, limit: 255) add_column(:users, :first_name, :string, null: true, limit: 255)
add_column(:users, :last_name, :string, null: true, limit: 255) add_column(:users, :last_name, :string, null: true, limit: 255)
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables # rubocop:enable Migration/AddColumnsToWideTables
end end
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
class CreateClusterProvidersAws < ActiveRecord::Migration[5.2] class CreateClusterProvidersAws < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :cluster_providers_aws do |t| create_table :cluster_providers_aws do |t|
t.references :cluster, null: false, type: :bigint, index: { unique: true }, foreign_key: { on_delete: :cascade } t.references :cluster, null: false, type: :bigint, index: { unique: true }, foreign_key: { on_delete: :cascade }
...@@ -30,4 +32,6 @@ class CreateClusterProvidersAws < ActiveRecord::Migration[5.2] ...@@ -30,4 +32,6 @@ class CreateClusterProvidersAws < ActiveRecord::Migration[5.2]
t.index [:cluster_id, :status] t.index [:cluster_id, :status]
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -9,10 +9,12 @@ class AddSourcegraphConfigurationToApplicationSettings < ActiveRecord::Migration ...@@ -9,10 +9,12 @@ class AddSourcegraphConfigurationToApplicationSettings < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column(:application_settings, :sourcegraph_enabled, :boolean, default: false, null: false) add_column(:application_settings, :sourcegraph_enabled, :boolean, default: false, null: false)
add_column(:application_settings, :sourcegraph_url, :string, null: true, limit: 255) add_column(:application_settings, :sourcegraph_url, :string, null: true, limit: 255)
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column(:application_settings, :sourcegraph_enabled) remove_column(:application_settings, :sourcegraph_enabled)
......
...@@ -8,7 +8,7 @@ class CreatePackageTag < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class CreatePackageTag < ActiveRecord::Migration[5.2]
def change def change
create_table :packages_package_tags do |t| create_table :packages_package_tags do |t|
t.references :package, index: true, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer t.references :package, index: true, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer
t.string :name, limit: 255, null: false t.string :name, limit: 255, null: false # rubocop:disable Migration/PreventStrings
end end
end end
end end
...@@ -6,6 +6,7 @@ class CreateExternalPullRequests < ActiveRecord::Migration[5.2] ...@@ -6,6 +6,7 @@ class CreateExternalPullRequests < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
INDEX = 'index_external_pull_requests_on_project_and_branches' INDEX = 'index_external_pull_requests_on_project_and_branches'
# rubocop:disable Migration/PreventStrings
def change def change
create_table :external_pull_requests do |t| create_table :external_pull_requests do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -22,4 +23,5 @@ class CreateExternalPullRequests < ActiveRecord::Migration[5.2] ...@@ -22,4 +23,5 @@ class CreateExternalPullRequests < ActiveRecord::Migration[5.2]
t.index [:project_id, :source_branch, :target_branch], unique: true, name: INDEX t.index [:project_id, :source_branch, :target_branch], unique: true, name: INDEX
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreateAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2] ...@@ -5,6 +5,7 @@ class CreateAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :analytics_repository_files do |t| create_table :analytics_repository_files do |t|
t.references :project, t.references :project,
...@@ -18,4 +19,5 @@ class CreateAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2] ...@@ -18,4 +19,5 @@ class CreateAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2]
add_index :analytics_repository_files, [:project_id, :file_path], unique: true add_index :analytics_repository_files, [:project_id, :file_path], unique: true
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateAlertsServiceData < ActiveRecord::Migration[5.2] class CreateAlertsServiceData < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :alerts_service_data do |t| create_table :alerts_service_data do |t|
t.references :service, type: :integer, index: true, null: false, t.references :service, type: :integer, index: true, null: false,
...@@ -12,4 +13,5 @@ class CreateAlertsServiceData < ActiveRecord::Migration[5.2] ...@@ -12,4 +13,5 @@ class CreateAlertsServiceData < ActiveRecord::Migration[5.2]
t.string :encrypted_token_iv, limit: 255 t.string :encrypted_token_iv, limit: 255
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2] ...@@ -5,6 +5,7 @@ class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :packages_conan_file_metadata do |t| create_table :packages_conan_file_metadata do |t|
t.references :package_file, index: { unique: true }, null: false, foreign_key: { to_table: :packages_package_files, on_delete: :cascade }, type: :bigint t.references :package_file, index: { unique: true }, null: false, foreign_key: { to_table: :packages_package_files, on_delete: :cascade }, type: :bigint
...@@ -15,4 +16,5 @@ class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2] ...@@ -15,4 +16,5 @@ class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2]
t.integer "conan_file_type", limit: 2, null: false t.integer "conan_file_type", limit: 2, null: false
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class AddSpdxIdToSoftwareLicenses < ActiveRecord::Migration[5.2] class AddSpdxIdToSoftwareLicenses < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :software_licenses, :spdx_identifier, :string, limit: 255 add_column :software_licenses, :spdx_identifier, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :software_licenses, :spdx_identifier remove_column :software_licenses, :spdx_identifier
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateGrafanaIntegrations < ActiveRecord::Migration[5.2] class CreateGrafanaIntegrations < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :grafana_integrations do |t| create_table :grafana_integrations do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, unique: true, null: false t.references :project, index: true, foreign_key: { on_delete: :cascade }, unique: true, null: false
...@@ -12,4 +13,5 @@ class CreateGrafanaIntegrations < ActiveRecord::Migration[5.2] ...@@ -12,4 +13,5 @@ class CreateGrafanaIntegrations < ActiveRecord::Migration[5.2]
t.string :grafana_url, null: false, limit: 1024 t.string :grafana_url, null: false, limit: 1024
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,6 +7,6 @@ class AddCleanupStatusReasonToCluster < ActiveRecord::Migration[5.2] ...@@ -7,6 +7,6 @@ class AddCleanupStatusReasonToCluster < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :clusters, :cleanup_status_reason, :text add_column :clusters, :cleanup_status_reason, :text # rubocop:disable Migration/AddLimitToTextColumns
end end
end end
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
class CreateMergeRequestContextCommitsAndDiffs < ActiveRecord::Migration[5.2] class CreateMergeRequestContextCommitsAndDiffs < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :merge_request_context_commits do |t| create_table :merge_request_context_commits do |t|
t.references :merge_request, foreign_key: { on_delete: :cascade } t.references :merge_request, foreign_key: { on_delete: :cascade }
...@@ -38,4 +40,6 @@ class CreateMergeRequestContextCommitsAndDiffs < ActiveRecord::Migration[5.2] ...@@ -38,4 +40,6 @@ class CreateMergeRequestContextCommitsAndDiffs < ActiveRecord::Migration[5.2]
t.index [:merge_request_context_commit_id, :sha], name: 'idx_mr_cc_diff_files_on_mr_cc_id_and_sha' t.index [:merge_request_context_commit_id, :sha], name: 'idx_mr_cc_diff_files_on_mr_cc_id_and_sha'
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
class AddPullMirrorBranchPrefixToProjects < ActiveRecord::Migration[5.2] class AddPullMirrorBranchPrefixToProjects < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/PreventStrings
def change def change
add_column :projects, :pull_mirror_branch_prefix, :string, limit: 50 # rubocop:disable Migration/AddColumnsToWideTables add_column :projects, :pull_mirror_branch_prefix, :string, limit: 50
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables
end end
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
class CreateX509Signatures < ActiveRecord::Migration[5.2] class CreateX509Signatures < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :x509_issuers do |t| create_table :x509_issuers do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -38,4 +39,5 @@ class CreateX509Signatures < ActiveRecord::Migration[5.2] ...@@ -38,4 +39,5 @@ class CreateX509Signatures < ActiveRecord::Migration[5.2]
t.integer :verification_status, limit: 2, default: 0, null: false t.integer :verification_status, limit: 2, default: 0, null: false
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -11,7 +11,7 @@ class CreateDescriptionVersions < ActiveRecord::Migration[5.2] ...@@ -11,7 +11,7 @@ class CreateDescriptionVersions < ActiveRecord::Migration[5.2]
t.references :issue, index: false, foreign_key: { on_delete: :cascade }, type: :integer t.references :issue, index: false, foreign_key: { on_delete: :cascade }, type: :integer
t.references :merge_request, index: false, foreign_key: { on_delete: :cascade }, type: :integer t.references :merge_request, index: false, foreign_key: { on_delete: :cascade }, type: :integer
t.references :epic, index: false, foreign_key: { on_delete: :cascade }, type: :integer t.references :epic, index: false, foreign_key: { on_delete: :cascade }, type: :integer
t.text :description t.text :description # rubocop:disable Migration/AddLimitToTextColumns
end end
add_index :description_versions, :issue_id, where: 'issue_id IS NOT NULL' add_index :description_versions, :issue_id, where: 'issue_id IS NOT NULL'
......
...@@ -8,6 +8,7 @@ class CreateVulnerabilities < ActiveRecord::Migration[5.2] ...@@ -8,6 +8,7 @@ class CreateVulnerabilities < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :vulnerabilities do |t| create_table :vulnerabilities do |t|
t.bigint "milestone_id" t.bigint "milestone_id"
...@@ -30,10 +31,11 @@ class CreateVulnerabilities < ActiveRecord::Migration[5.2] ...@@ -30,10 +31,11 @@ class CreateVulnerabilities < ActiveRecord::Migration[5.2]
t.integer "confidence", limit: 2, null: false # auto-calculated as lowest-confidence finding, but overrideable t.integer "confidence", limit: 2, null: false # auto-calculated as lowest-confidence finding, but overrideable
t.boolean "severity_overridden", default: false t.boolean "severity_overridden", default: false
t.boolean "confidence_overridden", default: false t.boolean "confidence_overridden", default: false
t.string "title", limit: 255, null: false t.string "title", limit: 255, null: false # rubocop:disable Migration/PreventStrings
t.text "title_html", null: false t.text "title_html", null: false
t.text "description" t.text "description"
t.text "description_html" t.text "description_html"
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -15,7 +15,7 @@ class CreateZoomMeetings < ActiveRecord::Migration[5.2] ...@@ -15,7 +15,7 @@ class CreateZoomMeetings < ActiveRecord::Migration[5.2]
null: false null: false
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.integer :issue_status, limit: 2, default: 1, null: false t.integer :issue_status, limit: 2, default: 1, null: false
t.string :url, limit: 255 t.string :url, limit: 255 # rubocop:disable Migration/PreventStrings
t.index [:issue_id, :issue_status], unique: true, t.index [:issue_id, :issue_status], unique: true,
where: "issue_status = #{ZOOM_MEETING_STATUS_ADDED}" where: "issue_status = #{ZOOM_MEETING_STATUS_ADDED}"
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateCiRef < ActiveRecord::Migration[5.2] class CreateCiRef < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :ci_refs do |t| create_table :ci_refs do |t|
t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer
...@@ -16,4 +17,5 @@ class CreateCiRef < ActiveRecord::Migration[5.2] ...@@ -16,4 +17,5 @@ class CreateCiRef < ActiveRecord::Migration[5.2]
t.index [:last_updated_by_pipeline_id] t.index [:last_updated_by_pipeline_id]
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,6 +8,7 @@ class CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2] ...@@ -8,6 +8,7 @@ class CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :clusters_applications_elastic_stacks do |t| create_table :clusters_applications_elastic_stacks do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -15,8 +16,9 @@ class CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2] ...@@ -15,8 +16,9 @@ class CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2]
t.integer :status, null: false t.integer :status, null: false
t.string :version, null: false, limit: 255 t.string :version, null: false, limit: 255
t.string :kibana_hostname, limit: 255 t.string :kibana_hostname, limit: 255
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
t.index :cluster_id, unique: true t.index :cluster_id, unique: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2] class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :self_managed_prometheus_alert_events do |t| create_table :self_managed_prometheus_alert_events do |t|
t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
...@@ -17,4 +18,5 @@ class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2] ...@@ -17,4 +18,5 @@ class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2]
t.index [:project_id, :payload_key], unique: true, name: 'idx_project_id_payload_key_self_managed_prometheus_alert_events' t.index [:project_id, :payload_key], unique: true, name: 'idx_project_id_payload_key_self_managed_prometheus_alert_events'
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
class CreateAwsRoles < ActiveRecord::Migration[5.2] class CreateAwsRoles < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :aws_roles, id: false do |t| create_table :aws_roles, id: false do |t|
t.references :user, primary_key: true, default: nil, type: :integer, index: { unique: true }, foreign_key: { on_delete: :cascade } t.references :user, primary_key: true, default: nil, type: :integer, index: { unique: true }, foreign_key: { on_delete: :cascade }
...@@ -18,4 +19,5 @@ class CreateAwsRoles < ActiveRecord::Migration[5.2] ...@@ -18,4 +19,5 @@ class CreateAwsRoles < ActiveRecord::Migration[5.2]
t.index :role_external_id, unique: true t.index :role_external_id, unique: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ class AddPendoUrlToApplicationSettings < ActiveRecord::Migration[5.2] ...@@ -3,7 +3,9 @@ class AddPendoUrlToApplicationSettings < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :pendo_url, :string, limit: 255 add_column :application_settings, :pendo_url, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,7 +7,9 @@ class AddCustomHttpCloneUrlRootToApplicationSettings < ActiveRecord::Migration[5 ...@@ -7,7 +7,9 @@ class AddCustomHttpCloneUrlRootToApplicationSettings < ActiveRecord::Migration[5
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :custom_http_clone_url_root, :string, limit: 511 add_column :application_settings, :custom_http_clone_url_root, :string, limit: 511
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddSnowplowIgluRegistryUrlToApplicationSettings < ActiveRecord::Migration[5.2] class AddSnowplowIgluRegistryUrlToApplicationSettings < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :application_settings, :snowplow_iglu_registry_url, :string, limit: 255 add_column :application_settings, :snowplow_iglu_registry_url, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2] ...@@ -5,6 +5,7 @@ class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :clusters_applications_crossplane do |t| create_table :clusters_applications_crossplane do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -12,8 +13,9 @@ class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2] ...@@ -12,8 +13,9 @@ class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2]
t.integer :status, null: false t.integer :status, null: false
t.string :version, null: false, limit: 255 t.string :version, null: false, limit: 255
t.string :stack, null: false, limit: 255 t.string :stack, null: false, limit: 255
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
t.index :cluster_id, unique: true t.index :cluster_id, unique: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
class AddSecretTokenToSnippet < ActiveRecord::Migration[5.2] class AddSecretTokenToSnippet < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :snippets, :encrypted_secret_token, :string, limit: 255 add_column :snippets, :encrypted_secret_token, :string, limit: 255
add_column :snippets, :encrypted_secret_token_iv, :string, limit: 255 add_column :snippets, :encrypted_secret_token_iv, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2] ...@@ -5,6 +5,7 @@ class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :packages_conan_metadata do |t| create_table :packages_conan_metadata do |t|
t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
...@@ -13,4 +14,5 @@ class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2] ...@@ -13,4 +14,5 @@ class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2]
t.string "package_channel", null: false, limit: 255 t.string "package_channel", null: false, limit: 255
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -4,6 +4,8 @@ class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2] ...@@ -4,6 +4,8 @@ class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :application_settings, :eks_integration_enabled, :boolean, null: false, default: false add_column :application_settings, :eks_integration_enabled, :boolean, null: false, default: false
add_column :application_settings, :eks_account_id, :string, limit: 128 add_column :application_settings, :eks_account_id, :string, limit: 128
...@@ -11,4 +13,6 @@ class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2] ...@@ -11,4 +13,6 @@ class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2]
add_column :application_settings, :encrypted_eks_secret_access_key_iv, :string, limit: 255 add_column :application_settings, :encrypted_eks_secret_access_key_iv, :string, limit: 255
add_column :application_settings, :encrypted_eks_secret_access_key, :text add_column :application_settings, :encrypted_eks_secret_access_key, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateServiceDeskSettings < ActiveRecord::Migration[5.2] class CreateServiceDeskSettings < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :service_desk_settings, id: false do |t| create_table :service_desk_settings, id: false do |t|
t.references :project, t.references :project,
...@@ -15,4 +16,5 @@ class CreateServiceDeskSettings < ActiveRecord::Migration[5.2] ...@@ -15,4 +16,5 @@ class CreateServiceDeskSettings < ActiveRecord::Migration[5.2]
t.string :issue_template_key, limit: 255 t.string :issue_template_key, limit: 255
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class DefaultCiConfigPath < ActiveRecord::Migration[5.2] class DefaultCiConfigPath < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :application_settings, :default_ci_config_path, :string, limit: 255 add_column :application_settings, :default_ci_config_path, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :application_settings, :default_ci_config_path remove_column :application_settings, :default_ci_config_path
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateContainerExpirationPolicies < ActiveRecord::Migration[5.2] class CreateContainerExpirationPolicies < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :container_expiration_policies, id: false, primary_key: :project_id do |t| create_table :container_expiration_policies, id: false, primary_key: :project_id do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -18,4 +19,5 @@ class CreateContainerExpirationPolicies < ActiveRecord::Migration[5.2] ...@@ -18,4 +19,5 @@ class CreateContainerExpirationPolicies < ActiveRecord::Migration[5.2]
add_index :container_expiration_policies, [:next_run_at, :enabled], add_index :container_expiration_policies, [:next_run_at, :enabled],
name: 'index_container_expiration_policies_on_next_run_at_and_enabled' name: 'index_container_expiration_policies_on_next_run_at_and_enabled'
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -14,12 +14,16 @@ class AddEncryptedFieldsToApplicationSettings < ActiveRecord::Migration[5.2] ...@@ -14,12 +14,16 @@ class AddEncryptedFieldsToApplicationSettings < ActiveRecord::Migration[5.2]
slack_app_verification_token slack_app_verification_token
].freeze ].freeze
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def up def up
PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute| PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute|
add_column :application_settings, "encrypted_#{plaintext_attribute}", :text add_column :application_settings, "encrypted_#{plaintext_attribute}", :text
add_column :application_settings, "encrypted_#{plaintext_attribute}_iv", :string, limit: 255 add_column :application_settings, "encrypted_#{plaintext_attribute}_iv", :string, limit: 255
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
def down def down
PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute| PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute|
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreatePackagesDependencies < ActiveRecord::Migration[5.2] class CreatePackagesDependencies < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :packages_dependencies do |t| create_table :packages_dependencies do |t|
t.string :name, null: false, limit: 255 t.string :name, null: false, limit: 255
...@@ -11,4 +12,5 @@ class CreatePackagesDependencies < ActiveRecord::Migration[5.2] ...@@ -11,4 +12,5 @@ class CreatePackagesDependencies < ActiveRecord::Migration[5.2]
add_index :packages_dependencies, [:name, :version_pattern], unique: true add_index :packages_dependencies, [:name, :version_pattern], unique: true
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddTargetPathToBroadcastMessage < ActiveRecord::Migration[5.2] class AddTargetPathToBroadcastMessage < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :broadcast_messages, :target_path, :string, limit: 255 add_column :broadcast_messages, :target_path, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateImportFailures < ActiveRecord::Migration[5.2] class CreateImportFailures < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :import_failures do |t| create_table :import_failures do |t|
t.integer :relation_index t.integer :relation_index
...@@ -14,4 +15,5 @@ class CreateImportFailures < ActiveRecord::Migration[5.2] ...@@ -14,4 +15,5 @@ class CreateImportFailures < ActiveRecord::Migration[5.2]
t.string :exception_message, limit: 255 t.string :exception_message, limit: 255
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateServerlessDomainCluster < ActiveRecord::Migration[5.2] class CreateServerlessDomainCluster < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :serverless_domain_cluster, id: false, primary_key: :uuid do |t| create_table :serverless_domain_cluster, id: false, primary_key: :uuid do |t|
t.references :pages_domain, null: false, foreign_key: { on_delete: :cascade } t.references :pages_domain, null: false, foreign_key: { on_delete: :cascade }
...@@ -14,4 +15,5 @@ class CreateServerlessDomainCluster < ActiveRecord::Migration[5.2] ...@@ -14,4 +15,5 @@ class CreateServerlessDomainCluster < ActiveRecord::Migration[5.2]
t.string :uuid, null: false, limit: 14, primary_key: true t.string :uuid, null: false, limit: 14, primary_key: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,7 +7,7 @@ class AddCiResourceGroups < ActiveRecord::Migration[5.2] ...@@ -7,7 +7,7 @@ class AddCiResourceGroups < ActiveRecord::Migration[5.2]
create_table :ci_resource_groups do |t| create_table :ci_resource_groups do |t|
t.timestamps_with_timezone t.timestamps_with_timezone
t.bigint :project_id, null: false t.bigint :project_id, null: false
t.string :key, null: false, limit: 255 t.string :key, null: false, limit: 255 # rubocop:disable Migration/PreventStrings
t.index %i[project_id key], unique: true t.index %i[project_id key], unique: true
end end
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class AddEnvironmentAutoStopInToCiBuildsMetadata < ActiveRecord::Migration[5.2] class AddEnvironmentAutoStopInToCiBuildsMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :ci_builds_metadata, :environment_auto_stop_in, :string, limit: 255 add_column :ci_builds_metadata, :environment_auto_stop_in, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :ci_builds_metadata, :environment_auto_stop_in remove_column :ci_builds_metadata, :environment_auto_stop_in
......
...@@ -5,8 +5,10 @@ class AddDesignDiskPathToGeoHashedStorageMigratedEvents < ActiveRecord::Migratio ...@@ -5,8 +5,10 @@ class AddDesignDiskPathToGeoHashedStorageMigratedEvents < ActiveRecord::Migratio
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :geo_hashed_storage_migrated_events, :old_design_disk_path, :text add_column :geo_hashed_storage_migrated_events, :old_design_disk_path, :text
add_column :geo_hashed_storage_migrated_events, :new_design_disk_path, :text add_column :geo_hashed_storage_migrated_events, :new_design_disk_path, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddImageToDesignManagementDesignsVersions < ActiveRecord::Migration[6.0] class AddImageToDesignManagementDesignsVersions < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :design_management_designs_versions, :image_v432x230, :string, limit: 255 add_column :design_management_designs_versions, :image_v432x230, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
class AddSuggestionCommitMessageToProjects < ActiveRecord::Migration[5.2] class AddSuggestionCommitMessageToProjects < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumnsToWideTables
# rubocop:disable Migration/PreventStrings
def change def change
add_column :projects, :suggestion_commit_message, :string, limit: 255 # rubocop:disable Migration/AddColumnsToWideTables add_column :projects, :suggestion_commit_message, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumnsToWideTables
end end
...@@ -12,6 +12,7 @@ class ChangeCommitUserMentionsCommitIdColumnType < ActiveRecord::Migration[5.2] ...@@ -12,6 +12,7 @@ class ChangeCommitUserMentionsCommitIdColumnType < ActiveRecord::Migration[5.2]
NEW_TMP_INDEX = 'temp_commit_id_for_type_change_and_note_id_index' NEW_TMP_INDEX = 'temp_commit_id_for_type_change_and_note_id_index'
NEW_INDEX = 'commit_id_and_note_id_index' NEW_INDEX = 'commit_id_and_note_id_index'
# rubocop:disable Migration/PreventStrings
def up def up
# the initial index name is too long and fails during migration. Renaming the index first. # the initial index name is too long and fails during migration. Renaming the index first.
add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], name: OLD_TMP_INDEX add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], name: OLD_TMP_INDEX
...@@ -29,6 +30,7 @@ class ChangeCommitUserMentionsCommitIdColumnType < ActiveRecord::Migration[5.2] ...@@ -29,6 +30,7 @@ class ChangeCommitUserMentionsCommitIdColumnType < ActiveRecord::Migration[5.2]
add_concurrent_index :commit_user_mentions, [:commit_id_for_type_change, :note_id], name: NEW_INDEX add_concurrent_index :commit_user_mentions, [:commit_id_for_type_change, :note_id], name: NEW_INDEX
remove_concurrent_index_by_name :commit_user_mentions, NEW_TMP_INDEX remove_concurrent_index_by_name :commit_user_mentions, NEW_TMP_INDEX
end end
# rubocop:enable Migration/PreventStrings
def down def down
cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddServiceDeskUsername < ActiveRecord::Migration[5.2] class AddServiceDeskUsername < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :service_desk_settings, :outgoing_name, :string, limit: 255 add_column :service_desk_settings, :outgoing_name, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -8,7 +8,7 @@ class CreateCiPipelinesConfig < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class CreateCiPipelinesConfig < ActiveRecord::Migration[5.2]
t.references :pipeline, t.references :pipeline,
primary_key: true, primary_key: true,
foreign_key: { to_table: :ci_pipelines, on_delete: :cascade } foreign_key: { to_table: :ci_pipelines, on_delete: :cascade }
t.text :content, null: false t.text :content, null: false # rubocop:disable Migration/AddLimitToTextColumns
end end
end end
end end
...@@ -7,6 +7,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2] ...@@ -7,6 +7,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/PreventStrings
def up def up
add_column_with_default( add_column_with_default(
:snippets, :snippets,
...@@ -17,6 +18,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2] ...@@ -17,6 +18,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2]
allow_null: false allow_null: false
) )
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column(:snippets, :repository_storage) remove_column(:snippets, :repository_storage)
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class AddExpandedEnvironmentNameToCiBuildMetadata < ActiveRecord::Migration[5.2] class AddExpandedEnvironmentNameToCiBuildMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
add_column :ci_builds_metadata, :expanded_environment_name, :string, limit: 255 add_column :ci_builds_metadata, :expanded_environment_name, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column :ci_builds_metadata, :expanded_environment_name remove_column :ci_builds_metadata, :expanded_environment_name
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateGeoEvents < ActiveRecord::Migration[5.2] class CreateGeoEvents < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :geo_events do |t| create_table :geo_events do |t|
t.string :replicable_name, limit: 255, null: false t.string :replicable_name, limit: 255, null: false
...@@ -11,4 +12,5 @@ class CreateGeoEvents < ActiveRecord::Migration[5.2] ...@@ -11,4 +12,5 @@ class CreateGeoEvents < ActiveRecord::Migration[5.2]
t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :created_at, null: false
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddSourceToImportFailures < ActiveRecord::Migration[5.2] class AddSourceToImportFailures < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :import_failures, :source, :string, limit: 128 add_column :import_failures, :source, :string, limit: 128
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2] class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
create_table :resource_milestone_events, id: :bigserial do |t| create_table :resource_milestone_events, id: :bigserial do |t|
t.references :user, null: false, foreign_key: { on_delete: :nullify }, t.references :user, null: false, foreign_key: { on_delete: :nullify },
...@@ -22,4 +23,5 @@ class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2] ...@@ -22,4 +23,5 @@ class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2]
t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :created_at, null: false
end end
end end
# rubocop:enable Migration/AddLimitToTextColumns
end end
...@@ -5,9 +5,13 @@ class AddCertAndKeyToServerlessDomainCluster < ActiveRecord::Migration[5.2] ...@@ -5,9 +5,13 @@ class AddCertAndKeyToServerlessDomainCluster < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change def change
add_column :serverless_domain_cluster, :encrypted_key, :text add_column :serverless_domain_cluster, :encrypted_key, :text
add_column :serverless_domain_cluster, :encrypted_key_iv, :string, limit: 255 add_column :serverless_domain_cluster, :encrypted_key_iv, :string, limit: 255
add_column :serverless_domain_cluster, :certificate, :text add_column :serverless_domain_cluster, :certificate, :text
end end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
class AddServiceDeskProjectKey < ActiveRecord::Migration[5.2] class AddServiceDeskProjectKey < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :service_desk_settings, :project_key, :string, limit: 255 add_column :service_desk_settings, :project_key, :string, limit: 255
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateDailyReportResults < ActiveRecord::Migration[6.0] class CreateDailyReportResults < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :ci_daily_report_results do |t| create_table :ci_daily_report_results do |t|
t.date :date, null: false t.date :date, null: false
...@@ -10,8 +11,8 @@ class CreateDailyReportResults < ActiveRecord::Migration[6.0] ...@@ -10,8 +11,8 @@ class CreateDailyReportResults < ActiveRecord::Migration[6.0]
t.bigint :last_pipeline_id, null: false t.bigint :last_pipeline_id, null: false
t.float :value, null: false t.float :value, null: false
t.integer :param_type, limit: 8, null: false t.integer :param_type, limit: 8, null: false
t.string :ref_path, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :ref_path, null: false
t.string :title, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :title, null: false
t.index :last_pipeline_id t.index :last_pipeline_id
t.index [:project_id, :ref_path, :param_type, :date, :title], name: 'index_daily_report_results_unique_columns', unique: true t.index [:project_id, :ref_path, :param_type, :date, :title], name: 'index_daily_report_results_unique_columns', unique: true
...@@ -19,4 +20,5 @@ class CreateDailyReportResults < ActiveRecord::Migration[6.0] ...@@ -19,4 +20,5 @@ class CreateDailyReportResults < ActiveRecord::Migration[6.0]
t.foreign_key :ci_pipelines, column: :last_pipeline_id, on_delete: :cascade t.foreign_key :ci_pipelines, column: :last_pipeline_id, on_delete: :cascade
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0] class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :snippet_repositories, id: false, primary_key: :snippet_id do |t| create_table :snippet_repositories, id: false, primary_key: :snippet_id do |t|
t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
...@@ -10,4 +11,5 @@ class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0] ...@@ -10,4 +11,5 @@ class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0]
t.string :disk_path, limit: 80, null: false, index: { unique: true } t.string :disk_path, limit: 80, null: false, index: { unique: true }
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateDeploymentClusters < ActiveRecord::Migration[6.0] class CreateDeploymentClusters < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :deployment_clusters, id: false, force: :cascade do |t| create_table :deployment_clusters, id: false, force: :cascade do |t|
t.references :deployment, foreign_key: { on_delete: :cascade }, primary_key: true, type: :integer, index: false, default: nil t.references :deployment, foreign_key: { on_delete: :cascade }, primary_key: true, type: :integer, index: false, default: nil
...@@ -13,4 +14,5 @@ class CreateDeploymentClusters < ActiveRecord::Migration[6.0] ...@@ -13,4 +14,5 @@ class CreateDeploymentClusters < ActiveRecord::Migration[6.0]
t.index [:cluster_id, :deployment_id], unique: true t.index [:cluster_id, :deployment_id], unique: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0] class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :operations_strategies do |t| create_table :operations_strategies do |t|
t.references :feature_flag, index: true, null: false, foreign_key: { to_table: :operations_feature_flags, on_delete: :cascade } t.references :feature_flag, index: true, null: false, foreign_key: { to_table: :operations_feature_flags, on_delete: :cascade }
...@@ -10,4 +11,5 @@ class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0] ...@@ -10,4 +11,5 @@ class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0]
t.jsonb :parameters, null: false, default: {} t.jsonb :parameters, null: false, default: {}
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateOperationsScopesTable < ActiveRecord::Migration[6.0] class CreateOperationsScopesTable < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :operations_scopes do |t| create_table :operations_scopes do |t|
t.references :strategy, null: false, index: false, foreign_key: { to_table: :operations_strategies, on_delete: :cascade } t.references :strategy, null: false, index: false, foreign_key: { to_table: :operations_strategies, on_delete: :cascade }
...@@ -11,4 +12,5 @@ class CreateOperationsScopesTable < ActiveRecord::Migration[6.0] ...@@ -11,4 +12,5 @@ class CreateOperationsScopesTable < ActiveRecord::Migration[6.0]
add_index :operations_scopes, [:strategy_id, :environment_scope], unique: true add_index :operations_scopes, [:strategy_id, :environment_scope], unique: true
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
class AddEmailRestrictionsToApplicationSettings < ActiveRecord::Migration[6.0] class AddEmailRestrictionsToApplicationSettings < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def up def up
add_column(:application_settings, :email_restrictions_enabled, :boolean, default: false, null: false) add_column(:application_settings, :email_restrictions_enabled, :boolean, default: false, null: false)
add_column(:application_settings, :email_restrictions, :text, null: true) add_column(:application_settings, :email_restrictions, :text, null: true)
end end
# rubocop:enable Migration/AddLimitToTextColumns
def down def down
remove_column(:application_settings, :email_restrictions_enabled) remove_column(:application_settings, :email_restrictions_enabled)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddVerificationColumnsToPackages < ActiveRecord::Migration[6.0] class AddVerificationColumnsToPackages < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :packages_package_files, :verification_retry_at, :datetime_with_timezone add_column :packages_package_files, :verification_retry_at, :datetime_with_timezone
add_column :packages_package_files, :verified_at, :datetime_with_timezone add_column :packages_package_files, :verified_at, :datetime_with_timezone
...@@ -10,4 +11,5 @@ class AddVerificationColumnsToPackages < ActiveRecord::Migration[6.0] ...@@ -10,4 +11,5 @@ class AddVerificationColumnsToPackages < ActiveRecord::Migration[6.0]
add_column :packages_package_files, :verification_failure, :string, limit: 255 add_column :packages_package_files, :verification_failure, :string, limit: 255
add_column :packages_package_files, :verification_retry_count, :integer add_column :packages_package_files, :verification_retry_count, :integer
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -10,7 +10,7 @@ class AddCanonicalEmails < ActiveRecord::Migration[6.0] ...@@ -10,7 +10,7 @@ class AddCanonicalEmails < ActiveRecord::Migration[6.0]
create_table :user_canonical_emails do |t| create_table :user_canonical_emails do |t|
t.timestamps_with_timezone t.timestamps_with_timezone
t.references :user, index: false, null: false, foreign_key: { on_delete: :cascade } t.references :user, index: false, null: false, foreign_key: { on_delete: :cascade }
t.string :canonical_email, null: false, index: true # rubocop:disable Migration/AddLimitToStringColumns t.string :canonical_email, null: false, index: true # rubocop:disable Migration/PreventStrings
end end
end end
......
...@@ -3,6 +3,6 @@ class AddFilepathToReleaseLinks < ActiveRecord::Migration[6.0] ...@@ -3,6 +3,6 @@ class AddFilepathToReleaseLinks < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :release_links, :filepath, :string, limit: 128 add_column :release_links, :filepath, :string, limit: 128 # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -4,6 +4,6 @@ class AddLimitMetricTypeToList < ActiveRecord::Migration[6.0] ...@@ -4,6 +4,6 @@ class AddLimitMetricTypeToList < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
def change def change
add_column :lists, :limit_metric, :string, limit: 20 add_column :lists, :limit_metric, :string, limit: 20 # rubocop:disable Migration/PreventStrings
end end
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddStatusPageSettings < ActiveRecord::Migration[6.0] class AddStatusPageSettings < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :status_page_settings, id: false do |t| create_table :status_page_settings, id: false do |t|
t.references :project, index: true, primary_key: true, foreign_key: { on_delete: :cascade }, unique: true, null: false t.references :project, index: true, primary_key: true, foreign_key: { on_delete: :cascade }, unique: true, null: false
...@@ -15,4 +16,5 @@ class AddStatusPageSettings < ActiveRecord::Migration[6.0] ...@@ -15,4 +16,5 @@ class AddStatusPageSettings < ActiveRecord::Migration[6.0]
t.string :encrypted_aws_secret_key_iv, limit: 255, null: false t.string :encrypted_aws_secret_key_iv, limit: 255, null: false
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0] ...@@ -5,6 +5,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :requirements do |t| create_table :requirements do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -14,7 +15,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0] ...@@ -14,7 +15,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
t.integer :cached_markdown_version t.integer :cached_markdown_version
t.integer :state, limit: 2, default: 1, null: false t.integer :state, limit: 2, default: 1, null: false
t.string :title, limit: 255, null: false t.string :title, limit: 255, null: false
t.text :title_html t.text :title_html # rubocop:disable Migration/AddLimitToTextColumns
t.index :project_id t.index :project_id
t.index :author_id t.index :author_id
...@@ -25,4 +26,5 @@ class CreateRequirements < ActiveRecord::Migration[6.0] ...@@ -25,4 +26,5 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
t.index %w(project_id iid), name: 'index_requirements_on_project_id_and_iid', where: 'project_id IS NOT NULL', unique: true, using: :btree t.index %w(project_id iid), name: 'index_requirements_on_project_id_and_iid', where: 'project_id IS NOT NULL', unique: true, using: :btree
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateScimIdentities < ActiveRecord::Migration[6.0] class CreateScimIdentities < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :scim_identities do |t| create_table :scim_identities do |t|
t.references :group, foreign_key: { to_table: :namespaces, on_delete: :cascade }, null: false t.references :group, foreign_key: { to_table: :namespaces, on_delete: :cascade }, null: false
...@@ -15,4 +16,5 @@ class CreateScimIdentities < ActiveRecord::Migration[6.0] ...@@ -15,4 +16,5 @@ class CreateScimIdentities < ActiveRecord::Migration[6.0]
t.index [:user_id, :group_id], unique: true t.index [:user_id, :group_id], unique: true
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreateUserDetails < ActiveRecord::Migration[6.0] ...@@ -5,6 +5,7 @@ class CreateUserDetails < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
with_lock_retries do with_lock_retries do
create_table :user_details, id: false do |t| create_table :user_details, id: false do |t|
...@@ -15,6 +16,7 @@ class CreateUserDetails < ActiveRecord::Migration[6.0] ...@@ -15,6 +16,7 @@ class CreateUserDetails < ActiveRecord::Migration[6.0]
add_index :user_details, :user_id, unique: true add_index :user_details, :user_id, unique: true
end end
# rubocop:enable Migration/PreventStrings
def down def down
with_lock_retries do with_lock_retries do
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddWikiSlug < ActiveRecord::Migration[6.0] class AddWikiSlug < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :wiki_page_meta, id: :serial do |t| create_table :wiki_page_meta, id: :serial do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
...@@ -19,4 +20,5 @@ class AddWikiSlug < ActiveRecord::Migration[6.0] ...@@ -19,4 +20,5 @@ class AddWikiSlug < ActiveRecord::Migration[6.0]
t.index [:wiki_page_meta_id], name: 'one_canonical_wiki_page_slug_per_metadata', unique: true, where: "(canonical = true)" t.index [:wiki_page_meta_id], name: 'one_canonical_wiki_page_slug_per_metadata', unique: true, where: "(canonical = true)"
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateTerraformStates < ActiveRecord::Migration[6.0] class CreateTerraformStates < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :terraform_states do |t| create_table :terraform_states do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
...@@ -11,4 +12,5 @@ class CreateTerraformStates < ActiveRecord::Migration[6.0] ...@@ -11,4 +12,5 @@ class CreateTerraformStates < ActiveRecord::Migration[6.0]
t.string :file, limit: 255 t.string :file, limit: 255
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
class AddOpenProjectTrackerData < ActiveRecord::Migration[6.0] class AddOpenProjectTrackerData < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :open_project_tracker_data do |t| create_table :open_project_tracker_data do |t|
t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
...@@ -20,4 +21,5 @@ class AddOpenProjectTrackerData < ActiveRecord::Migration[6.0] ...@@ -20,4 +21,5 @@ class AddOpenProjectTrackerData < ActiveRecord::Migration[6.0]
t.string :project_identifier_code, limit: 100 t.string :project_identifier_code, limit: 100
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,7 @@ class CreateVulnerabilityExports < ActiveRecord::Migration[6.0] ...@@ -5,6 +5,7 @@ class CreateVulnerabilityExports < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :vulnerability_exports do |t| create_table :vulnerability_exports do |t|
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
...@@ -21,4 +22,5 @@ class CreateVulnerabilityExports < ActiveRecord::Migration[6.0] ...@@ -21,4 +22,5 @@ class CreateVulnerabilityExports < ActiveRecord::Migration[6.0]
t.index %i[author_id] t.index %i[author_id]
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateProjectExportJobs < ActiveRecord::Migration[6.0] class CreateProjectExportJobs < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :project_export_jobs do |t| create_table :project_export_jobs do |t|
t.references :project, index: false, null: false, foreign_key: { on_delete: :cascade } t.references :project, index: false, null: false, foreign_key: { on_delete: :cascade }
...@@ -16,4 +17,5 @@ class CreateProjectExportJobs < ActiveRecord::Migration[6.0] ...@@ -16,4 +17,5 @@ class CreateProjectExportJobs < ActiveRecord::Migration[6.0]
t.index [:project_id, :status] t.index [:project_id, :status]
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,7 +7,7 @@ class AddExternalKeyToIssuesTable < ActiveRecord::Migration[6.0] ...@@ -7,7 +7,7 @@ class AddExternalKeyToIssuesTable < ActiveRecord::Migration[6.0]
def up def up
with_lock_retries do with_lock_retries do
add_column :issues, :external_key, :string, limit: 255 add_column :issues, :external_key, :string, limit: 255 # rubocop:disable Migration/PreventStrings
end end
end end
......
...@@ -7,7 +7,7 @@ class AddExternalKeyToEpicsTable < ActiveRecord::Migration[6.0] ...@@ -7,7 +7,7 @@ class AddExternalKeyToEpicsTable < ActiveRecord::Migration[6.0]
def up def up
with_lock_retries do with_lock_retries do
add_column :epics, :external_key, :string, limit: 255 add_column :epics, :external_key, :string, limit: 255 # rubocop:disable Migration/PreventStrings
end end
end end
......
...@@ -8,7 +8,7 @@ class CreatePypiPackageMetadata < ActiveRecord::Migration[6.0] ...@@ -8,7 +8,7 @@ class CreatePypiPackageMetadata < ActiveRecord::Migration[6.0]
def change def change
create_table :packages_pypi_metadata, id: false do |t| create_table :packages_pypi_metadata, id: false do |t|
t.references :package, primary_key: true, index: false, default: nil, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint t.references :package, primary_key: true, index: false, default: nil, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
t.string "required_python", null: false, limit: 50 t.string "required_python", null: false, limit: 50 # rubocop:disable Migration/PreventStrings
end end
end end
end end
...@@ -7,6 +7,7 @@ class CreateMetricsDashboardAnnotations < ActiveRecord::Migration[6.0] ...@@ -7,6 +7,7 @@ class CreateMetricsDashboardAnnotations < ActiveRecord::Migration[6.0]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :metrics_dashboard_annotations do |t| create_table :metrics_dashboard_annotations do |t|
t.datetime_with_timezone :starting_at, null: false t.datetime_with_timezone :starting_at, null: false
...@@ -15,10 +16,11 @@ class CreateMetricsDashboardAnnotations < ActiveRecord::Migration[6.0] ...@@ -15,10 +16,11 @@ class CreateMetricsDashboardAnnotations < ActiveRecord::Migration[6.0]
t.references :cluster, index: false, foreign_key: { on_delete: :cascade }, null: true t.references :cluster, index: false, foreign_key: { on_delete: :cascade }, null: true
t.string :dashboard_path, null: false, limit: 255 t.string :dashboard_path, null: false, limit: 255
t.string :panel_xid, limit: 255 t.string :panel_xid, limit: 255
t.text :description, null: false, limit: 255 t.text :description, null: false, limit: 255 # rubocop:disable Migration/AddLimitToTextColumns
t.index %i(environment_id dashboard_path starting_at ending_at), where: 'environment_id IS NOT NULL', name: "index_metrics_dashboard_annotations_on_environment_id_and_3_col" t.index %i(environment_id dashboard_path starting_at ending_at), where: 'environment_id IS NOT NULL', name: "index_metrics_dashboard_annotations_on_environment_id_and_3_col"
t.index %i(cluster_id dashboard_path starting_at ending_at), where: 'cluster_id IS NOT NULL', name: "index_metrics_dashboard_annotations_on_cluster_id_and_3_columns" t.index %i(cluster_id dashboard_path starting_at ending_at), where: 'cluster_id IS NOT NULL', name: "index_metrics_dashboard_annotations_on_cluster_id_and_3_columns"
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -7,9 +7,11 @@ class AddBioToUserDetails < ActiveRecord::Migration[6.0] ...@@ -7,9 +7,11 @@ class AddBioToUserDetails < ActiveRecord::Migration[6.0]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/PreventStrings
def up def up
add_column_with_default(:user_details, :bio, :string, default: '', allow_null: false, limit: 255, update_column_in_batches_args: { batch_column_name: :user_id }) add_column_with_default(:user_details, :bio, :string, default: '', allow_null: false, limit: 255, update_column_in_batches_args: { batch_column_name: :user_id })
end end
# rubocop:enable Migration/PreventStrings
def down def down
remove_column(:user_details, :bio) remove_column(:user_details, :bio)
......
...@@ -7,6 +7,7 @@ class CreateJiraImportsTable < ActiveRecord::Migration[6.0] ...@@ -7,6 +7,7 @@ class CreateJiraImportsTable < ActiveRecord::Migration[6.0]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/PreventStrings
def change def change
create_table :jira_imports do |t| create_table :jira_imports do |t|
t.integer :project_id, null: false, limit: 8 t.integer :project_id, null: false, limit: 8
...@@ -26,4 +27,5 @@ class CreateJiraImportsTable < ActiveRecord::Migration[6.0] ...@@ -26,4 +27,5 @@ class CreateJiraImportsTable < ActiveRecord::Migration[6.0]
add_index :jira_imports, [:project_id, :jira_project_key], name: 'index_jira_imports_on_project_id_and_jira_project_key' add_index :jira_imports, [:project_id, :jira_project_key], name: 'index_jira_imports_on_project_id_and_jira_project_key'
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -5,6 +5,8 @@ class CreateDiffNotePositions < ActiveRecord::Migration[6.0] ...@@ -5,6 +5,8 @@ class CreateDiffNotePositions < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
# rubocop:disable Migration/PreventStrings
def up def up
with_lock_retries do with_lock_retries do
create_table :diff_note_positions do |t| create_table :diff_note_positions do |t|
...@@ -24,6 +26,8 @@ class CreateDiffNotePositions < ActiveRecord::Migration[6.0] ...@@ -24,6 +26,8 @@ class CreateDiffNotePositions < ActiveRecord::Migration[6.0]
end end
end end
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddLimitToTextColumns
def down def down
drop_table :diff_note_positions drop_table :diff_note_positions
......
...@@ -8,8 +8,8 @@ class CreateOperationsUserLists < ActiveRecord::Migration[6.0] ...@@ -8,8 +8,8 @@ class CreateOperationsUserLists < ActiveRecord::Migration[6.0]
t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
t.timestamps_with_timezone t.timestamps_with_timezone
t.integer :iid, null: false t.integer :iid, null: false
t.string :name, null: false, limit: 255 t.string :name, null: false, limit: 255 # rubocop:disable Migration/PreventStrings
t.text :user_xids, null: false, default: '' t.text :user_xids, null: false, default: '' # rubocop:disable Migration/AddLimitToTextColumns
t.index [:project_id, :iid], unique: true t.index [:project_id, :iid], unique: true
t.index [:project_id, :name], unique: true t.index [:project_id, :name], unique: true
......
...@@ -5,11 +5,13 @@ class AddCorrelationIdToProjectImportState < ActiveRecord::Migration[6.0] ...@@ -5,11 +5,13 @@ class AddCorrelationIdToProjectImportState < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up def up
with_lock_retries do with_lock_retries do
add_column :project_mirror_data, :correlation_id_value, :string, limit: 128 add_column :project_mirror_data, :correlation_id_value, :string, limit: 128
end end
end end
# rubocop:enable Migration/PreventStrings
def down def down
with_lock_retries do with_lock_retries do
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class CreateClustersApplicationsFluentd < ActiveRecord::Migration[6.0] class CreateClustersApplicationsFluentd < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
create_table :clusters_applications_fluentd do |t| create_table :clusters_applications_fluentd do |t|
t.integer :protocol, null: false, limit: 2 t.integer :protocol, null: false, limit: 2
...@@ -12,7 +13,8 @@ class CreateClustersApplicationsFluentd < ActiveRecord::Migration[6.0] ...@@ -12,7 +13,8 @@ class CreateClustersApplicationsFluentd < ActiveRecord::Migration[6.0]
t.timestamps_with_timezone null: false t.timestamps_with_timezone null: false
t.string :version, null: false, limit: 255 t.string :version, null: false, limit: 255
t.string :host, null: false, limit: 255 t.string :host, null: false, limit: 255
t.text :status_reason t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns
end end
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
class AddColumnsToTerraformState < ActiveRecord::Migration[6.0] class AddColumnsToTerraformState < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :terraform_states, :lock_xid, :string, limit: 255 add_column :terraform_states, :lock_xid, :string, limit: 255
add_column :terraform_states, :locked_at, :datetime_with_timezone add_column :terraform_states, :locked_at, :datetime_with_timezone
...@@ -14,4 +15,5 @@ class AddColumnsToTerraformState < ActiveRecord::Migration[6.0] ...@@ -14,4 +15,5 @@ class AddColumnsToTerraformState < ActiveRecord::Migration[6.0]
add_index :terraform_states, [:project_id, :name], unique: true # rubocop:disable Migration/AddIndex (table not used yet) add_index :terraform_states, [:project_id, :name], unique: true # rubocop:disable Migration/AddIndex (table not used yet)
remove_index :terraform_states, :project_id # rubocop:disable Migration/RemoveIndex (table not used yet) remove_index :terraform_states, :project_id # rubocop:disable Migration/RemoveIndex (table not used yet)
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -12,6 +12,6 @@ class RemoveKodingFromApplicationSettings < ActiveRecord::Migration[4.2] ...@@ -12,6 +12,6 @@ class RemoveKodingFromApplicationSettings < ActiveRecord::Migration[4.2]
def down def down
add_column :application_settings, :koding_enabled, :boolean # rubocop:disable Migration/SaferBooleanColumn add_column :application_settings, :koding_enabled, :boolean # rubocop:disable Migration/SaferBooleanColumn
add_column :application_settings, :koding_url, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :application_settings, :koding_url, :string
end end
end end
...@@ -16,6 +16,6 @@ class RemoveAlternateUrlFromGeoNodes < ActiveRecord::Migration[5.0] ...@@ -16,6 +16,6 @@ class RemoveAlternateUrlFromGeoNodes < ActiveRecord::Migration[5.0]
end end
def down def down
add_column :geo_nodes, :alternate_url, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :geo_nodes, :alternate_url, :string
end end
end end
...@@ -32,7 +32,7 @@ class RemoveSentryFromApplicationSettings < ActiveRecord::Migration[5.0] ...@@ -32,7 +32,7 @@ class RemoveSentryFromApplicationSettings < ActiveRecord::Migration[5.0]
end end
SENTRY_DSN_COLUMNS.each do |column| SENTRY_DSN_COLUMNS.each do |column|
add_column(:application_settings, column, :string) unless column_exists?(:application_settings, column) # rubocop:disable Migration/AddLimitToStringColumns add_column(:application_settings, column, :string) unless column_exists?(:application_settings, column)
end end
end end
end end
...@@ -14,7 +14,7 @@ class DropOperationsFeatureFlagsClientsToken < ActiveRecord::Migration[5.2] ...@@ -14,7 +14,7 @@ class DropOperationsFeatureFlagsClientsToken < ActiveRecord::Migration[5.2]
def down def down
unless column_exists?(:operations_feature_flags_clients, :token) unless column_exists?(:operations_feature_flags_clients, :token)
add_column :operations_feature_flags_clients, :token, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :operations_feature_flags_clients, :token, :string
end end
add_concurrent_index :operations_feature_flags_clients, [:project_id, :token], unique: true, add_concurrent_index :operations_feature_flags_clients, [:project_id, :token], unique: true,
......
...@@ -18,7 +18,7 @@ class RemoveStateFromIssues < ActiveRecord::Migration[6.0] ...@@ -18,7 +18,7 @@ class RemoveStateFromIssues < ActiveRecord::Migration[6.0]
return if issue_state_column_exists? return if issue_state_column_exists?
with_lock_retries do with_lock_retries do
add_column :issues, :state, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :issues, :state, :string
end end
end end
......
...@@ -18,7 +18,7 @@ class RemoveStateFromMergeRequests < ActiveRecord::Migration[6.0] ...@@ -18,7 +18,7 @@ class RemoveStateFromMergeRequests < ActiveRecord::Migration[6.0]
return if merge_requests_state_column_exists? return if merge_requests_state_column_exists?
with_lock_retries do with_lock_retries do
add_column :merge_requests, :state, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :merge_requests, :state, :string
end end
end end
......
class CreateFileRegistry < ActiveRecord::Migration[4.2] class CreateFileRegistry < ActiveRecord::Migration[4.2]
# rubocop:disable Migration/PreventStrings
def change def change
create_table :file_registry do |t| create_table :file_registry do |t|
t.string :file_type, null: false # rubocop:disable Migration/AddLimitToStringColumns t.string :file_type, null: false
t.integer :file_id, null: false t.integer :file_id, null: false
t.integer :bytes t.integer :bytes
t.string :sha256 # rubocop:disable Migration/AddLimitToStringColumns t.string :sha256
t.datetime :created_at, null: false # rubocop:disable Migration/Datetime t.datetime :created_at, null: false # rubocop:disable Migration/Datetime
end end
...@@ -12,4 +13,5 @@ class CreateFileRegistry < ActiveRecord::Migration[4.2] ...@@ -12,4 +13,5 @@ class CreateFileRegistry < ActiveRecord::Migration[4.2]
add_index :file_registry, :file_type add_index :file_registry, :file_type
add_index :file_registry, [:file_type, :file_id], { unique: true } add_index :file_registry, [:file_type, :file_id], { unique: true }
end end
# rubocop:enable Migration/PreventStrings
end end
class AddLastSyncFailureToProjectRegistry < ActiveRecord::Migration[4.2] class AddLastSyncFailureToProjectRegistry < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change def change
add_column :project_registry, :last_repository_sync_failure, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :last_repository_sync_failure, :string
add_column :project_registry, :last_wiki_sync_failure, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :last_wiki_sync_failure, :string
end end
# rubocop:enable Migration/PreventStrings
end end
...@@ -4,15 +4,19 @@ class AddRepositoryVerificationToProjectRegistry < ActiveRecord::Migration[4.2] ...@@ -4,15 +4,19 @@ class AddRepositoryVerificationToProjectRegistry < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/AddColumn
# rubocop:disable Migration/PreventStrings
def change def change
add_column :project_registry, :repository_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :repository_verification_checksum, :string
add_column :project_registry, :last_repository_verification_at, :datetime_with_timezone add_column :project_registry, :last_repository_verification_at, :datetime_with_timezone
add_column :project_registry, :last_repository_verification_failed, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn add_column :project_registry, :last_repository_verification_failed, :boolean, null: false, default: false
add_column :project_registry, :last_repository_verification_failure, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :last_repository_verification_failure, :string
add_column :project_registry, :wiki_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :wiki_verification_checksum, :string
add_column :project_registry, :last_wiki_verification_at, :datetime_with_timezone add_column :project_registry, :last_wiki_verification_at, :datetime_with_timezone
add_column :project_registry, :last_wiki_verification_failed, :boolean, null: false, default: false # rubocop:disable Migration/AddColumn add_column :project_registry, :last_wiki_verification_failed, :boolean, null: false, default: false
add_column :project_registry, :last_wiki_verification_failure, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :last_wiki_verification_failure, :string
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/AddColumn
end end
...@@ -7,7 +7,7 @@ class MigrateCiJobArtifactsToSeparateRegistry < ActiveRecord::Migration[4.2] ...@@ -7,7 +7,7 @@ class MigrateCiJobArtifactsToSeparateRegistry < ActiveRecord::Migration[4.2]
t.integer "artifact_id", unique: true t.integer "artifact_id", unique: true
t.integer "retry_count" t.integer "retry_count"
t.boolean "success" t.boolean "success"
t.string "sha256" # rubocop:disable Migration/AddLimitToStringColumns t.string "sha256" # rubocop:disable Migration/PreventStrings
end end
Geo::TrackingBase.transaction do Geo::TrackingBase.transaction do
......
...@@ -3,19 +3,23 @@ ...@@ -3,19 +3,23 @@
class AddContainerRepositoryRegistry < ActiveRecord::Migration[5.0] class AddContainerRepositoryRegistry < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/PreventStrings
def change def change
create_table :container_repository_registry, id: :serial, force: :cascade do |t| create_table :container_repository_registry, id: :serial, force: :cascade do |t|
t.integer :container_repository_id, null: false t.integer :container_repository_id, null: false
t.string :state # rubocop:disable Migration/AddLimitToStringColumns t.string :state
t.integer :retry_count, default: 0 t.integer :retry_count, default: 0
t.string :last_sync_failure # rubocop:disable Migration/AddLimitToStringColumns t.string :last_sync_failure
t.datetime :retry_at # rubocop:disable Migration/Datetime t.datetime :retry_at
t.datetime :last_synced_at # rubocop:disable Migration/Datetime t.datetime :last_synced_at
t.datetime :created_at, null: false # rubocop:disable Migration/Datetime t.datetime :created_at, null: false
t.index :container_repository_id, name: :index_container_repository_registry_on_repository_id, using: :btree t.index :container_repository_id, name: :index_container_repository_registry_on_repository_id, using: :btree
t.index :retry_at, name: :index_container_repository_registry_on_retry_at, using: :btree t.index :retry_at, name: :index_container_repository_registry_on_retry_at, using: :btree
t.index :state, name: :index_container_repository_registry_on_state, using: :btree t.index :state, name: :index_container_repository_registry_on_state, using: :btree
end end
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/Datetime
end end
...@@ -8,21 +8,25 @@ class AddDesignRegistry < ActiveRecord::Migration[5.2] ...@@ -8,21 +8,25 @@ class AddDesignRegistry < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
# rubocop:disable Migration/Datetime
# rubocop:disable Migration/PreventStrings
def change def change
create_table :design_registry, id: :serial, force: :cascade do |t| create_table :design_registry, id: :serial, force: :cascade do |t|
t.integer :project_id, null: false t.integer :project_id, null: false
t.string :state, limit: 20 t.string :state, limit: 20
t.integer :retry_count, default: 0 t.integer :retry_count, default: 0
t.string :last_sync_failure # rubocop:disable Migration/AddLimitToStringColumns t.string :last_sync_failure
t.boolean :force_to_redownload t.boolean :force_to_redownload
t.boolean :missing_on_primary t.boolean :missing_on_primary
t.datetime :retry_at # rubocop:disable Migration/Datetime t.datetime :retry_at
t.datetime :last_synced_at # rubocop:disable Migration/Datetime t.datetime :last_synced_at
t.datetime :created_at, null: false # rubocop:disable Migration/Datetime t.datetime :created_at, null: false
t.index :project_id, name: :index_design_registry_on_project_id, using: :btree t.index :project_id, name: :index_design_registry_on_project_id, using: :btree
t.index :retry_at, name: :index_design_registry_on_retry_at, using: :btree t.index :retry_at, name: :index_design_registry_on_retry_at, using: :btree
t.index :state, name: :index_design_registry_on_state, using: :btree t.index :state, name: :index_design_registry_on_state, using: :btree
end end
end end
# rubocop:enable Migration/PreventStrings
# rubocop:enable Migration/Datetime
end end
...@@ -8,7 +8,7 @@ class CreatePackageFileRegistry < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class CreatePackageFileRegistry < ActiveRecord::Migration[5.2]
t.integer :package_file_id, null: false t.integer :package_file_id, null: false
t.integer :state, default: 0, null: false t.integer :state, default: 0, null: false
t.integer :retry_count, default: 0 t.integer :retry_count, default: 0
t.string :last_sync_failure, limit: 255 t.string :last_sync_failure, limit: 255 # rubocop:disable Migration/PreventStrings
t.datetime_with_timezone :retry_at t.datetime_with_timezone :retry_at
t.datetime_with_timezone :last_synced_at t.datetime_with_timezone :last_synced_at
t.datetime_with_timezone :created_at, null: false t.datetime_with_timezone :created_at, null: false
......
...@@ -7,7 +7,7 @@ class RemoveOldRepositoryVerificationChecksumFromGeoProjectRegistry < ActiveReco ...@@ -7,7 +7,7 @@ class RemoveOldRepositoryVerificationChecksumFromGeoProjectRegistry < ActiveReco
end end
def down def down
add_column :project_registry, :repository_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :repository_verification_checksum, :string
add_column :project_registry, :wiki_verification_checksum, :string # rubocop:disable Migration/AddLimitToStringColumns add_column :project_registry, :wiki_verification_checksum, :string
end end
end end
# frozen_string_literal: true
require_relative '../../migration_helpers'
module RuboCop
module Cop
module Migration
# Cop that enforces always adding a limit on text columns
class AddLimitToTextColumns < RuboCop::Cop::Cop
include MigrationHelpers
MSG = 'Text columns should always have a limit set (255 is suggested). ' \
'You can add a limit to a `text` column by using `add_text_limit`'.freeze
def_node_matcher :reverting?, <<~PATTERN
(def :down ...)
PATTERN
def_node_matcher :add_text_limit?, <<~PATTERN
(send _ :add_text_limit ...)
PATTERN
def on_def(node)
return unless in_migration?(node)
# Don't enforce the rule when on down to keep consistency with existing schema
return if reverting?(node)
node.each_descendant(:send) do |send_node|
next unless text_operation?(send_node)
# We require a limit for the same table and attribute name
if text_limit_missing?(node, *table_and_attribute_name(send_node))
add_offense(send_node, location: :selector)
end
end
end
private
def text_operation?(node)
modifier = node.children[0]
migration_method = node.children[1]
if migration_method == :text
modifier.type == :lvar
elsif ADD_COLUMN_METHODS.include?(migration_method)
modifier.nil? && text_column?(node.children[4])
end
end
def text_column?(column_type)
column_type.type == :sym && column_type.value == :text
end
# For a given node, find the table and attribute this node is for
#
# Simple when we have calls to `add_column_XXX` helper methods
#
# A little bit more tricky when we have attributes defined as part of
# a create/change table block:
# - The attribute name is available on the node
# - Finding the table name requires to:
# * go up
# * find the first block the attribute def is part of
# * go back down to find the create_table node
# * fetch the table name from that node
def table_and_attribute_name(node)
migration_method = node.children[1]
table_name, attribute_name = ''
if migration_method == :text
# We are inside a node in a create/change table block
block_node = node.each_ancestor(:block).first
create_table_node = block_node
.children
.find { |n| TABLE_METHODS.include?(n.children[1])}
if create_table_node
table_name = create_table_node.children[2].value
else
# Guard against errors when a new table create/change migration
# helper is introduced and warn the author so that it can be
# added in TABLE_METHODS
table_name = 'unknown'
add_offense(block_node, message: 'Unknown table create/change helper')
end
attribute_name = node.children[2].value
else
# We are in a node for one of the ADD_COLUMN_METHODS
table_name = node.children[2].value
attribute_name = node.children[3].value
end
[table_name, attribute_name]
end
# Check if there is an `add_text_limit` call for the provided
# table and attribute name
def text_limit_missing?(node, table_name, attribute_name)
limit_found = false
node.each_descendant(:send) do |send_node|
next unless add_text_limit?(send_node)
limit_table = send_node.children[2].value
limit_attribute = send_node.children[3].value
if limit_table == table_name && limit_attribute == attribute_name
limit_found = true
break
end
end
!limit_found
end
end
end
end
end
...@@ -5,21 +5,28 @@ require_relative '../../migration_helpers' ...@@ -5,21 +5,28 @@ require_relative '../../migration_helpers'
module RuboCop module RuboCop
module Cop module Cop
module Migration module Migration
# Cop that enforces length constraints to string columns # Cop that enforces using text instead of the string data type
class AddLimitToStringColumns < RuboCop::Cop::Cop class PreventStrings < RuboCop::Cop::Cop
include MigrationHelpers include MigrationHelpers
ADD_COLUMNS_METHODS = %i(add_column add_column_with_default).freeze MSG = 'Do not use the `string` data type, use `text` instead. ' \
'Updating limits on strings requires downtime. This can be avoided ' \
'by using `text` and adding a limit with `add_text_limit`'.freeze
MSG = 'String columns should have a limit constraint. 255 is suggested'.freeze def_node_matcher :reverting?, <<~PATTERN
(def :down ...)
PATTERN
def on_def(node) def on_def(node)
return unless in_migration?(node) return unless in_migration?(node)
# Don't enforce the rule when on down to keep consistency with existing schema
return if reverting?(node)
node.each_descendant(:send) do |send_node| node.each_descendant(:send) do |send_node|
next unless string_operation?(send_node) next unless string_operation?(send_node)
add_offense(send_node, location: :selector) unless limit_on_string_column?(send_node) add_offense(send_node, location: :selector)
end end
end end
...@@ -31,7 +38,7 @@ module RuboCop ...@@ -31,7 +38,7 @@ module RuboCop
if migration_method == :string if migration_method == :string
modifier.type == :lvar modifier.type == :lvar
elsif ADD_COLUMNS_METHODS.include?(migration_method) elsif ADD_COLUMN_METHODS.include?(migration_method)
modifier.nil? && string_column?(node.children[4]) modifier.nil? && string_column?(node.children[4])
end end
end end
...@@ -39,20 +46,6 @@ module RuboCop ...@@ -39,20 +46,6 @@ module RuboCop
def string_column?(column_type) def string_column?(column_type)
column_type.type == :sym && column_type.value == :string column_type.type == :sym && column_type.value == :string
end end
def limit_on_string_column?(node)
migration_method = node.children[1]
if migration_method == :string
limit_present?(node.children)
elsif ADD_COLUMNS_METHODS.include?(migration_method)
limit_present?(node)
end
end
def limit_present?(statement)
!(statement.to_s =~ /:limit/).nil?
end
end end
end end
end end
......
...@@ -54,6 +54,12 @@ module RuboCop ...@@ -54,6 +54,12 @@ module RuboCop
ci_builds ci_builds
].freeze ].freeze
# List of helpers that add new columns, either directly (ADD_COLUMN_METHODS)
# or through a create/alter table (TABLE_METHODS)
ADD_COLUMN_METHODS = %i(add_column add_column_with_default change_column_type_concurrently).freeze
TABLE_METHODS = %i(create_table create_table_if_not_exists change_table).freeze
# Returns true if the given node originated from the db/migrate directory. # Returns true if the given node originated from the db/migrate directory.
def in_migration?(node) def in_migration?(node)
dirname(node).end_with?('db/migrate', 'db/geo/migrate') || in_post_deployment_migration?(node) dirname(node).end_with?('db/migrate', 'db/geo/migrate') || in_post_deployment_migration?(node)
......
# frozen_string_literal: true
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/migration/add_limit_to_string_columns'
describe RuboCop::Cop::Migration::AddLimitToStringColumns do
include CopHelper
subject(:cop) { described_class.new }
context 'in migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
inspect_source(migration)
end
context 'when creating a table' do
context 'with string columns and limit' do
let(:migration) do
%q(
class CreateUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :users do |t|
t.string :username, null: false, limit: 255
t.timestamps_with_timezone null: true
end
end
end
)
end
it 'register no offense' do
expect(cop.offenses.size).to eq(0)
end
context 'with limit in a different position' do
let(:migration) do
%q(
class CreateUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :users do |t|
t.string :username, limit: 255, null: false
t.timestamps_with_timezone null: true
end
end
end
)
end
it 'registers an offense' do
expect(cop.offenses.size).to eq(0)
end
end
end
context 'with string columns and no limit' do
let(:migration) do
%q(
class CreateUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :users do |t|
t.string :username, null: false
t.timestamps_with_timezone null: true
end
end
end
)
end
it 'registers an offense' do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.first.message)
.to eq('String columns should have a limit constraint. 255 is suggested')
end
end
context 'with no string columns' do
let(:migration) do
%q(
class CreateMilestoneReleases < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :milestone_releases do |t|
t.integer :milestone_id
t.integer :release_id
end
end
end
)
end
it 'register no offense' do
expect(cop.offenses.size).to eq(0)
end
end
end
context 'when adding columns' do
context 'with string columns with limit' do
let(:migration) do
%q(
class AddEmailToUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :users, :email, :string, limit: 255
end
end
)
end
it 'registers no offense' do
expect(cop.offenses.size).to eq(0)
end
context 'with limit in a different position' do
let(:migration) do
%q(
class AddEmailToUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :users, :email, :string, limit: 255, default: 'example@email.com'
end
end
)
end
it 'registers no offense' do
expect(cop.offenses.size).to eq(0)
end
end
end
context 'with string columns with no limit' do
let(:migration) do
%q(
class AddEmailToUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :users, :email, :string
end
end
)
end
it 'registers offense' do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.first.message)
.to eq('String columns should have a limit constraint. 255 is suggested')
end
end
context 'with no string columns' do
let(:migration) do
%q(
class AddEmailToUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :users, :active, :boolean, default: false
end
end
)
end
it 'registers no offense' do
expect(cop.offenses.size).to eq(0)
end
end
end
context 'with add_column_with_default' do
context 'with a limit' do
let(:migration) do
%q(
class AddRuleTypeToApprovalMergeRequestRules < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column_with_default(:approval_merge_request_rules, :rule_type, :string, limit: 2, default: 1)
end
end
)
end
it 'registers no offense' do
expect(cop.offenses.size).to eq(0)
end
end
context 'without a limit' do
let(:migration) do
%q(
class AddRuleTypeToApprovalMergeRequestRules < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column_with_default(:approval_merge_request_rules, :rule_type, :string, default: 1)
end
end
)
end
it 'registers an offense' do
expect(cop.offenses.size).to eq(1)
end
end
end
context 'with methods' do
let(:migration) do
%q(
class AddEmailToUsers < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column_if_table_not_exists :users, :first_name, :string, limit: 255
search_namespace(user_name)
end
def add_column_if_not_exists(table, name, *args)
add_column(table, name, *args) unless column_exists?(table, name)
end
def search_namespace(username)
Uniquify.new.string(username) do |str|
query = "SELECT id FROM namespaces WHERE parent_id IS NULL AND path='#{str}' LIMIT 1"
connection.exec_query(query)
end
end
end
)
end
it 'registers no offense' do
expect(cop.offenses.size).to eq(0)
end
end
end
context 'outside of migrations' do
let(:active_record_model) do
%q(
class User < ApplicationRecord
end
)
end
it 'registers no offense' do
inspect_source(active_record_model)
expect(cop.offenses.size).to eq(0)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/migration/add_limit_to_text_columns'
describe RuboCop::Cop::Migration::AddLimitToTextColumns do
include CopHelper
subject(:cop) { described_class.new }
context 'in migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
context 'when text columns are defined without a limit' do
it 'registers an offense' do
expect_offense(<<~RUBY)
class TestTextLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
disable_ddl_transaction!
def up
create_table :test_text_limits, id: false do |t|
t.integer :test_id, null: false
t.text :name
^^^^ #{described_class::MSG}
end
add_column :test_text_limits, :email, :text
^^^^^^^^^^ #{described_class::MSG}
add_column_with_default :test_text_limits, :role, :text, default: 'default'
^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
change_column_type_concurrently :test_text_limits, :test_id, :text
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
end
end
RUBY
expect(cop.offenses.map(&:cop_name)).to all(eq('Migration/AddLimitToTextColumns'))
end
end
context 'when text columns are defined with a limit' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class TestTextLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
disable_ddl_transaction!
def up
create_table :test_text_limits, id: false do |t|
t.integer :test_id, null: false
t.text :name
end
add_column :test_text_limits, :email, :text
add_column_with_default :test_text_limits, :role, :text, default: 'default'
change_column_type_concurrently :test_text_limits, :test_id, :text
add_text_limit :test_text_limits, :name, 255
add_text_limit :test_text_limits, :email, 255
add_text_limit :test_text_limits, :role, 255
add_text_limit :test_text_limits, :test_id, 255
end
end
RUBY
end
end
# Make sure that the cop is properly checking for an `add_text_limit`
# over the same {table, attribute} as the one that triggered the offence
context 'when the limit is defined for a same name attribute but different table' do
it 'registers an offense' do
expect_offense(<<~RUBY)
class TestTextLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
disable_ddl_transaction!
def up
create_table :test_text_limits, id: false do |t|
t.integer :test_id, null: false
t.text :name
^^^^ #{described_class::MSG}
end
add_column :test_text_limits, :email, :text
^^^^^^^^^^ #{described_class::MSG}
add_column_with_default :test_text_limits, :role, :text, default: 'default'
^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
change_column_type_concurrently :test_text_limits, :test_id, :text
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
add_text_limit :wrong_table, :name, 255
add_text_limit :wrong_table, :email, 255
add_text_limit :wrong_table, :role, 255
add_text_limit :wrong_table, :test_id, 255
end
end
RUBY
expect(cop.offenses.map(&:cop_name)).to all(eq('Migration/AddLimitToTextColumns'))
end
end
context 'on down' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class TestTextLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
drop_table :no_offence_on_down
end
def down
create_table :no_offence_on_down, id: false do |t|
t.integer :test_id, null: false
t.text :name
end
add_column :no_offence_on_down, :email, :text
add_column_with_default :no_offence_on_down, :role, :text, default: 'default'
end
end
RUBY
end
end
end
context 'outside of migration' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class TestTextLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
disable_ddl_transaction!
def up
create_table :test_text_limits, id: false do |t|
t.integer :test_id, null: false
t.text :name
end
add_column :test_text_limits, :email, :text
add_column_with_default :test_text_limits, :role, :text, default: 'default'
change_column_type_concurrently :test_text_limits, :test_id, :text
end
end
RUBY
end
end
end
# frozen_string_literal: true
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/migration/prevent_strings'
describe RuboCop::Cop::Migration::PreventStrings do
include CopHelper
subject(:cop) { described_class.new }
context 'in migration' do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
context 'when the string data type is used' do
it 'registers an offense' do
expect_offense(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
create_table :users do |t|
t.string :username, null: false
^^^^^^ #{described_class::MSG}
t.timestamps_with_timezone null: true
t.string :password
^^^^^^ #{described_class::MSG}
end
add_column(:users, :bio, :string)
^^^^^^^^^^ #{described_class::MSG}
add_column_with_default(:users, :url, :string, default: '/-/user', allow_null: false, limit: 255)
^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
change_column_type_concurrently :users, :commit_id, :string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
end
end
RUBY
expect(cop.offenses.map(&:cop_name)).to all(eq('Migration/PreventStrings'))
end
end
context 'when the string data type is not used' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
create_table :users do |t|
t.integer :not_a_string, null: false
t.timestamps_with_timezone null: true
end
add_column(:users, :not_a_string, :integer)
end
end
RUBY
end
end
context 'when the text data type is used' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
create_table :users do |t|
t.text :username, null: false
t.timestamps_with_timezone null: true
t.text :password
end
add_column(:users, :bio, :text)
add_column_with_default(:users, :url, :text, default: '/-/user', allow_null: false, limit: 255)
change_column_type_concurrently :users, :commit_id, :text
end
end
RUBY
end
end
context 'on down' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
remove_column :users, :bio
remove_column :users, :url
drop_table :test_strings
end
def down
create_table :test_strings, id: false do |t|
t.integer :test_id, null: false
t.string :name
end
add_column(:users, :bio, :string)
add_column_with_default(:users, :url, :string, default: '/-/user', allow_null: false, limit: 255)
change_column_type_concurrently :users, :commit_id, :string
end
end
RUBY
end
end
end
context 'outside of migration' do
it 'registers no offense' do
expect_no_offenses(<<~RUBY)
class Users < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
create_table :users do |t|
t.string :username, null: false
t.timestamps_with_timezone null: true
t.string :password
end
add_column(:users, :bio, :string)
add_column_with_default(:users, :url, :string, default: '/-/user', allow_null: false, limit: 255)
change_column_type_concurrently :users, :commit_id, :string
end
end
RUBY
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment