summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-02-29 20:50:23 -0700
committermo k <mo@mokhan.ca>2012-02-29 20:50:23 -0700
commit29fc85fbec3ca220d6dfaa38ea7e71c2c195ec7e (patch)
treeb7d73ed17100d7908cde9c662e1e8a7369de877c /db
parentd07feb75ec40f68a8b011d3a61195798c2d78cae (diff)
add active admin. go to http://??/admin/ username:admin@example.com password:password
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20120229204755_create_admin_notes.rb16
-rw-r--r--db/migrate/20120229204756_move_admin_notes_to_comments.rb25
-rw-r--r--db/migrate/20120301034745_devise_create_admin_users.rb28
-rw-r--r--db/schema.rb35
4 files changed, 103 insertions, 1 deletions
diff --git a/db/migrate/20120229204755_create_admin_notes.rb b/db/migrate/20120229204755_create_admin_notes.rb
new file mode 100644
index 00000000..a2d3247e
--- /dev/null
+++ b/db/migrate/20120229204755_create_admin_notes.rb
@@ -0,0 +1,16 @@
+class CreateAdminNotes < ActiveRecord::Migration
+ def self.up
+ create_table :admin_notes do |t|
+ t.references :resource, :polymorphic => true, :null => false
+ t.references :admin_user, :polymorphic => true
+ t.text :body
+ t.timestamps
+ end
+ add_index :admin_notes, [:resource_type, :resource_id]
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+
+ def self.down
+ drop_table :admin_notes
+ end
+end
diff --git a/db/migrate/20120229204756_move_admin_notes_to_comments.rb b/db/migrate/20120229204756_move_admin_notes_to_comments.rb
new file mode 100644
index 00000000..296aa43f
--- /dev/null
+++ b/db/migrate/20120229204756_move_admin_notes_to_comments.rb
@@ -0,0 +1,25 @@
+class MoveAdminNotesToComments < ActiveRecord::Migration
+ def self.up
+ remove_index :admin_notes, [:admin_user_type, :admin_user_id]
+ rename_table :admin_notes, :active_admin_comments
+ rename_column :active_admin_comments, :admin_user_type, :author_type
+ rename_column :active_admin_comments, :admin_user_id, :author_id
+ add_column :active_admin_comments, :namespace, :string
+ add_index :active_admin_comments, [:namespace]
+ add_index :active_admin_comments, [:author_type, :author_id]
+
+ # Update all the existing comments to the default namespace
+ say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
+ execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
+ end
+
+ def self.down
+ remove_index :active_admin_comments, :column => [:author_type, :author_id]
+ remove_index :active_admin_comments, :column => [:namespace]
+ remove_column :active_admin_comments, :namespace
+ rename_column :active_admin_comments, :author_id, :admin_user_id
+ rename_column :active_admin_comments, :author_type, :admin_user_type
+ rename_table :active_admin_comments, :admin_notes
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
+ end
+end
diff --git a/db/migrate/20120301034745_devise_create_admin_users.rb b/db/migrate/20120301034745_devise_create_admin_users.rb
new file mode 100644
index 00000000..6730a47b
--- /dev/null
+++ b/db/migrate/20120301034745_devise_create_admin_users.rb
@@ -0,0 +1,28 @@
+class DeviseCreateAdminUsers < ActiveRecord::Migration
+ def change
+ create_table(:admin_users) do |t|
+ t.database_authenticatable :null => false
+ t.recoverable
+ t.rememberable
+ t.trackable
+
+ # t.encryptable
+ # t.confirmable
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
+ # t.token_authenticatable
+
+
+ t.timestamps
+ end
+
+ # Create a default user
+ AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')
+
+ add_index :admin_users, :email, :unique => true
+ add_index :admin_users, :reset_password_token, :unique => true
+ # add_index :admin_users, :confirmation_token, :unique => true
+ # add_index :admin_users, :unlock_token, :unique => true
+ # add_index :admin_users, :authentication_token, :unique => true
+ end
+
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4212b150..49af2c03 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,40 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120130032306) do
+ActiveRecord::Schema.define(:version => 20120301034745) do
+
+ create_table "active_admin_comments", :force => true do |t|
+ t.integer "resource_id", :null => false
+ t.string "resource_type", :null => false
+ t.integer "author_id"
+ t.string "author_type"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "namespace"
+ end
+
+ add_index "active_admin_comments", ["author_type", "author_id"], :name => "index_active_admin_comments_on_author_type_and_author_id"
+ add_index "active_admin_comments", ["namespace"], :name => "index_active_admin_comments_on_namespace"
+ add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id"
+
+ create_table "admin_users", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true
+ add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true
create_table "categories", :force => true do |t|
t.string "name"