From 1530f68c9876bc8376bf4aa199c8abda570f5214 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 24 Sep 2015 17:09:33 +0200 Subject: WIP --- db/migrate/20150924125150_add_project_id_to_ci_tables.rb | 12 ++++++++++++ .../20150924125436_migrate_project_id_for_ci_tables.rb | 15 +++++++++++++++ .../20150924131004_add_ci_fields_to_projects_table.rb | 5 +++++ 3 files changed, 32 insertions(+) create mode 100644 db/migrate/20150924125150_add_project_id_to_ci_tables.rb create mode 100644 db/migrate/20150924125436_migrate_project_id_for_ci_tables.rb create mode 100644 db/migrate/20150924131004_add_ci_fields_to_projects_table.rb (limited to 'db') diff --git a/db/migrate/20150924125150_add_project_id_to_ci_tables.rb b/db/migrate/20150924125150_add_project_id_to_ci_tables.rb new file mode 100644 index 00000000000..8b45bcf5fe1 --- /dev/null +++ b/db/migrate/20150924125150_add_project_id_to_ci_tables.rb @@ -0,0 +1,12 @@ +class AddProjectIdToCiTables < ActiveRecord::Migration + def up + add_column :ci_builds, :gl_project_id, :integer + add_column :ci_commits, :gl_project_id, :integer + add_column :ci_events, :gl_project_id, :integer + add_column :ci_runner_projects, :gl_project_id, :integer + add_column :ci_services, :gl_project_id, :integer + add_column :ci_triggers, :gl_project_id, :integer + add_column :ci_variables, :gl_project_id, :integer + add_column :ci_web_hooks, :gl_project_id, :integer + end +end diff --git a/db/migrate/20150924125436_migrate_project_id_for_ci_tables.rb b/db/migrate/20150924125436_migrate_project_id_for_ci_tables.rb new file mode 100644 index 00000000000..28d63c8c840 --- /dev/null +++ b/db/migrate/20150924125436_migrate_project_id_for_ci_tables.rb @@ -0,0 +1,15 @@ +class MigrateProjectIdForCiTables < ActiveRecord::Migration + TABLES = %w(ci_builds ci_commits ci_events ci_runner_projects + ci_services ci_triggers ci_variables ci_web_hooks) + + def up + TABLES.each do |table| + execute( + "UPDATE #{table} " + + "JOIN ci_projects ON ci_projects.id = #{table}.project_id " + + "SET gl_project_id=ci_projects.gitlab_id " + + "WHERE gl_project_id IS NULL" + ) + end + end +end diff --git a/db/migrate/20150924131004_add_ci_fields_to_projects_table.rb b/db/migrate/20150924131004_add_ci_fields_to_projects_table.rb new file mode 100644 index 00000000000..bb97ec30051 --- /dev/null +++ b/db/migrate/20150924131004_add_ci_fields_to_projects_table.rb @@ -0,0 +1,5 @@ +class AddCiFieldsToProjectsTable < ActiveRecord::Migration + def up + add_column :projects, :shared_runners_enabled, :boolean, default: false + end +end -- cgit v1.2.1