project setup

* added refinerycms(-blog) as depencies
* removed capybara (we won't do any browsertests here)
* initialized refinery in dummy app
This commit is contained in:
Marc Remolt
2011-06-01 21:07:20 +02:00
parent 3ec27fdfe6
commit 1a68663552
46 changed files with 1263 additions and 211 deletions

View File

@@ -0,0 +1,23 @@
class CreateRefinerycmsCoreSchema < ActiveRecord::Migration
def self.up
create_table ::Slug.table_name, :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"
end
add_index ::Slug.table_name, ["name", "sluggable_type", "scope", "sequence"], :name => "index_#{::Slug.table_name}_on_n_s_s_and_s", :unique => true
add_index ::Slug.table_name, ["sluggable_id"], :name => "index_#{::Slug.table_name}_on_sluggable_id"
end
def self.down
[::Slug].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,13 @@
class AddLocaleToSlugs < ActiveRecord::Migration
def self.up
add_column :slugs, :locale, :string
add_index :slugs, :locale
end
def self.down
remove_column :slugs, :locale
remove_index :slugs, :locale
end
end

View File

@@ -0,0 +1,24 @@
class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration
def self.up
create_table ::RefinerySetting.table_name, :force => true do |t|
t.string "name"
t.text "value"
t.boolean "destroyable", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.string "scoping"
t.boolean "restricted", :default => false
t.string "callback_proc_as_string"
end
add_index ::RefinerySetting.table_name, ["name"], :name => "index_#{::RefinerySetting.table_name}_on_name"
end
def self.down
[::RefinerySetting].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,9 @@
class AddValueTypeToRefinerySettings < ActiveRecord::Migration
def self.up
add_column ::RefinerySetting.table_name, :form_value_type, :string
end
def self.down
remove_column ::RefinerySetting.table_name, :form_value_type
end
end

View File

@@ -0,0 +1,43 @@
class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
def self.up
# Postgres apparently requires the roles_users table to exist before creating the roles table.
create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
create_table ::Role.table_name, :force => true do |t|
t.string "title"
end
create_table ::UserPlugin.table_name, :force => true do |t|
t.integer "user_id"
t.string "name"
t.integer "position"
end
add_index ::UserPlugin.table_name, ["name"], :name => "index_#{::UserPlugin.table_name}_on_title"
add_index ::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::UserPlugin.table_name}", :unique => true
create_table ::User.table_name, :force => true do |t|
t.string "login", :null => false
t.string "email", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.string "perishable_token"
end
add_index ::User.table_name, ["id"], :name => "index_#{::User.table_name}_on_id"
end
def self.down
[::User].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,11 @@
class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
def self.up
add_index ::RolesUsers.table_name, [:role_id, :user_id]
add_index ::RolesUsers.table_name, [:user_id, :role_id]
end
def self.down
remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id]
remove_index ::RolesUsers.table_name, :column => [:user_id, :role_id]
end
end

View File

@@ -0,0 +1,27 @@
class ChangeToDeviseUsersTable < ActiveRecord::Migration
def self.up
add_column ::User.table_name, :current_sign_in_at, :datetime
add_column ::User.table_name, :last_sign_in_at, :datetime
add_column ::User.table_name, :current_sign_in_ip, :string
add_column ::User.table_name, :last_sign_in_ip, :string
add_column ::User.table_name, :sign_in_count, :integer
add_column ::User.table_name, :remember_token, :string
add_column ::User.table_name, :reset_password_token, :string
rename_column ::User.table_name, :crypted_password, :encrypted_password
rename_column ::User.table_name, :login, :username
end
def self.down
remove_column ::User.table_name, :current_sign_in_at
remove_column ::User.table_name, :last_sign_in_at
remove_column ::User.table_name, :current_sign_in_ip
remove_column ::User.table_name, :last_sign_in_ip
remove_column ::User.table_name, :sign_in_count
remove_column ::User.table_name, :remember_token
remove_column ::User.table_name, :reset_password_token
rename_column ::User.table_name, :encrypted_password, :crypted_password
rename_column ::User.table_name, :username, :login
end
end

View File

@@ -0,0 +1,9 @@
class AddRememberCreatedAtToUsers < ActiveRecord::Migration
def self.up
add_column :users, :remember_created_at, :datetime
end
def self.down
remove_column :users, :remember_created_at
end
end

View File

@@ -0,0 +1,13 @@
class RemovePasswordSaltFromUsers < ActiveRecord::Migration
def self.up
remove_column :users, :password_salt
# Make the current password invalid :(
User.all.each do |u|
u.update_attribute(:encrypted_password, u.encrypted_password[29..-1])
end
end
def self.down
add_column :users, :password_salt, :string
end
end

View File

@@ -0,0 +1,23 @@
class CreateRefinerycmsImagesSchema < ActiveRecord::Migration
def self.up
create_table ::Image.table_name, :force => true do |t|
t.string "image_mime_type"
t.string "image_name"
t.integer "image_size"
t.integer "image_width"
t.integer "image_height"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image_uid"
t.string "image_ext"
end
end
def self.down
[::Image].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,52 @@
class CreateRefinerycmsPagesSchema < ActiveRecord::Migration
def self.up
create_table ::PagePart.table_name, :force => true do |t|
t.integer "page_id"
t.string "title"
t.text "body"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index ::PagePart.table_name, ["id"], :name => "index_#{::PagePart.table_name}_on_id"
add_index ::PagePart.table_name, ["page_id"], :name => "index_#{::PagePart.table_name}_on_page_id"
create_table ::Page.table_name, :force => true do |t|
t.string "title"
t.integer "parent_id"
t.integer "position"
t.string "path"
t.datetime "created_at"
t.datetime "updated_at"
t.string "meta_keywords"
t.text "meta_description"
t.boolean "show_in_menu", :default => true
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title"
t.string "custom_title_type", :default => "none"
t.boolean "draft", :default => false
t.string "browser_title"
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
t.integer "rgt"
t.integer "depth"
end
add_index ::Page.table_name, ["depth"], :name => "index_#{::Page.table_name}_on_depth"
add_index ::Page.table_name, ["id"], :name => "index_#{::Page.table_name}_on_id"
add_index ::Page.table_name, ["lft"], :name => "index_#{::Page.table_name}_on_lft"
add_index ::Page.table_name, ["parent_id"], :name => "index_#{::Page.table_name}_on_parent_id"
add_index ::Page.table_name, ["rgt"], :name => "index_#{::Page.table_name}_on_rgt"
end
def self.down
[::Page, ::PagePart].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,29 @@
class TranslatePagePlugin < ActiveRecord::Migration
def self.up
PagePart.create_translation_table!({
:body => :text
}, {
:migrate_data => true
})
Page.create_translation_table!({
:title => :string,
:meta_keywords => :string,
:meta_description => :text,
:browser_title => :string
}, {
:migrate_data => true
})
if (seed_file = Rails.root.join('db', 'seeds', 'pages.rb')).file?
load seed_file.to_s unless Page.where(:link_url => '/').any?
end
Slug.update_all(:locale => ::I18n.locale)
end
def self.down
Page.drop_translation_table! :migrate_data => true
PagePart.drop_translation_table! :migrate_data => true
end
end

View File

@@ -0,0 +1,11 @@
class RemoveCachedSlugFromPages < ActiveRecord::Migration
def self.up
if ::Page.column_names.map(&:to_s).include?('cached_slug')
remove_column ::Page.table_name, :cached_slug
end
end
def self.down
# Don't add this column back, it breaks stuff.
end
end

View File

@@ -0,0 +1,26 @@
class TranslateCustomTitleOnPages < ActiveRecord::Migration
def self.up
unless ::Page::Translation.column_names.map(&:to_sym).include?(:custom_title)
add_column ::Page::Translation.table_name, :custom_title, :string
# Re-save custom_title
::Page.all.each do |page|
page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
end
end
end
def self.down
# Re-save custom_title
::Page.all.each do |page|
::Page.update_all({
:custom_title => page.attributes['custom_title']
}, {
:id => page.id.to_s
}) unless page.attributes['custom_title'].nil?
end
remove_column ::Page::Translation.table_name, :custom_title
end
end

View File

@@ -0,0 +1,13 @@
class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
def self.up
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
remove_column ::Page.table_name, column_name if ::Page.column_names.map(&:to_sym).include?(column_name)
end
end
def self.down
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
add_column ::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
end
end
end

View File

@@ -0,0 +1,88 @@
class CreateSeoMeta < ActiveRecord::Migration
def self.up
create_table :seo_meta do |t|
t.integer :seo_meta_id
t.string :seo_meta_type
t.string :browser_title
t.string :meta_keywords
t.text :meta_description
t.timestamps
end
add_index :seo_meta, :id
add_index :seo_meta, [:seo_meta_id, :seo_meta_type]
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Remove columns
::SeoMeta.attributes.keys.each do |field|
if ::Page::Translation.column_names.map(&:to_sym).include?(field)
remove_column ::Page::Translation.table_name, field
end
end
# Reset column information because otherwise the old columns will still exist.
::Page::Translation.reset_column_information
# Re-attach seo_meta
::Page::Translation.module_eval do
is_seo_meta
end
# Migrate data
existing_translations.each do |translation|
::Page::Translation.find(translation['id']).update_attributes(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}
)
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
end
def self.down
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Add columns back to your model
::SeoMeta.attributes.each do |field, field_type|
unless ::Page::Translation.column_names.map(&:to_sym).include?(field)
add_column ::Page::Translation.table_name, field, field_type
end
end
# Reset column information because otherwise the new columns won't exist yet.
::Page::Translation.reset_column_information
# Migrate data
existing_translations.each do |translation|
::Page::Translation.update_all(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}, :id => translation['id']
)
end
::SeoMeta.attributes.keys.each do |k|
::Page::Translation.module_eval %{
def #{k}
end
def #{k}=(*args)
end
}
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
drop_table :seo_meta
end
end

View File

@@ -0,0 +1,21 @@
class CreateRefinerycmsResourcesSchema < ActiveRecord::Migration
def self.up
create_table ::Resource.table_name, :force => true do |t|
t.string "file_mime_type"
t.string "file_name"
t.integer "file_size"
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_uid"
t.string "file_ext"
end
end
def self.down
[::Resource].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@@ -0,0 +1,54 @@
class CreateBlogStructure < ActiveRecord::Migration
def self.up
create_table :blog_posts, :id => true do |t|
t.string :title
t.text :body
t.boolean :draft
t.datetime :published_at
t.timestamps
end
add_index :blog_posts, :id
create_table :blog_comments, :id => true do |t|
t.integer :blog_post_id
t.boolean :spam
t.string :name
t.string :email
t.text :body
t.string :state
t.timestamps
end
add_index :blog_comments, :id
create_table :blog_categories, :id => true do |t|
t.string :title
t.timestamps
end
add_index :blog_categories, :id
create_table :blog_categories_blog_posts, :id => false do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end
add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
end
def self.down
UserPlugin.destroy_all({:name => "refinerycms_blog"})
Page.delete_all({:link_url => "/blog"})
drop_table :blog_posts
drop_table :blog_comments
drop_table :blog_categories
drop_table :blog_categories_blog_posts
end
end

View File

@@ -0,0 +1,11 @@
class AddUserIdToBlogPosts < ActiveRecord::Migration
def self.up
add_column :blog_posts, :user_id, :integer
end
def self.down
remove_column :blog_posts, :user_id
end
end