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`
This commit is contained in:
parent
312dc89a44
commit
8c8a9e6d3f
5 changed files with 27 additions and 57 deletions
|
@ -3,11 +3,16 @@ class CreateGpgKeys < ActiveRecord::Migration
|
||||||
|
|
||||||
def change
|
def change
|
||||||
create_table :gpg_keys do |t|
|
create_table :gpg_keys do |t|
|
||||||
t.string :fingerprint
|
t.timestamps_with_timezone null: false
|
||||||
t.text :key
|
|
||||||
t.references :user, index: true, foreign_key: true
|
t.references :user, index: true, foreign_key: true
|
||||||
|
|
||||||
t.timestamps_with_timezone null: false
|
t.string :fingerprint
|
||||||
|
t.string :primary_keyid
|
||||||
|
|
||||||
|
t.text :key
|
||||||
|
|
||||||
|
t.index :primary_keyid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
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
|
|
|
@ -1,29 +1,22 @@
|
||||||
class CreateGpgSignatures < ActiveRecord::Migration
|
class CreateGpgSignatures < ActiveRecord::Migration
|
||||||
include Gitlab::Database::MigrationHelpers
|
|
||||||
|
|
||||||
DOWNTIME = false
|
DOWNTIME = false
|
||||||
|
|
||||||
disable_ddl_transaction!
|
def change
|
||||||
|
|
||||||
def up
|
|
||||||
create_table :gpg_signatures do |t|
|
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 :project, index: true, foreign_key: true
|
||||||
t.references :gpg_key, 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.boolean :valid_signature
|
||||||
|
|
||||||
t.timestamps_with_timezone null: false
|
t.string :commit_sha
|
||||||
|
t.string :gpg_key_primary_keyid
|
||||||
|
t.string :gpg_key_user_name
|
||||||
|
t.string :gpg_key_user_email
|
||||||
|
|
||||||
|
t.index :commit_sha
|
||||||
|
t.index :gpg_key_primary_keyid
|
||||||
end
|
end
|
||||||
|
|
||||||
add_concurrent_index :gpg_signatures, :commit_sha
|
|
||||||
add_concurrent_index :gpg_signatures, :gpg_key_primary_keyid
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
drop_table :gpg_signatures
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# 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
|
|
16
db/schema.rb
16
db/schema.rb
|
@ -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
|
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|
|
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 "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "fingerprint"
|
||||||
t.string "primary_keyid"
|
t.string "primary_keyid"
|
||||||
|
t.text "key"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "gpg_keys", ["primary_keyid"], name: "index_gpg_keys_on_primary_keyid", using: :btree
|
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
|
add_index "gpg_keys", ["user_id"], name: "index_gpg_keys_on_user_id", using: :btree
|
||||||
|
|
||||||
create_table "gpg_signatures", force: :cascade do |t|
|
create_table "gpg_signatures", force: :cascade do |t|
|
||||||
t.string "commit_sha"
|
|
||||||
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 "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "gpg_key_id"
|
||||||
|
t.boolean "valid_signature"
|
||||||
|
t.string "commit_sha"
|
||||||
|
t.string "gpg_key_primary_keyid"
|
||||||
t.string "gpg_key_user_name"
|
t.string "gpg_key_user_name"
|
||||||
t.string "gpg_key_user_email"
|
t.string "gpg_key_user_email"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue