diff options
author | Drew Blessing <drew.blessing@me.com> | 2014-09-07 19:54:18 -0500 |
---|---|---|
committer | Drew Blessing <drew.blessing@me.com> | 2014-09-10 09:56:39 -0500 |
commit | a0dbcd2365b9c90892ccd0c5dfb18c7c58de8704 (patch) | |
tree | 09b0e5a4027cb9187d9f46f4cd6ff75ac64ea1e6 /db | |
parent | f42a1ded99920998a9b63b309adc227485428d2c (diff) | |
download | gitlab-ce-a0dbcd2365b9c90892ccd0c5dfb18c7c58de8704.tar.gz |
Serialize services properties
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20140907220153_serialize_service_properties.rb | 35 | ||||
-rw-r--r-- | db/schema.rb | 13 |
2 files changed, 39 insertions, 9 deletions
diff --git a/db/migrate/20140907220153_serialize_service_properties.rb b/db/migrate/20140907220153_serialize_service_properties.rb new file mode 100644 index 00000000000..2326fd0aebf --- /dev/null +++ b/db/migrate/20140907220153_serialize_service_properties.rb @@ -0,0 +1,35 @@ +class SerializeServiceProperties < ActiveRecord::Migration + def change + add_column :services, :properties, :text + + associations = + { + AssemblaService: [:token, :subdomain], + CampfireService: [:token, :subdomain, :room], + EmailsOnPushService: [:recipients], + FlowdockService: [:token], + GemnasiumService: [:api_key, :token], + GitlabCiService: [:token, :project_url], + HipchatService: [:token, :room], + PivotaltrackerService: [:token], + SlackService: [:subdomain, :token, :room], + JenkinsService: [:token, :subdomain], + JiraService: [:project_url, :username, :password, + :api_version, :jira_issue_transition_id], + } + + Service.all.each do |service| + associations[service.type.to_sym].each do |attribute| + service.send("#{attribute}=", service.attributes[attribute.to_s]) + end + service.save! + end + + remove_column :services, :project_url, :string + remove_column :services, :subdomain, :string + remove_column :services, :room, :string + remove_column :services, :recipients, :text + remove_column :services, :api_key, :string + remove_column :services, :token, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index a2dda07c102..e9b3713557d 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: 20140903115954) do +ActiveRecord::Schema.define(version: 20140907220153) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -265,16 +265,11 @@ ActiveRecord::Schema.define(version: 20140903115954) do create_table "services", force: true do |t| t.string "type" t.string "title" - t.string "token" - t.integer "project_id", null: false + t.integer "project_id", null: false t.datetime "created_at" t.datetime "updated_at" - t.boolean "active", default: false, null: false - t.string "project_url" - t.string "subdomain" - t.string "room" - t.text "recipients" - t.string "api_key" + t.boolean "active", default: false, null: false + t.text "properties" end add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree |