diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20161207231626_add_environment_slug.rb | 18 | ||||
-rw-r--r-- | db/migrate/20170130204620_add_index_to_project_authorizations.rb | 11 | ||||
-rw-r--r-- | db/schema.rb | 3 |
3 files changed, 26 insertions, 6 deletions
diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 7153e6a32b1..8e98ee5b9ba 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -8,8 +8,9 @@ class AddEnvironmentSlug < ActiveRecord::Migration DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data' # Used to generate random suffixes for the slug + LETTERS = 'a'..'z' NUMBERS = '0'..'9' - SUFFIX_CHARS = ('a'..'z').to_a + NUMBERS.to_a + SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a def up environments = Arel::Table.new(:environments) @@ -39,17 +40,24 @@ class AddEnvironmentSlug < ActiveRecord::Migration slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-') # Must start with a letter - slugified = "env-" + slugified if NUMBERS.cover?(slugified[0]) + slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0]) + + # Repeated dashes are invalid (OpenShift limitation) + slugified.gsub!(/\-+/, '-') # Maximum length: 24 characters (OpenShift limitation) slugified = slugified[0..23] - # Cannot end with a "-" character (Kubernetes label limitation) - slugified = slugified[0..-2] if slugified[-1] == "-" + # Cannot end with a dash (Kubernetes label limitation) + slugified.chop! if slugified.end_with?('-') # Add a random suffix, shortening the current string if necessary, if it # has been slugified. This ensures uniqueness. - slugified = slugified[0..16] + "-" + random_suffix if slugified != name + if slugified != name + slugified = slugified[0..16] + slugified << '-' unless slugified.end_with?('-') + slugified << random_suffix + end slugified end diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb new file mode 100644 index 00000000000..e9a0aee4d6a --- /dev/null +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -0,0 +1,11 @@ +class AddIndexToProjectAuthorizations < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(:project_authorizations, :project_id) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3c836db27fc..5efb4f6595c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170121130655) do +ActiveRecord::Schema.define(version: 20170130204620) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -874,6 +874,7 @@ ActiveRecord::Schema.define(version: 20170121130655) do t.integer "access_level" end + add_index "project_authorizations", ["project_id"], name: "index_project_authorizations_on_project_id", using: :btree add_index "project_authorizations", ["user_id", "project_id", "access_level"], name: "index_project_authorizations_on_user_id_project_id_access_level", unique: true, using: :btree create_table "project_features", force: :cascade do |t| |