From 2391b02ab0ed5a81ff7ad94058dd4f4cc9beeb44 Mon Sep 17 00:00:00 2001 From: Jim Neath Date: Mon, 29 Sep 2008 18:22:52 +0100 Subject: [PATCH] Merged all migrations into one file to help keep things uncluttered in the file department --- db/migrate/20080811093045_create_sessions.rb | 16 ---- db/migrate/20080811094730_create_users.rb | 24 ----- db/migrate/20080811135317_create_passwords.rb | 14 --- db/migrate/20080912160708_create_roles.rb | 17 ---- .../20080912160936_add_default_admin_user.rb | 25 ----- ...23512_add_open_id_authentication_tables.rb | 20 ---- db/migrate/20080929171348_bort_migration.rb | 91 +++++++++++++++++++ db/schema.rb | 2 +- 8 files changed, 92 insertions(+), 117 deletions(-) delete mode 100644 db/migrate/20080811093045_create_sessions.rb delete mode 100644 db/migrate/20080811094730_create_users.rb delete mode 100644 db/migrate/20080811135317_create_passwords.rb delete mode 100644 db/migrate/20080912160708_create_roles.rb delete mode 100644 db/migrate/20080912160936_add_default_admin_user.rb delete mode 100644 db/migrate/20080924123512_add_open_id_authentication_tables.rb create mode 100644 db/migrate/20080929171348_bort_migration.rb diff --git a/db/migrate/20080811093045_create_sessions.rb b/db/migrate/20080811093045_create_sessions.rb deleted file mode 100644 index 4ccc353b..00000000 --- a/db/migrate/20080811093045_create_sessions.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateSessions < ActiveRecord::Migration - def self.up - create_table :sessions do |t| - t.string :session_id, :null => false - t.text :data - t.timestamps - end - - add_index :sessions, :session_id - add_index :sessions, :updated_at - end - - def self.down - drop_table :sessions - end -end diff --git a/db/migrate/20080811094730_create_users.rb b/db/migrate/20080811094730_create_users.rb deleted file mode 100644 index 4f73520e..00000000 --- a/db/migrate/20080811094730_create_users.rb +++ /dev/null @@ -1,24 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def self.up - create_table :users do |t| - t.string :login, :limit => 40 - t.string :identity_url - t.string :name, :limit => 100, :default => '', :null => true - t.string :email, :limit => 100 - t.string :crypted_password, :limit => 40 - t.string :salt, :limit => 40 - t.string :remember_token, :limit => 40 - t.string :activation_code, :limit => 40 - t.string :state, :null => :no, :default => 'passive' - t.datetime :remember_token_expires_at - t.datetime :activated_at - t.datetime :deleted_at - t.timestamps - end - add_index :users, :login, :unique => true - end - - def self.down - drop_table :users - end -end diff --git a/db/migrate/20080811135317_create_passwords.rb b/db/migrate/20080811135317_create_passwords.rb deleted file mode 100644 index e539465a..00000000 --- a/db/migrate/20080811135317_create_passwords.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreatePasswords < ActiveRecord::Migration - def self.up - create_table :passwords do |t| - t.integer :user_id - t.string :reset_code - t.datetime :expiration_date - t.timestamps - end - end - - def self.down - drop_table :passwords - end -end diff --git a/db/migrate/20080912160708_create_roles.rb b/db/migrate/20080912160708_create_roles.rb deleted file mode 100644 index 0146bc38..00000000 --- a/db/migrate/20080912160708_create_roles.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateRoles < ActiveRecord::Migration - def self.up - create_table :roles do |t| - t.string :name - end - - create_table :roles_users, :id => false do |t| - t.belongs_to :role - t.belongs_to :user - end - end - - def self.down - drop_table :roles - drop_table :roles_users - end -end \ No newline at end of file diff --git a/db/migrate/20080912160936_add_default_admin_user.rb b/db/migrate/20080912160936_add_default_admin_user.rb deleted file mode 100644 index a9348e08..00000000 --- a/db/migrate/20080912160936_add_default_admin_user.rb +++ /dev/null @@ -1,25 +0,0 @@ -class AddDefaultAdminUser < ActiveRecord::Migration - def self.up - # Create admin role - admin_role = Role.create(:name => 'admin') - - # Create default admin user - user = User.create do |u| - u.login = 'admin' - u.password = u.password_confirmation = 'chester' - u.email = APP_CONFIG[:admin_email] - end - - # Activate user - user.register! - user.activate! - - # Add admin role to admin user - user.roles << admin_role - end - - def self.down - Role.delete_all - User.delete_all - end -end diff --git a/db/migrate/20080924123512_add_open_id_authentication_tables.rb b/db/migrate/20080924123512_add_open_id_authentication_tables.rb deleted file mode 100644 index caae0d8c..00000000 --- a/db/migrate/20080924123512_add_open_id_authentication_tables.rb +++ /dev/null @@ -1,20 +0,0 @@ -class AddOpenIdAuthenticationTables < ActiveRecord::Migration - def self.up - create_table :open_id_authentication_associations, :force => true do |t| - t.integer :issued, :lifetime - t.string :handle, :assoc_type - t.binary :server_url, :secret - end - - create_table :open_id_authentication_nonces, :force => true do |t| - t.integer :timestamp, :null => false - t.string :server_url, :null => true - t.string :salt, :null => false - end - end - - def self.down - drop_table :open_id_authentication_associations - drop_table :open_id_authentication_nonces - end -end diff --git a/db/migrate/20080929171348_bort_migration.rb b/db/migrate/20080929171348_bort_migration.rb new file mode 100644 index 00000000..0038871f --- /dev/null +++ b/db/migrate/20080929171348_bort_migration.rb @@ -0,0 +1,91 @@ +class BortMigration < ActiveRecord::Migration + def self.up + # Create Sessions Table + create_table :sessions do |t| + t.string :session_id, :null => false + t.text :data + t.timestamps + end + + add_index :sessions, :session_id + add_index :sessions, :updated_at + + # Create OpenID Tables + create_table :open_id_authentication_associations, :force => true do |t| + t.integer :issued, :lifetime + t.string :handle, :assoc_type + t.binary :server_url, :secret + end + + create_table :open_id_authentication_nonces, :force => true do |t| + t.integer :timestamp, :null => false + t.string :server_url, :null => true + t.string :salt, :null => false + end + + # Create Users Table + create_table :users do |t| + t.string :login, :limit => 40 + t.string :identity_url + t.string :name, :limit => 100, :default => '', :null => true + t.string :email, :limit => 100 + t.string :crypted_password, :limit => 40 + t.string :salt, :limit => 40 + t.string :remember_token, :limit => 40 + t.string :activation_code, :limit => 40 + t.string :state, :null => :no, :default => 'passive' + t.datetime :remember_token_expires_at + t.datetime :activated_at + t.datetime :deleted_at + t.timestamps + end + + add_index :users, :login, :unique => true + + # Create Passwords Table + create_table :passwords do |t| + t.integer :user_id + t.string :reset_code + t.datetime :expiration_date + t.timestamps + end + + # Create Roles Databases + create_table :roles do |t| + t.string :name + end + + create_table :roles_users, :id => false do |t| + t.belongs_to :role + t.belongs_to :user + end + + # Create admin role + admin_role = Role.create(:name => 'admin') + + # Create default admin user + user = User.create do |u| + u.login = 'admin' + u.password = u.password_confirmation = 'chester' + u.email = APP_CONFIG[:admin_email] + end + + # Activate user + user.register! + user.activate! + + # Add admin role to admin user + user.roles << admin_role + end + + def self.down + # Drop all Bort tables + drop_table :sessions + drop_table :users + drop_table :passwords + drop_table :roles + drop_table :roles_users + drop_table :open_id_authentication_associations + drop_table :open_id_authentication_nonces + end +end diff --git a/db/schema.rb b/db/schema.rb index c8cf7ab4..914ac4fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20080924123512) do +ActiveRecord::Schema.define(:version => 20080929171348) do create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued"