Commit 8c8a9e6d authored by Alexis Reigel's avatar Alexis Reigel

merge migrations to 1 single create per table

also:

* reorder table columns
* no need for `add_concurrent_index`
* no need for explicit index removal on `#down`
parent 312dc89a
......@@ -3,11 +3,16 @@ class CreateGpgKeys < ActiveRecord::Migration
def change
create_table :gpg_keys do |t|
t.timestamps_with_timezone null: false
t.references :user, index: true, foreign_key: true
t.string :fingerprint
t.string :primary_keyid
t.text :key
t.references :user, index: true, foreign_key: true
t.timestamps_with_timezone null: false
t.index :primary_keyid
end
end
end
class AddPrimaryKeyidToGpgKeys < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :gpg_keys, :primary_keyid, :string
add_concurrent_index :gpg_keys, :primary_keyid
end
def down
remove_concurrent_index :gpg_keys, :primary_keyid if index_exists?(:gpg_keys, :primary_keyid)
remove_column :gpg_keys, :primary_keyid, :string
end
end
class CreateGpgSignatures < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
def change
create_table :gpg_signatures do |t|
t.string :commit_sha
t.timestamps_with_timezone null: false
t.references :project, index: true, foreign_key: true
t.references :gpg_key, index: true, foreign_key: true
t.string :gpg_key_primary_keyid
t.boolean :valid_signature
t.timestamps_with_timezone null: false
end
add_concurrent_index :gpg_signatures, :commit_sha
add_concurrent_index :gpg_signatures, :gpg_key_primary_keyid
end
t.boolean :valid_signature
def down
remove_concurrent_index :gpg_signatures, :commit_sha if index_exists?(:gpg_signatures, :commit_sha)
remove_concurrent_index :gpg_signatures, :gpg_key_primary_keyid if index_exists?(:gpg_signatures, :gpg_key_primary_keyid)
t.string :commit_sha
t.string :gpg_key_primary_keyid
t.string :gpg_key_user_name
t.string :gpg_key_user_email
drop_table :gpg_signatures
t.index :commit_sha
t.index :gpg_key_primary_keyid
end
end
end
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddGpgKeyUserInfoToGpgSignatures < ActiveRecord::Migration
DOWNTIME = false
def change
add_column :gpg_signatures, :gpg_key_user_name, :string
add_column :gpg_signatures, :gpg_key_user_email, :string
end
end
......@@ -541,25 +541,25 @@ ActiveRecord::Schema.define(version: 20170725145659) do
add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree
create_table "gpg_keys", force: :cascade do |t|
t.string "fingerprint"
t.text "key"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.string "fingerprint"
t.string "primary_keyid"
t.text "key"
end
add_index "gpg_keys", ["primary_keyid"], name: "index_gpg_keys_on_primary_keyid", using: :btree
add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree
create_table "gpg_signatures", force: :cascade do |t|
t.string "commit_sha"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "project_id"
t.integer "gpg_key_id"
t.string "gpg_key_primary_keyid"
t.boolean "valid_signature"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "commit_sha"
t.string "gpg_key_primary_keyid"
t.string "gpg_key_user_name"
t.string "gpg_key_user_email"
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment