Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
Migration upgrades or installs
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Apr 10, 2012
1 parent a1b2fd4 commit 2fc3ea3
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 98 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -48,7 +48,10 @@ _If you want to upgrade from masquerade, please skip this part and see the Upgra

3. Copy your existing masquerade config file from `config/app_config.yml` to the new apps `config/masq.yml`

4. Change the existing database tables to be prefixed with *masq_*. We will supply a migration for that later on, for now you'll have to do this by hand.
4. Copy the migrations and migrate:
* PLEASE BACKUP YOUR DATABASE FIRST!
* `bundle exec rake masq:install:migrations`
* `bundle exec rake db:migrate`

5. Configure the routes by mounting the masq engine:

Expand Down
231 changes: 134 additions & 97 deletions db/migrate/20120312120000_masq_schema.rb
@@ -1,115 +1,152 @@
class MasqSchema < ActiveRecord::Migration
def change
create_table "masq_accounts", :force => true do |t|
t.boolean "enabled", :default => true
t.string "login", :null => false
t.string "email", :null => false
t.string "crypted_password", :limit => 40, :null => false
t.string "salt", :limit => 40, :null => false
t.string "remember_token"
t.string "password_reset_code", :limit => 40
t.string "activation_code", :limit => 40
t.string "yubico_identity", :limit => 12
t.integer "public_persona_id"
t.datetime "last_authenticated_at"
t.boolean "last_authenticated_with_yubikey"
t.boolean "yubikey_mandatory", :default => false, :null => false
t.datetime "remember_token_expires_at"
t.datetime "activated_at"
t.datetime "created_at"
t.datetime "updated_at"
end
# Check for existing masquerade tables. In case the tables already exist,
# upgrade the database by renaming the tables - otherwise create them.

add_index "masq_accounts", ["email"], :unique => true
add_index "masq_accounts", ["login"], :unique => true
# Accounts: Also check for columns, as account is a pretty generic model name
# and we don't want to conflict with an existing account tables that's not
# from an existing masquerade installation
if table_exists?(:accounts) && column_exists?(:accounts, :public_persona_id) &&
column_exists?(:accounts, :yubico_identity)
rename_table :accounts, :masq_accounts
else
create_table :masq_accounts, :force => true do |t|
t.boolean :enabled, :default => true
t.string :login, :null => false
t.string :email, :null => false
t.string :crypted_password, :limit => 40, :null => false
t.string :salt, :limit => 40, :null => false
t.string :remember_token
t.string :password_reset_code, :limit => 40
t.string :activation_code, :limit => 40
t.string :yubico_identity, :limit => 12
t.integer :public_persona_id
t.datetime :last_authenticated_at
t.boolean :last_authenticated_with_yubikey
t.boolean :yubikey_mandatory, :default => false, :null => false
t.datetime :remember_token_expires_at
t.datetime :activated_at
t.datetime :created_at
t.datetime :updated_at
end

create_table "masq_open_id_associations", :force => true do |t|
t.binary "server_url"
t.binary "secret"
t.string "handle"
t.string "assoc_type"
t.integer "issued"
t.integer "lifetime"
add_index :masq_accounts, [:email], :unique => true
add_index :masq_accounts, [:login], :unique => true
end

create_table "masq_open_id_nonces", :force => true do |t|
t.string "server_url", :null => false
t.string "salt", :null => false
t.integer "timestamp", :null => false
# OpenID Associations
if table_exists?(:open_id_associations)
rename_table :open_id_associations, :masq_open_id_associations
else
create_table :masq_open_id_associations, :force => true do |t|
t.binary :server_url
t.binary :secret
t.string :handle
t.string :assoc_type
t.integer :issued
t.integer :lifetime
end
end

create_table "masq_open_id_requests", :force => true do |t|
t.string "token", :limit => 40
t.text "parameters"
t.datetime "created_at"
t.datetime "updated_at"
# OpenID Nonces
if table_exists?(:open_id_nonces)
rename_table :open_id_nonces, :masq_open_id_nonces
else
create_table :masq_open_id_nonces, :force => true do |t|
t.string :server_url, :null => false
t.string :salt, :null => false
t.integer :timestamp, :null => false
end
end

add_index "masq_open_id_requests", ["token"], :unique => true

create_table "masq_personas", :force => true do |t|
t.integer "account_id", :null => false
t.string "title", :null => false
t.string "nickname"
t.string "email"
t.string "fullname"
t.string "postcode"
t.string "country"
t.string "language"
t.string "timezone"
t.string "gender", :limit => 1
t.string "address"
t.string "address_additional"
t.string "city"
t.string "state"
t.string "company_name"
t.string "job_title"
t.string "address_business"
t.string "address_additional_business"
t.string "postcode_business"
t.string "city_business"
t.string "state_business"
t.string "country_business"
t.string "phone_home"
t.string "phone_mobile"
t.string "phone_work"
t.string "phone_fax"
t.string "im_aim"
t.string "im_icq"
t.string "im_msn"
t.string "im_yahoo"
t.string "im_jabber"
t.string "im_skype"
t.string "image_default"
t.string "biography"
t.string "web_default"
t.string "web_blog"
t.integer "dob_day", :limit => 2
t.integer "dob_month", :limit => 2
t.integer "dob_year"
t.boolean "deletable", :default => true, :null => false
t.datetime "created_at"
t.datetime "updated_at"
# OpenID Requests
if table_exists?(:open_id_requests)
rename_table :open_id_requests, :masq_open_id_requests
else
create_table :masq_open_id_requests, :force => true do |t|
t.string :token, :limit => 40
t.text :parameters
t.datetime :created_at
t.datetime :updated_at
end
add_index :masq_open_id_requests, [:token], :unique => true
end

add_index "masq_personas", ["account_id", "title"], :unique => true

create_table "masq_release_policies", :force => true do |t|
t.integer "site_id", :null => false
t.string "property", :null => false
t.string "type_identifier"
# Personas
if table_exists?(:personas)
rename_table :personas, :masq_personas
else
create_table :masq_personas, :force => true do |t|
t.integer :account_id, :null => false
t.string :title, :null => false
t.string :nickname
t.string :email
t.string :fullname
t.string :postcode
t.string :country
t.string :language
t.string :timezone
t.string :gender, :limit => 1
t.string :address
t.string :address_additional
t.string :city
t.string :state
t.string :company_name
t.string :job_title
t.string :address_business
t.string :address_additional_business
t.string :postcode_business
t.string :city_business
t.string :state_business
t.string :country_business
t.string :phone_home
t.string :phone_mobile
t.string :phone_work
t.string :phone_fax
t.string :im_aim
t.string :im_icq
t.string :im_msn
t.string :im_yahoo
t.string :im_jabber
t.string :im_skype
t.string :image_default
t.string :biography
t.string :web_default
t.string :web_blog
t.integer :dob_day, :limit => 2
t.integer :dob_month, :limit => 2
t.integer :dob_year
t.boolean :deletable, :default => true, :null => false
t.datetime :created_at
t.datetime :updated_at
end
add_index :masq_personas, [:account_id, :title], :unique => true
end

add_index "masq_release_policies", ["site_id", "property", "type_identifier"], :name => 'index_masq_release_policies', :unique => true

create_table "masq_sites", :force => true do |t|
t.integer "account_id", :null => false
t.integer "persona_id", :null => false
t.string "url", :null => false
t.datetime "created_at"
t.datetime "updated_at"
# Release Policies
if table_exists?(:release_policies)
rename_table :release_policies, :masq_release_policies
else
create_table :masq_release_policies, :force => true do |t|
t.integer :site_id, :null => false
t.string :property, :null => false
t.string :type_identifier
end
add_index :masq_release_policies, [:site_id, :property, :type_identifier], :name => :index_masq_release_policies, :unique => true
end

add_index "masq_sites", ["account_id", "url"], :unique => true
# Sites
if table_exists?(:sites)
rename_table :sites, :masq_sites
else
create_table :masq_sites, :force => true do |t|
t.integer :account_id, :null => false
t.integer :persona_id, :null => false
t.string :url, :null => false
t.datetime :created_at
t.datetime :updated_at
end
add_index :masq_sites, [:account_id, :url], :unique => true
end
end
end

0 comments on commit 2fc3ea3

Please sign in to comment.