Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20140415124820_limits_to_mysql.rb1
-rw-r--r--db/migrate/20140416074002_add_index_on_iid.rb32
-rw-r--r--db/migrate/20140416185734_index_on_current_sign_in_at.rb5
-rw-r--r--db/migrate/20140428105831_add_notes_index_updated_at.rb5
-rw-r--r--db/migrate/limits_to_mysql.rb10
-rw-r--r--db/schema.rb7
6 files changed, 59 insertions, 1 deletions
diff --git a/db/migrate/20140415124820_limits_to_mysql.rb b/db/migrate/20140415124820_limits_to_mysql.rb
new file mode 100644
index 00000000000..3f6e62617c5
--- /dev/null
+++ b/db/migrate/20140415124820_limits_to_mysql.rb
@@ -0,0 +1 @@
+require_relative 'limits_to_mysql'
diff --git a/db/migrate/20140416074002_add_index_on_iid.rb b/db/migrate/20140416074002_add_index_on_iid.rb
new file mode 100644
index 00000000000..85269e2a03b
--- /dev/null
+++ b/db/migrate/20140416074002_add_index_on_iid.rb
@@ -0,0 +1,32 @@
+class AddIndexOnIid < ActiveRecord::Migration
+ def change
+ RemoveDuplicateIid.clean(Issue)
+ RemoveDuplicateIid.clean(MergeRequest, 'target_project_id')
+ RemoveDuplicateIid.clean(Milestone)
+
+ add_index :issues, [:project_id, :iid], unique: true
+ add_index :merge_requests, [:target_project_id, :iid], unique: true
+ add_index :milestones, [:project_id, :iid], unique: true
+ end
+end
+
+class RemoveDuplicateIid
+ def self.clean(klass, project_field = 'project_id')
+ duplicates = klass.find_by_sql("SELECT iid, #{project_field} FROM #{klass.table_name} GROUP BY #{project_field}, iid HAVING COUNT(*) > 1")
+
+ duplicates.each do |duplicate|
+ project_id = duplicate.send(project_field)
+ iid = duplicate.iid
+ items = klass.of_projects(project_id).where(iid: iid)
+
+ if items.size > 1
+ puts "Remove #{klass.name} duplicates for iid: #{iid} and project_id: #{project_id}"
+ items.shift
+ items.each do |item|
+ item.destroy
+ puts '.'
+ end
+ end
+ end
+ end
+end
diff --git a/db/migrate/20140416185734_index_on_current_sign_in_at.rb b/db/migrate/20140416185734_index_on_current_sign_in_at.rb
new file mode 100644
index 00000000000..0bf80ce154a
--- /dev/null
+++ b/db/migrate/20140416185734_index_on_current_sign_in_at.rb
@@ -0,0 +1,5 @@
+class IndexOnCurrentSignInAt < ActiveRecord::Migration
+ def change
+ add_index :users, :current_sign_in_at
+ end
+end
diff --git a/db/migrate/20140428105831_add_notes_index_updated_at.rb b/db/migrate/20140428105831_add_notes_index_updated_at.rb
new file mode 100644
index 00000000000..6c25570f128
--- /dev/null
+++ b/db/migrate/20140428105831_add_notes_index_updated_at.rb
@@ -0,0 +1,5 @@
+class AddNotesIndexUpdatedAt < ActiveRecord::Migration
+ def change
+ add_index :notes, :updated_at
+ end
+end
diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb
new file mode 100644
index 00000000000..2b7afae6d7c
--- /dev/null
+++ b/db/migrate/limits_to_mysql.rb
@@ -0,0 +1,10 @@
+class LimitsToMysql < ActiveRecord::Migration
+ def up
+ return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
+
+ change_column :merge_request_diffs, :st_commits, :text, limit: 2147483647
+ change_column :merge_request_diffs, :st_diffs, :text, limit: 2147483647
+ change_column :snippets, :content, :text, limit: 2147483647
+ change_column :notes, :st_diff, :text, limit: 2147483647
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index dbd489335db..a26c60874a3 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: 20140414131055) do
+ActiveRecord::Schema.define(version: 20140428105831) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20140414131055) do
add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree
add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree
add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree
+ add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree
add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree
add_index "issues", ["title"], name: "index_issues_on_title", using: :btree
@@ -143,6 +144,7 @@ ActiveRecord::Schema.define(version: 20140414131055) do
add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree
add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree
add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree
+ add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree
add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree
create_table "milestones", force: true do |t|
@@ -157,6 +159,7 @@ ActiveRecord::Schema.define(version: 20140414131055) do
end
add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree
+ add_index "milestones", ["project_id", "iid"], name: "index_milestones_on_project_id_and_iid", unique: true, using: :btree
add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree
create_table "namespaces", force: true do |t|
@@ -197,6 +200,7 @@ ActiveRecord::Schema.define(version: 20140414131055) do
add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree
add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree
add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree
+ add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree
create_table "projects", force: true do |t|
t.string "name"
@@ -332,6 +336,7 @@ ActiveRecord::Schema.define(version: 20140414131055) do
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
+ add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", using: :btree