diff options
author | Jamie Winsor <jamie@enmasse.com> | 2011-08-03 19:18:19 -0700 |
---|---|---|
committer | Jamie Winsor <jamie@enmasse.com> | 2011-08-03 19:18:19 -0700 |
commit | 274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55 (patch) | |
tree | c61db4fd992067a80e47396fcfc2feabd542fe10 /spec/dummy/db/migrate | |
parent | 13c35c262072c06a97b178c9c9cabbe2482ac649 (diff) | |
download | refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.tar.gz refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.tar.bz2 refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.zip |
refactor dummy application into git submodule
Diffstat (limited to 'spec/dummy/db/migrate')
19 files changed, 0 insertions, 462 deletions
diff --git a/spec/dummy b/spec/dummy new file mode 160000 +Subproject 84d66350ec474665e7d436dca479a142b091f87 diff --git a/spec/dummy/db/migrate/20110802081556_create_refinerycms_core_schema.rb b/spec/dummy/db/migrate/20110802081556_create_refinerycms_core_schema.rb deleted file mode 100644 index 3199a9c..0000000 --- a/spec/dummy/db/migrate/20110802081556_create_refinerycms_core_schema.rb +++ /dev/null @@ -1,23 +0,0 @@ -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 diff --git a/spec/dummy/db/migrate/20110802081557_add_locale_to_slugs.rb b/spec/dummy/db/migrate/20110802081557_add_locale_to_slugs.rb deleted file mode 100644 index 0795cad..0000000 --- a/spec/dummy/db/migrate/20110802081557_add_locale_to_slugs.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddLocaleToSlugs < ActiveRecord::Migration - def self.up - add_column ::Slug.table_name, :locale, :string - - add_index ::Slug.table_name, :locale - end - - def self.down - remove_column ::Slug.table_name, :locale - - remove_index ::Slug.table_name, :locale - end -end diff --git a/spec/dummy/db/migrate/20110802081558_create_refinerycms_settings_schema.rb b/spec/dummy/db/migrate/20110802081558_create_refinerycms_settings_schema.rb deleted file mode 100644 index b60cf82..0000000 --- a/spec/dummy/db/migrate/20110802081558_create_refinerycms_settings_schema.rb +++ /dev/null @@ -1,24 +0,0 @@ -class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration - def self.up - create_table ::Refinery::Setting.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 ::Refinery::Setting.table_name, ["name"], :name => "index_#{::Refinery::Setting.table_name}_on_name" - end - - def self.down - [::Refinery::Setting].reject{|m| - !(defined?(m) and m.respond_to?(:table_name)) - }.each do |model| - drop_table model.table_name - end - end -end diff --git a/spec/dummy/db/migrate/20110802081559_add_value_type_to_refinery_settings.rb b/spec/dummy/db/migrate/20110802081559_add_value_type_to_refinery_settings.rb deleted file mode 100644 index 2fdf6d8..0000000 --- a/spec/dummy/db/migrate/20110802081559_add_value_type_to_refinery_settings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddValueTypeToRefinerySettings < ActiveRecord::Migration - def self.up - add_column ::Refinery::Setting.table_name, :form_value_type, :string - end - - def self.down - remove_column ::Refinery::Setting.table_name, :form_value_type - end -end diff --git a/spec/dummy/db/migrate/20110802081560_create_refinerycms_authentication_schema.rb b/spec/dummy/db/migrate/20110802081560_create_refinerycms_authentication_schema.rb deleted file mode 100644 index f9b6c2e..0000000 --- a/spec/dummy/db/migrate/20110802081560_create_refinerycms_authentication_schema.rb +++ /dev/null @@ -1,48 +0,0 @@ -class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration - def self.up - # Postgres apparently requires the roles_users table to exist before creating the roles table. - create_table ::Refinery::RolesUsers.table_name, :id => false, :force => true do |t| - t.integer "user_id" - t.integer "role_id" - end unless ::Refinery::RolesUsers.table_exists? - - create_table ::Refinery::Role.table_name, :force => true do |t| - t.string "title" - end unless ::Refinery::Role.table_exists? - - unless ::Refinery::UserPlugin.table_exists? - create_table ::Refinery::UserPlugin.table_name, :force => true do |t| - t.integer "user_id" - t.string "name" - t.integer "position" - end - - add_index ::Refinery::UserPlugin.table_name, ["name"], :name => "index_#{::Refinery::UserPlugin.table_name}_on_title" - add_index ::Refinery::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::Refinery::UserPlugin.table_name}", :unique => true - - end - - unless ::Refinery::User.table_exists? - create_table ::Refinery::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 ::Refinery::User.table_name, ["id"], :name => "index_#{::Refinery::User.table_name}_on_id" - end - end - - def self.down - [::User].reject{|m| - !(defined?(m) and m.respond_to?(:table_name)) - }.each do |model| - drop_table model.table_name if model.table_exists? if model.table_exists? - end - end -end diff --git a/spec/dummy/db/migrate/20110802081561_add_missing_indexes_to_roles_users.rb b/spec/dummy/db/migrate/20110802081561_add_missing_indexes_to_roles_users.rb deleted file mode 100644 index e72d81f..0000000 --- a/spec/dummy/db/migrate/20110802081561_add_missing_indexes_to_roles_users.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddMissingIndexesToRolesUsers < ActiveRecord::Migration - def self.up - add_index ::Refinery::RolesUsers.table_name, [:role_id, :user_id] - add_index ::Refinery::RolesUsers.table_name, [:user_id, :role_id] - end - - def self.down - remove_index ::Refinery::RolesUsers.table_name, :column => [:role_id, :user_id] - remove_index ::Refinery::RolesUsers.table_name, :column => [:user_id, :role_id] - end -end diff --git a/spec/dummy/db/migrate/20110802081562_change_to_devise_users_table.rb b/spec/dummy/db/migrate/20110802081562_change_to_devise_users_table.rb deleted file mode 100644 index 8beef83..0000000 --- a/spec/dummy/db/migrate/20110802081562_change_to_devise_users_table.rb +++ /dev/null @@ -1,31 +0,0 @@ -class ChangeToDeviseUsersTable < ActiveRecord::Migration - def self.up - add_column ::Refinery::User.table_name, :current_sign_in_at, :datetime - add_column ::Refinery::User.table_name, :last_sign_in_at, :datetime - add_column ::Refinery::User.table_name, :current_sign_in_ip, :string - add_column ::Refinery::User.table_name, :last_sign_in_ip, :string - add_column ::Refinery::User.table_name, :sign_in_count, :integer - add_column ::Refinery::User.table_name, :remember_token, :string - add_column ::Refinery::User.table_name, :reset_password_token, :string - - rename_column ::Refinery::User.table_name, :crypted_password, :encrypted_password - rename_column ::Refinery::User.table_name, :login, :username - - ::Refinery::User.reset_column_information - end - - def self.down - remove_column ::Refinery::User.table_name, :current_sign_in_at - remove_column ::Refinery::User.table_name, :last_sign_in_at - remove_column ::Refinery::User.table_name, :current_sign_in_ip - remove_column ::Refinery::User.table_name, :last_sign_in_ip - remove_column ::Refinery::User.table_name, :sign_in_count - remove_column ::Refinery::User.table_name, :remember_token - remove_column ::Refinery::User.table_name, :reset_password_token - - rename_column ::Refinery::User.table_name, :encrypted_password, :crypted_password - rename_column ::Refinery::User.table_name, :username, :login - - ::Refinery::User.reset_column_information - end -end diff --git a/spec/dummy/db/migrate/20110802081563_add_remember_created_at_to_users.rb b/spec/dummy/db/migrate/20110802081563_add_remember_created_at_to_users.rb deleted file mode 100644 index 524b36f..0000000 --- a/spec/dummy/db/migrate/20110802081563_add_remember_created_at_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRememberCreatedAtToUsers < ActiveRecord::Migration - def change - add_column ::Refinery::User.table_name, :remember_created_at, :datetime - end -end diff --git a/spec/dummy/db/migrate/20110802081564_remove_password_salt_from_users.rb b/spec/dummy/db/migrate/20110802081564_remove_password_salt_from_users.rb deleted file mode 100644 index afcbfd7..0000000 --- a/spec/dummy/db/migrate/20110802081564_remove_password_salt_from_users.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RemovePasswordSaltFromUsers < ActiveRecord::Migration - def self.up - remove_column ::Refinery::User.table_name, :password_salt - # Make the current password invalid :( - ::Refinery::User.all.each do |u| - u.update_attribute(:encrypted_password, u.encrypted_password[29..-1]) - end - end - - def self.down - add_column ::Refinery::User.table_name, :password_salt, :string - end -end diff --git a/spec/dummy/db/migrate/20110802081565_create_refinerycms_images_schema.rb b/spec/dummy/db/migrate/20110802081565_create_refinerycms_images_schema.rb deleted file mode 100644 index 6c4e079..0000000 --- a/spec/dummy/db/migrate/20110802081565_create_refinerycms_images_schema.rb +++ /dev/null @@ -1,23 +0,0 @@ -class CreateRefinerycmsImagesSchema < ActiveRecord::Migration - def self.up - create_table ::Refinery::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 unless ::Refinery::Image.table_exists? - end - - def self.down - [::Image].reject{|m| - !(defined?(m) and m.respond_to?(:table_name)) - }.each do |model| - drop_table model.table_name if model.table_exists? - end - end -end diff --git a/spec/dummy/db/migrate/20110802081566_create_refinerycms_pages_schema.rb b/spec/dummy/db/migrate/20110802081566_create_refinerycms_pages_schema.rb deleted file mode 100644 index 4458726..0000000 --- a/spec/dummy/db/migrate/20110802081566_create_refinerycms_pages_schema.rb +++ /dev/null @@ -1,56 +0,0 @@ -class CreateRefinerycmsPagesSchema < ActiveRecord::Migration - def self.up - unless ::Refinery::PagePart.table_exists? - create_table ::Refinery::PagePart.table_name, :force => true do |t| - t.integer "refinery_page_id" - t.string "title" - t.text "body" - t.integer "position" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index ::Refinery::PagePart.table_name, ["id"], :name => "index_#{::Refinery::PagePart.table_name}_on_id" - add_index ::Refinery::PagePart.table_name, ["refinery_page_id"], :name => "index_#{::Refinery::PagePart.table_name}_on_page_id" - end - - unless ::Refinery::Page.table_exists? - create_table ::Refinery::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 ::Refinery::Page.table_name, ["depth"], :name => "index_#{::Refinery::Page.table_name}_on_depth" - add_index ::Refinery::Page.table_name, ["id"], :name => "index_#{::Refinery::Page.table_name}_on_id" - add_index ::Refinery::Page.table_name, ["lft"], :name => "index_#{::Refinery::Page.table_name}_on_lft" - add_index ::Refinery::Page.table_name, ["parent_id"], :name => "index_#{::Refinery::Page.table_name}_on_parent_id" - add_index ::Refinery::Page.table_name, ["rgt"], :name => "index_#{::Refinery::Page.table_name}_on_rgt" - end - end - - def self.down - [::Page, ::Refinery::PagePart].reject{|m| - !(defined?(m) and m.respond_to?(:table_name)) - }.each do |model| - drop_table model.table_name if model.table_exists? - end - end -end diff --git a/spec/dummy/db/migrate/20110802081567_translate_page_plugin.rb b/spec/dummy/db/migrate/20110802081567_translate_page_plugin.rb deleted file mode 100644 index bdb0a43..0000000 --- a/spec/dummy/db/migrate/20110802081567_translate_page_plugin.rb +++ /dev/null @@ -1,38 +0,0 @@ -class TranslatePagePlugin < ActiveRecord::Migration - def self.up - say_with_time("Creating ::Refinery::PagePart translation table") do - ::Refinery::PagePart.create_translation_table!({ - :body => :text - }, { - :migrate_data => true - }) - end - - say_with_time("Creating ::Refinery::Page translation table") do - ::Refinery::Page.create_translation_table!({ - :title => :string, - :meta_keywords => :string, - :meta_description => :text, - :browser_title => :string - }, { - :migrate_data => true - }) - end - - puts "seeds pages" - if (seed_file = Rails.root.join('db', 'seeds', 'pages.rb')).file? - load seed_file.to_s unless ::Refinery::Page.where(:link_url => '/').any? - end - - say_with_time("Updating slugs") do - ::Slug.update_all(:locale => I18n.locale) - end - end - - def self.down - say_with_time("Dropping ::Refinery::Page and ::Refinery::PagePart translation tables") do - ::Refinery::Page.drop_translation_table! :migrate_data => true - ::Refinery::PagePart.drop_translation_table! :migrate_data => true - end - end -end diff --git a/spec/dummy/db/migrate/20110802081568_remove_cached_slug_from_pages.rb b/spec/dummy/db/migrate/20110802081568_remove_cached_slug_from_pages.rb deleted file mode 100644 index d265838..0000000 --- a/spec/dummy/db/migrate/20110802081568_remove_cached_slug_from_pages.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveCachedSlugFromPages < ActiveRecord::Migration - def self.up - if ::Refinery::Page.column_names.map(&:to_s).include?('cached_slug') - remove_column ::Refinery::Page.table_name, :cached_slug - end - end - - def self.down - # Don't add this column back, it breaks stuff. - end -end diff --git a/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb b/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb deleted file mode 100644 index ab21e11..0000000 --- a/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb +++ /dev/null @@ -1,26 +0,0 @@ -class TranslateCustomTitleOnPages < ActiveRecord::Migration - def self.up - unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(:custom_title) - add_column ::Refinery::Page.translation_class.table_name, :custom_title, :string - - # Re-save custom_title - ::Refinery::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 - ::Refinery::Page.all.each do |page| - ::Refinery::Page.update_all({ - :custom_title => page.attributes['custom_title'] - }, { - :id => page.id.to_s - }) unless page.attributes['custom_title'].nil? - end - - remove_column ::Refinery::Page.translation_class.table_name, :custom_title - end -end diff --git a/spec/dummy/db/migrate/20110802081570_remove_translated_fields_from_pages.rb b/spec/dummy/db/migrate/20110802081570_remove_translated_fields_from_pages.rb deleted file mode 100644 index 9dc30b2..0000000 --- a/spec/dummy/db/migrate/20110802081570_remove_translated_fields_from_pages.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration - def self.up - ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name| - remove_column ::Refinery::Page.table_name, column_name if ::Refinery::Page.column_names.map(&:to_sym).include?(column_name) - end - end - - def self.down - ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name| - add_column ::Refinery::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type - end - end -end diff --git a/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb b/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb deleted file mode 100644 index abc2178..0000000 --- a/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb +++ /dev/null @@ -1,86 +0,0 @@ -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 = ::Refinery::Page.translation_class.all.map(&:attributes) - - # Remove columns - ::SeoMeta.attributes.keys.each do |field| - if ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field) - remove_column ::Refinery::Page.translation_class.table_name, field - end - end - - # Reset column information because otherwise the old columns will still exist. - ::Refinery::Page.translation_class.reset_column_information - - # Re-attach seo_meta - ::Refinery::Page.translation_class.send :is_seo_meta - - # Migrate data - existing_translations.each do |translation| - ::Refinery::Page.translation_class.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. - ::Refinery::Page.reset_column_information - end - - def self.down - # Grab the attributes of the records that currently exist - existing_translations = ::Refinery::Page.translation_class.all.map(&:attributes) - - # Add columns back to your model - ::SeoMeta.attributes.each do |field, field_type| - unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field) - add_column ::Refinery::Page.translation_class.table_name, field, field_type - end - end - - # Reset column information because otherwise the new columns won't exist yet. - ::Refinery::Page.translation_class.reset_column_information - - # Migrate data - existing_translations.each do |translation| - ::Refinery::Page.translation_class.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| - ::Refinery::Page.translation_class.module_eval %{ - def #{k} - end - - def #{k}=(*args) - end - } - end - - # Reset column information again because otherwise the old columns will still exist. - ::Refinery::Page.reset_column_information - - drop_table :seo_meta - end - -end diff --git a/spec/dummy/db/migrate/20110802081572_create_add_template_columns.rb b/spec/dummy/db/migrate/20110802081572_create_add_template_columns.rb deleted file mode 100644 index eb98ed1..0000000 --- a/spec/dummy/db/migrate/20110802081572_create_add_template_columns.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateAddTemplateColumns < ActiveRecord::Migration - def self.up - add_column ::Refinery::Page.table_name, :view_template, :string - add_column ::Refinery::Page.table_name, :layout_template, :string - end - - def self.down - remove_column ::Refinery::Page.table_name, :layout_template - remove_column ::Refinery::Page.table_name, :view_template - end -end diff --git a/spec/dummy/db/migrate/20110802081573_create_refinerycms_resources_schema.rb b/spec/dummy/db/migrate/20110802081573_create_refinerycms_resources_schema.rb deleted file mode 100644 index 360f469..0000000 --- a/spec/dummy/db/migrate/20110802081573_create_refinerycms_resources_schema.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateRefinerycmsResourcesSchema < ActiveRecord::Migration - def self.up - create_table ::Refinery::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 unless ::Refinery::Resource.table_exists? - end - - def self.down - [::Resource].reject{|m| - !(defined?(m) and m.respond_to?(:table_name)) - }.each do |model| - drop_table model.table_name if model.table_exists? - end - end -end |