Merge admin and api users

This commit is contained in:
Martin Lensment 2015-02-13 13:05:01 +02:00
parent fcd3f4146b
commit f3215680d5
6 changed files with 114 additions and 37 deletions

View file

@ -0,0 +1,21 @@
class MergeApiUserAndUser < ActiveRecord::Migration
def change
add_column :users, :registrar_id, :integer
add_column :users, :active, :boolean, default: false
add_column :users, :csr, :text
add_column :users, :crt, :text
add_column :users, :type, :string
User.all.each do |x|
x.type = 'AdminUser'
x.save
end
ApiUserDeprecated.all.each do |x|
attrs = x.attributes
attrs.delete('id')
ApiUser.skip_callback(:save, :before, :create_crt)
ApiUser.create!(attrs)
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150203135303) do
ActiveRecord::Schema.define(version: 20150213104014) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -614,17 +614,22 @@ ActiveRecord::Schema.define(version: 20150203135303) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "email"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
t.string "identity_code"
t.integer "country_id"
t.string "roles", array: true
t.string "roles", array: true
t.string "creator_str"
t.string "updator_str"
t.string "country_code"
t.integer "registrar_id"
t.boolean "active", default: false
t.text "csr"
t.text "crt"
t.string "type"
end
create_table "versions", force: :cascade do |t|