summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-08-22 11:34:41 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-08-22 11:34:41 +0300
commit9329436deb3931d28c28b41de56173ef8acd63b5 (patch)
tree7557875233d3b506c2496599db1814afc7558c7c /db
parent6db65143db5003f74ddb1c9868a3d852e5661a0a (diff)
parentfb84439a92e759ff90811e98f6abf6bdbb3e6d55 (diff)
downloadgitlab-ce-9329436deb3931d28c28b41de56173ef8acd63b5.tar.gz
Merge branch 'master' into dz-merge-request-version
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/14_pipelines.rb (renamed from db/fixtures/development/14_builds.rb)99
-rw-r--r--db/migrate/20160801163421_add_expires_at_to_member.rb29
-rw-r--r--db/migrate/20160817133006_add_koding_to_application_settings.rb10
-rw-r--r--db/migrate/20160818205718_add_expires_at_to_project_group_links.rb29
-rw-r--r--db/migrate/20160819221631_add_index_to_note_discussion_id.rb14
-rw-r--r--db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb12
-rw-r--r--db/schema.rb9
7 files changed, 158 insertions, 44 deletions
diff --git a/db/fixtures/development/14_builds.rb b/db/fixtures/development/14_pipelines.rb
index 069d9dd6226..49e6e2361b1 100644
--- a/db/fixtures/development/14_builds.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -1,4 +1,4 @@
-class Gitlab::Seeder::Builds
+class Gitlab::Seeder::Pipelines
STAGES = %w[build test deploy notify]
BUILDS = [
{ name: 'build:linux', stage: 'build', status: :success },
@@ -7,11 +7,12 @@ class Gitlab::Seeder::Builds
{ name: 'rspec:windows', stage: 'test', status: :success },
{ name: 'rspec:windows', stage: 'test', status: :success },
{ name: 'rspec:osx', stage: 'test', status_event: :success },
- { name: 'spinach:linux', stage: 'test', status: :pending },
- { name: 'spinach:osx', stage: 'test', status: :canceled },
- { name: 'cucumber:linux', stage: 'test', status: :running },
- { name: 'cucumber:osx', stage: 'test', status: :failed },
- { name: 'staging', stage: 'deploy', environment: 'staging', status: :success },
+ { name: 'spinach:linux', stage: 'test', status: :success },
+ { name: 'spinach:osx', stage: 'test', status: :failed, allow_failure: true},
+ { name: 'env:alpha', stage: 'deploy', environment: 'alpha', status: :pending },
+ { name: 'env:beta', stage: 'deploy', environment: 'beta', status: :running },
+ { name: 'env:gamma', stage: 'deploy', environment: 'gamma', status: :canceled },
+ { name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success },
{ name: 'production', stage: 'deploy', environment: 'production', when: 'manual', status: :skipped },
{ name: 'slack', stage: 'notify', when: 'manual', status: :created },
]
@@ -34,72 +35,86 @@ class Gitlab::Seeder::Builds
end
end
+ private
+
def pipelines
- master_pipelines + merge_request_pipelines
+ create_master_pipelines + create_merge_request_pipelines
end
- def master_pipelines
- create_pipelines_for(@project, 'master')
+ def create_master_pipelines
+ @project.repository.commits('master', limit: 4).map do |commit|
+ create_pipeline!(@project, 'master', commit)
+ end
rescue
[]
end
- def merge_request_pipelines
- @project.merge_requests.last(5).map do |merge_request|
- create_pipelines(merge_request.source_project, merge_request.source_branch, merge_request.commits.last(5))
- end.flatten
+ def create_merge_request_pipelines
+ pipelines = @project.merge_requests.first(3).map do |merge_request|
+ project = merge_request.source_project
+ branch = merge_request.source_branch
+
+ merge_request.commits.last(4).map do |commit|
+ create_pipeline!(project, branch, commit)
+ end
+ end
+
+ pipelines.flatten
rescue
[]
end
- def create_pipelines_for(project, ref)
- commits = project.repository.commits(ref, limit: 5)
- create_pipelines(project, ref, commits)
+
+ def create_pipeline!(project, ref, commit)
+ project.pipelines.create(sha: commit.id, ref: ref)
end
- def create_pipelines(project, ref, commits)
- commits.map do |commit|
- project.pipelines.create(sha: commit.id, ref: ref)
+ def build_create!(pipeline, opts = {})
+ attributes = job_attributes(pipeline, opts)
+ .merge(commands: '$ build command')
+
+ Ci::Build.create!(attributes).tap do |build|
+ # We need to set build trace and artifacts after saving a build
+ # (id required), that is why we need `#tap` method instead of passing
+ # block directly to `Ci::Build#create!`.
+
+ setup_artifacts(build)
+ setup_build_log(build)
+ build.save
end
end
- def build_create!(pipeline, opts = {})
- attributes = build_attributes_for(pipeline, opts)
+ def setup_artifacts(build)
+ return unless %w[build test].include?(build.stage)
- Ci::Build.create!(attributes) do |build|
- if opts[:name].start_with?('build')
- artifacts_cache_file(artifacts_archive_path) do |file|
- build.artifacts_file = file
- end
+ artifacts_cache_file(artifacts_archive_path) do |file|
+ build.artifacts_file = file
+ end
- artifacts_cache_file(artifacts_metadata_path) do |file|
- build.artifacts_metadata = file
- end
- end
+ artifacts_cache_file(artifacts_metadata_path) do |file|
+ build.artifacts_metadata = file
+ end
+ end
- if %w(running success failed).include?(build.status)
- # We need to set build trace after saving a build (id required)
- build.trace = FFaker::Lorem.paragraphs(6).join("\n\n")
- end
+ def setup_build_log(build)
+ if %w(running success failed).include?(build.status)
+ build.trace = FFaker::Lorem.paragraphs(6).join("\n\n")
end
end
def commit_status_create!(pipeline, opts = {})
- attributes = commit_status_attributes_for(pipeline, opts)
+ attributes = job_attributes(pipeline, opts)
+
GenericCommitStatus.create!(attributes)
end
- def commit_status_attributes_for(pipeline, opts)
+ def job_attributes(pipeline, opts)
{ name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]),
ref: 'master', tag: false, user: build_user, project: @project, pipeline: pipeline,
created_at: Time.now, updated_at: Time.now
}.merge(opts)
end
- def build_attributes_for(pipeline, opts)
- commit_status_attributes_for(pipeline, opts).merge(commands: '$ build command')
- end
-
def build_user
@project.team.users.sample
end
@@ -131,8 +146,8 @@ class Gitlab::Seeder::Builds
end
Gitlab::Seeder.quiet do
- Project.all.sample(10).each do |project|
- project_builds = Gitlab::Seeder::Builds.new(project)
+ Project.all.sample(5).each do |project|
+ project_builds = Gitlab::Seeder::Pipelines.new(project)
project_builds.seed!
end
end
diff --git a/db/migrate/20160801163421_add_expires_at_to_member.rb b/db/migrate/20160801163421_add_expires_at_to_member.rb
new file mode 100644
index 00000000000..8db0fc60c4b
--- /dev/null
+++ b/db/migrate/20160801163421_add_expires_at_to_member.rb
@@ -0,0 +1,29 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddExpiresAtToMember < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # When a migration requires downtime you **must** uncomment the following
+ # constant and define a short and easy to understand explanation as to why the
+ # migration requires downtime.
+ # DOWNTIME_REASON = ''
+
+ # When using the methods "add_concurrent_index" or "add_column_with_default"
+ # you must disable the use of transactions as these methods can not run in an
+ # existing transaction. When using "add_concurrent_index" make sure that this
+ # method is the _only_ method called in the migration, any other changes
+ # should go in a separate migration. This ensures that upon failure _only_ the
+ # index creation fails and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ # disable_ddl_transaction!
+
+ def change
+ add_column :members, :expires_at, :date
+ end
+end
diff --git a/db/migrate/20160817133006_add_koding_to_application_settings.rb b/db/migrate/20160817133006_add_koding_to_application_settings.rb
new file mode 100644
index 00000000000..915d3d78e40
--- /dev/null
+++ b/db/migrate/20160817133006_add_koding_to_application_settings.rb
@@ -0,0 +1,10 @@
+class AddKodingToApplicationSettings < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :koding_enabled, :boolean
+ add_column :application_settings, :koding_url, :string
+ end
+end
diff --git a/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb b/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb
new file mode 100644
index 00000000000..0ed538b0df8
--- /dev/null
+++ b/db/migrate/20160818205718_add_expires_at_to_project_group_links.rb
@@ -0,0 +1,29 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddExpiresAtToProjectGroupLinks < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # When a migration requires downtime you **must** uncomment the following
+ # constant and define a short and easy to understand explanation as to why the
+ # migration requires downtime.
+ # DOWNTIME_REASON = ''
+
+ # When using the methods "add_concurrent_index" or "add_column_with_default"
+ # you must disable the use of transactions as these methods can not run in an
+ # existing transaction. When using "add_concurrent_index" make sure that this
+ # method is the _only_ method called in the migration, any other changes
+ # should go in a separate migration. This ensures that upon failure _only_ the
+ # index creation fails and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ # disable_ddl_transaction!
+
+ def change
+ add_column :project_group_links, :expires_at, :date
+ end
+end
diff --git a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb
new file mode 100644
index 00000000000..b6e8bb18e7b
--- /dev/null
+++ b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb
@@ -0,0 +1,14 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddIndexToNoteDiscussionId < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def change
+ add_concurrent_index :notes, :discussion_id
+ end
+end
diff --git a/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb b/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb
new file mode 100644
index 00000000000..0c68cf01900
--- /dev/null
+++ b/db/migrate/20160819221833_reset_diff_note_discussion_id_because_it_was_calculated_wrongly.rb
@@ -0,0 +1,12 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class ResetDiffNoteDiscussionIdBecauseItWasCalculatedWrongly < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ execute "UPDATE notes SET discussion_id = NULL WHERE discussion_id IS NOT NULL AND type = 'DiffNote'"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c74d4688a7d..4947745b232 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: 20160817154936) do
+ActiveRecord::Schema.define(version: 20160819221833) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -90,6 +90,8 @@ ActiveRecord::Schema.define(version: 20160817154936) do
t.string "enabled_git_access_protocol"
t.boolean "domain_blacklist_enabled", default: false
t.text "domain_blacklist"
+ t.boolean "koding_enabled"
+ t.string "koding_url"
end
create_table "audit_events", force: :cascade do |t|
@@ -569,6 +571,7 @@ ActiveRecord::Schema.define(version: 20160817154936) do
t.string "invite_token"
t.datetime "invite_accepted_at"
t.datetime "requested_at"
+ t.date "expires_at"
end
add_index "members", ["access_level"], name: "index_members_on_access_level", using: :btree
@@ -701,6 +704,7 @@ ActiveRecord::Schema.define(version: 20160817154936) do
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree
add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree
+ add_index "notes", ["discussion_id"], name: "index_notes_on_discussion_id", using: :btree
add_index "notes", ["line_code"], name: "index_notes_on_line_code", using: :btree
add_index "notes", ["note"], name: "index_notes_on_note_trigram", using: :gin, opclasses: {"note"=>"gin_trgm_ops"}
add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree
@@ -785,6 +789,7 @@ ActiveRecord::Schema.define(version: 20160817154936) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "group_access", default: 30, null: false
+ t.date "expires_at"
end
create_table "project_import_data", force: :cascade do |t|
@@ -1151,4 +1156,4 @@ ActiveRecord::Schema.define(version: 20160817154936) do
add_foreign_key "protected_branch_merge_access_levels", "protected_branches"
add_foreign_key "protected_branch_push_access_levels", "protected_branches"
add_foreign_key "u2f_registrations", "users"
-end
+end \ No newline at end of file