diff --git a/.gitignore b/.gitignore index 0f2c82fccf..88b1690102 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ config/mail.yml *.log *~ +db/* +db/db_test +db/db_development db/*.sqlite* db/schema.rb .*.swp diff --git a/Gemfile b/Gemfile index b8121c7ee5..771ddb6ce7 100644 --- a/Gemfile +++ b/Gemfile @@ -57,4 +57,5 @@ group :development, :test do gem 'cucumber-rails-training-wheels' gem 'database_cleaner' gem 'capybara' + gem 'pry' end diff --git a/Gemfile.lock b/Gemfile.lock index 64eb36cc1c..26794b0ec3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: RedCloth (4.2.9) abstract (1.0.0) @@ -87,6 +87,8 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) + method_source (0.6.7) + ruby_parser (>= 2.3.1) mime-types (1.19) mini_magick (1.3.3) subexec (~> 0.0.4) @@ -94,6 +96,11 @@ GEM nokogiri (1.5.5) pg (0.14.1) polyglot (0.3.3) + pry (0.9.7.4) + coderay (~> 0.9.8) + method_source (~> 0.6.7) + ruby_parser (>= 2.3.1) + slop (~> 2.1.0) rack (1.2.5) rack-mount (0.6.14) rack (>= 1.0.0) @@ -141,6 +148,8 @@ GEM ruby-debug-base19 (>= 0.11.19) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) + ruby_parser (3.8.1) + sexp_processor (~> 4.1) rubypants (0.2.0) rubyzip (0.9.9) selenium-webdriver (2.25.0) @@ -148,10 +157,12 @@ GEM libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip + sexp_processor (4.7.0) simplecov (0.6.4) multi_json (~> 1.0) simplecov-html (~> 0.5.3) simplecov-html (0.5.3) + slop (2.1.0) sqlite3 (1.3.6) subexec (0.0.4) thin (1.5.0) @@ -193,6 +204,7 @@ DEPENDENCIES kaminari mini_magick (~> 1.3.3) pg + pry rails (~> 3.0.10) rake (~> 0.9.2) recaptcha @@ -205,3 +217,6 @@ DEPENDENCIES thin uuidtools (~> 2.1.1) webrat + +BUNDLED WITH + 1.11.2 diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index b7026f8f29..86bdad6126 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -4,10 +4,10 @@ class Admin::CategoriesController < Admin::BaseController def index; redirect_to :action => 'new' ; end def edit; new_or_edit; end - def new + def new respond_to do |format| format.html { new_or_edit } - format.js { + format.js { @category = Category.new } end @@ -24,22 +24,26 @@ def destroy private def new_or_edit - @categories = Category.find(:all) - @category = Category.find(params[:id]) - @category.attributes = params[:category] - if request.post? - respond_to do |format| - format.html { save_category } - format.js do - @category.save - @article = Article.new - @article.categories << @category - return render(:partial => 'admin/content/categories') + begin + @categories = Category.find(:all) + @category = params[:id] ? Category.find(params[:id]) : Category.new + @category.attributes = params[:category] + if request.post? + respond_to do |format| + format.html { save_category } + format.js do + @category.save + @article = Article.new + @article.categories << @category + return render(:partial => 'admin/content/categories') + end end + return end - return + render 'new' + rescue + render 'new' end - render 'new' end def save_category diff --git a/db/converters/README b/db/converters/README deleted file mode 100644 index 60417c7b19..0000000000 --- a/db/converters/README +++ /dev/null @@ -1,14 +0,0 @@ -These are converters for migrating from other blog systems to Typo. In -general, you're best off using the converter that best-matches your blog -system, and then falling back to the RSS or Feed converter if the others fail. -These converters aren't always well tested, so please back up your data before -converting, and please file bugs at http://www.typosphere.org/trac. - -Available converters: - -* mt3.rb: Converts from Movable Type 3.x -* s9y.rb: Converts from Serendipity (aka s9y) -* textpattern.rb: Converts from TextPattern -* feed.rb: Converts from any RSS or Atom feed. Requires the 'feed_tools' gem. - -For Wordpress and Dotclear 1.2 and Dotclear 2 conversion, please use the converters in vendors/plugins \ No newline at end of file diff --git a/db/converters/feed.rb b/db/converters/feed.rb deleted file mode 100644 index 683acacba3..0000000000 --- a/db/converters/feed.rb +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env ruby - -# RSS 0.2/2.0/Atom converter to typo by Lennon Day-Reynolds -# Shamelessly copied from RSS-only converter by Chris Lee - -require File.dirname(__FILE__) + '/../../config/environment' -require 'optparse' -begin - require 'feed_tools' -rescue LoadError - STDERR.puts <<-EOF -This converter requires feedtools to be installed. -Please run `gem install feedtools` and try again. -EOF - exit 1 -end - -class FeedMigrate - attr_accessor :options - - def initialize - self.options = {} - self.parse_options - self.convert_entries - end - - def convert_entries - feed = FeedTools::Feed.open(self.options[:url]) - puts "Converting #{feed.items.length} entries..." - feed.items.each do |item| - puts "Converting '#{item.title}'" - a = Article.new - a.author = self.options[:author] - a.title = item.title - a.body = item.description - a.created_at = item.published - a.save - end - end - - def parse_options - OptionParser.new do |opt| - opt.banner = 'Usage: feed.rb [options]' - - opt.on('-a', '--author AUTHOR', 'Username of author in typo') do |a| - self.options[:author] = a - end - - opt.on('-u', '--url URL', 'URL of RSS feed to import.') do |u| - self.options[:url] = u - end - - opt.on_tail('-h', '--help', 'Show this message.') do - puts opt - exit - end - - opt.parse!(ARGV) - end - - unless self.options.include?(:author) and self.options.include?(:url) - puts 'See feed.rb --help for help.' - exit - end - end -end - -FeedMigrate.new diff --git a/db/converters/mt3.rb b/db/converters/mt3.rb deleted file mode 100755 index 718e486180..0000000000 --- a/db/converters/mt3.rb +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env ruby - -# MovableType 3.x converter for typo by Patrick Lenz -# -# MAKE BACKUPS OF EVERYTHING BEFORE RUNNING THIS SCRIPT! -# THIS SCRIPT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND - -require File.dirname(__FILE__) + '/../../config/environment' -require 'optparse' - -class MTMigrate - attr_accessor :options - - def initialize - self.options = {} - self.parse_options - self.convert_categories - self.convert_entries - self.convert_prefs - end - - def convert_categories - mt_categories = ActiveRecord::Base.connection.select_all(%{ - SELECT category_label AS name - FROM `#{self.options[:mt_db]}`.mt_category - WHERE category_blog_id = '#{self.options[:blog_id]}' - }) - - puts "Converting #{mt_categories.size} categories.." - - mt_categories.each do |cat| - Category.create(cat) unless Category.find_by_name(cat['name']) - end - end - - def convert_entries - default_filter = translate_filter ActiveRecord::Base.connection.select_all(%{ - SELECT - blog_convert_paras - FROM `#{self.options[:mt_db]}`.mt_blog - WHERE blog_id = '#{self.options[:blog_id]}' - })[0]["blog_convert_paras"] - - mt_entries = ActiveRecord::Base.connection.select_all(%{ - SELECT - entry_id, - entry_allow_comments AS allow_comments, - entry_allow_pings AS allow_pings, - entry_title AS title, - entry_text AS body, - entry_text_more AS extended, - entry_excerpt AS excerpt, - entry_convert_breaks AS convert_breaks, - entry_keywords AS keywords, - entry_created_on AS created_at, - entry_modified_on AS updated_at, - author_name AS author - FROM `#{self.options[:mt_db]}`.mt_entry, `#{self.options[:mt_db]}`.mt_author - WHERE entry_blog_id = '#{self.options[:blog_id]}' - AND author_id = entry_author_id - }) - - puts "Converting #{mt_entries.size} entries.." - - mt_entries.each do |entry| - a = Article.new - a.attributes = entry.reject { |k,v| k =~ /entry_id|convert_breaks/ } - - if entry["convert_breaks"] == "__default__" - a.text_filter = default_filter - else - a.text_filter = translate_filter entry["convert_breaks"] - end - - a.save - - # Fetch category assignments - ActiveRecord::Base.connection.select_all(%{ - SELECT category_label, placement_is_primary - FROM `#{self.options[:mt_db]}`.mt_category, `#{self.options[:mt_db]}`.mt_entry, `#{self.options[:mt_db]}`.mt_placement - WHERE entry_id = #{entry['entry_id']} - AND category_id = placement_category_id - AND entry_id = placement_entry_id - }).each do |c| - a.categories.push_with_attributes(Category.find_by_name(c['category_label']), :is_primary => c['placement_is_primary']) - end - - # Fetch comments - ActiveRecord::Base.connection.select_all(%{ - SELECT - comment_author AS author, - comment_email AS email, - comment_url AS url, - comment_text AS body, - comment_created_on AS created_at, - comment_modified_on AS updated_at - FROM `#{self.options[:mt_db]}`.mt_comment - WHERE comment_entry_id = #{entry['entry_id']} - }).each do |c| - a.comments.create(c) - end - - # Fetch trackbacks - ActiveRecord::Base.connection.select_all(%{ - SELECT - tbping_title AS title, - tbping_excerpt AS excerpt, - tbping_source_url AS url, - tbping_ip AS ip, - tbping_blog_name AS blog_name, - tbping_created_on AS created_at, - tbping_modified_on AS updated_at - FROM `#{self.options[:mt_db]}`.mt_tbping, `#{self.options[:mt_db]}`.mt_trackback - WHERE tbping_tb_id = trackback_id - AND trackback_entry_id = #{entry['entry_id']} - }).each do |tb| - a.trackbacks.create(tb) - end - end - end - - def convert_prefs - puts "Converting prefs" - - ActiveRecord::Base.connection.select_one(%{ - SELECT - blog_name, - blog_allow_comments_default AS default_allow_comments, - blog_allow_pings_default AS default_allow_pings - FROM `#{self.options[:mt_db]}`.mt_blog - WHERE blog_id = '#{self.options[:blog_id]}' - }).each do |pref_name, pref_value| - begin - Setting.find_by_name(pref_name).update_attribute("value", pref_value) - rescue - Setting.create({'name' => pref_name, 'value' => pref_value}) - end - end - - end - - def parse_options - OptionParser.new do |opt| - opt.banner = "Usage: mt3.rb [options]" - - opt.on('--blog-id BLOGID', Integer, 'Blog ID to import from.') { |i| self.options[:blog_id] = i } - opt.on('--db DBNAME', String, 'Movable Type database name.') { |d| self.options[:mt_db] = d } - - opt.on_tail('-h', '--help', 'Show this message.') do - puts opt - exit - end - - opt.parse!(ARGV) - end - - unless self.options.include?(:blog_id) and self.options.include?(:mt_db) - puts "See mt3.rb --help for help." - exit - end - end - - def translate_filter(input) - return case input - when /textile/ then 'textile' - when /markdown/ then 'markdown' - else nil - end - end -end - -MTMigrate.new diff --git a/db/converters/rss.rb b/db/converters/rss.rb deleted file mode 100644 index 33cdcecf60..0000000000 --- a/db/converters/rss.rb +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby - -# RSS 0.9/2.0 converter for typo by Chris Lee -# -# No need to make a backup of the original blog, really. This takes a URL for a -# read-only import, so there's not really any chance of it munging the original -# blog's data, unless somehow an HTTP GET causes your blog server to ignite. -# -# Even so, this script is still PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. - -require File.dirname(__FILE__) + '/../../config/environment' -require 'optparse' -require 'net/http' -require 'rss/2.0' - -class RSSMigrate - attr_accessor :options - - def initialize - self.options = {} - self.parse_options - self.convert_entries - end - - def convert_entries - feed = Net::HTTP.get(URI.parse(self.options[:url])) - rss = RSS::Parser.parse(feed) - puts "Converting #{rss.items.length} entries..." - rss.items.each do |item| - puts "Converting '#{item.title}'" - a = Article.new - a.author = self.options[:author] - a.title = item.title - a.body = item.description - a.created_at = item.pubDate - a.save - end - end - - def parse_options - OptionParser.new do |opt| - opt.banner = 'Usage: rss.rb [options]' - - opt.on('-a', '--author AUTHOR', 'Username of author in typo') do |a| - self.options[:author] = a - end - - opt.on('-u', '--url URL', 'URL of RSS feed to import.') do |u| - self.options[:url] = u - end - - opt.on_tail('-h', '--help', 'Show this message.') do - puts opt - exit - end - - opt.parse!(ARGV) - end - - unless self.options.include?(:author) and self.options.include?(:url) - puts 'See rss.rb --help for help.' - exit - end - end -end - -RSSMigrate.new diff --git a/db/converters/s9y.rb b/db/converters/s9y.rb deleted file mode 100755 index 7ab2e28162..0000000000 --- a/db/converters/s9y.rb +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env ruby - -# Serendipity (S9Y) 0.8.x converter for typo by Jochen Schalanda -# heavily based on the Wordpress 1.5x converter by Patrick Lenz -# -# MAKE BACKUPS OF EVERYTHING BEFORE RUNNING THIS SCRIPT! -# THIS SCRIPT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND -# -# -# SECURITY NOTICE: -# -# Migrated users will have the default password "password", since the -# MD5 hashes of S9Y cannot be converted to salted SHA1 hashes which are -# used by Typo. -# - -require File.dirname(__FILE__) + '/../../config/environment' -require 'optparse' - -class S9YMigrate - attr_accessor :options - - def initialize - self.options = {} - self.parse_options - self.convert_users - self.convert_categories - self.convert_entries - self.convert_prefs - end - - def convert_categories - s9y_categories = ActiveRecord::Base.connection.select_all(%{ - SELECT category_name AS name - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}category` - }) - - puts "Converting #{s9y_categories.size} categories.." - - s9y_categories.each do |cat| - Category.create(cat) unless Category.find_by_name(cat['name']) - end - end - - def convert_entries - s9y_entries = ActiveRecord::Base.connection.select_all(%{ - SELECT - id, - (CASE allow_comments WHEN 'true' THEN '1' ELSE '0' END) AS allow_comments, - title, - body, - extended, - FROM_UNIXTIME(timestamp) AS created_at, - FROM_UNIXTIME(last_modified) AS updated_at, - author, - authorid AS user_id, - (CASE isdraft WHEN 'true' THEN '0' ELSE '1' END) AS published - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}entries` - }) - - puts "Converting #{s9y_entries.size} entries.." - - s9y_entries.each do |entry| - a = Article.new - a.attributes = entry.reject { |k,v| k =~ /^(id)/ } - a.save - - # Fetch category assignments - ActiveRecord::Base.connection.select_all(%{ - SELECT category_name - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}category`, `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}entrycat` - WHERE entryid = #{entry['id']} - AND `#{self.options[:s9y_prefix]}entrycat`.categoryid = `#{self.options[:s9y_prefix]}category`.categoryid - }).each do |c| - a.categories.push_with_attributes(Category.find_by_name(c['category_name']), :is_primary => 0) - end - - # Fetch comments - ActiveRecord::Base.connection.select_all(%{ - SELECT - author, - email, - url, - body, - FROM_UNIXTIME(timestamp) AS created_at, - ip - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}comments` - WHERE id = #{entry['id']} - AND type != 'TRACKBACK' - AND status = 'approved' - }).each do |c| - a.comments.create(c) - end - - # Fetch trackbacks - ActiveRecord::Base.connection.select_all(%{ - SELECT - author AS blog_name, - url, - title, - body AS excerpt, - FROM_UNIXTIME(timestamp) AS created_at, - ip - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}comments` - WHERE entry_id = #{entry['id']} - AND type = 'TRACKBACK' - AND status = 'approved' - }).each do |c| - a.trackbacks.create(c) - end - - end - end - - def convert_prefs - puts "Converting prefs" - - ActiveRecord::Base.connection.select_all(%{ - SELECT - (CASE name - WHEN 'blogTitle' THEN 'blog_name' - WHEN 'blogDescription' THEN 'blog_subtitle' - END) AS name, - value - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}config` - WHERE name IN ('blogTitle', 'blogDescription') - }).each do |pref| - begin - Setting.find_by_name(pref['name']).update_attribute("value", pref['value']) - rescue - Setting.create(pref) - end - end - end - -def convert_users - puts "Converting users" - puts "** all users will have the default password \"password\" **" - puts "** you should change it as soon as possible! **" - - ActiveRecord::Base.connection.select_all(%{ - SELECT - realname AS name, - username AS login, - email - FROM `#{self.options[:s9y_db]}`.`#{self.options[:s9y_prefix]}authors` - }).each do |user| - u = User.new - u.attributes = user - u.password = "password" - u.save - end - end - - def parse_options - OptionParser.new do |opt| - opt.banner = "Usage: s9y.rb [options]" - - opt.on('--db DBNAME', String, 'S9Y database name.') { |d| self.options[:s9y_db] = d } - opt.on('--prefix PREFIX', String, 'S9Y table prefix (defaults to empty string).') { |d| self.options[:s9y_prefix] = d } - - opt.on_tail('-h', '--help', 'Show this message.') do - puts opt - exit - end - - opt.parse!(ARGV) - end - - unless self.options.include?(:s9y_db) - puts "See s9y.rb --help for help." - exit - end - - unless self.options.include?(:s9y_prefix) - self.options[:s9y_prefix] = "" - end - - end -end - -S9YMigrate.new diff --git a/db/converters/textpattern.rb b/db/converters/textpattern.rb deleted file mode 100755 index 9f1e9ce0da..0000000000 --- a/db/converters/textpattern.rb +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env ruby - -# TextPattern 1.x converter for typo by Patrick Lenz -# -# MAKE BACKUPS OF EVERYTHING BEFORE RUNNING THIS SCRIPT! -# THIS SCRIPT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND - -require File.dirname(__FILE__) + '/../../config/environment' -require 'optparse' - -class TXPMigrate - attr_accessor :options - - def initialize - self.options = {} - self.parse_options - self.convert_categories - self.convert_entries - self.convert_prefs - end - - def convert_categories - txp_categories = ActiveRecord::Base.connection.select_all(%{ - SELECT name - FROM `#{self.options[:txp_db]}`.`#{self.options[:txp_pfx]}`txp_category - WHERE parent = 'root' - AND type = 'article' - }) - - puts "Converting #{txp_categories.size} categories.." - - txp_categories.each do |cat| - Category.create(cat) unless Category.find_by_name(cat['name']) - end - end - - def convert_entries - txp_entries = ActiveRecord::Base.connection.select_all(%{ - SELECT - ID, - Annotate AS allow_comments, - 1 AS allow_pings, - Title AS title, - (CASE LENGTH(Body) WHEN 0 THEN Excerpt ELSE Body END) AS body, - Body_html AS body_html, - Excerpt AS excerpt, - Keywords AS keywords, - Posted AS created_at, - LastMod AS updated_at, - AuthorID AS author, - (CASE textile_body WHEN '1' THEN 'textile' ELSE 'none' END) AS text_filter, - (CASE Status WHEN '1' THEN '0' ELSE '1' END) AS published, - Category1, Category2 - FROM `#{self.options[:txp_db]}`..`#{self.options[:txp_pfx]}`textpattern - }) - - puts "Converting #{txp_entries.size} entries.." - - txp_entries.each do |entry| - a = Article.new - a.attributes = entry.reject { |k,v| k =~ /^(Category|ID)/ } - a.save - - # Assign categories - puts "Assign primary category for entry #{entry['ID']}" - a.categories.push_with_attributes(Category.find_by_name(entry['Category1']), :is_primary => 1) rescue nil - puts "Assign secondary category for entry #{entry['ID']}" - a.categories.push_with_attributes(Category.find_by_name(entry['Category2']), :is_primary => 0) rescue nil - - # Fetch comments - ActiveRecord::Base.connection.select_all(%{ - SELECT - name AS author, - email AS email, - web AS url, - message AS body, - message as body_html, - posted AS created_at, - ip AS ip - FROM `#{self.options[:txp_db]}`..`#{self.options[:txp_pfx]}`txp_discuss - WHERE parentid = #{entry['ID']} - }).each do |c| - a.comments.create(c) - end - - end - end - - def convert_prefs - puts "Converting prefs" - - ActiveRecord::Base.connection.select_all(%{ - SELECT - (CASE name - WHEN 'sitename' THEN 'blog_name' - WHEN 'comments_on_default' THEN 'default_allow_comments' - WHEN 'use_textile' THEN 'text_filter' - END) AS name, - val AS value - FROM `#{self.options[:txp_db]}`..`#{self.options[:txp_pfx]}`txp_prefs - WHERE name IN ('sitename', 'comments_on_default', 'use_textile') - }).each do |pref| - if pref['name'] == "text_filter" and pref['value'].to_i > 0 - pref['value'] = 'textile' - end - - begin - Setting.find_by_name(pref['name']).update_attribute("value", pref['value']) - rescue - Setting.create(pref) - end - end - end - - def parse_options - OptionParser.new do |opt| - opt.banner = "Usage: textpattern.rb [options]" - - opt.on('--db DBNAME', String, 'Text Pattern database name.') { |d| self.options[:txp_db] = d } - opt.on('--pf PREFIX', String, 'Textpattern table prefix.') { |p| self.options[:txp_pfx] = p } - - opt.on_tail('-h', '--help', 'Show this message.') do - puts opt - exit - end - - opt.parse!(ARGV) - end - - unless self.options.include?(:txp_db) - puts "See textpattern.rb --help for help." - exit - end - end -end - -TXPMigrate.new diff --git a/db/migrate/001_initial_schema.rb b/db/migrate/001_initial_schema.rb deleted file mode 100644 index b05ef815c0..0000000000 --- a/db/migrate/001_initial_schema.rb +++ /dev/null @@ -1,145 +0,0 @@ -class Bare1Category < ActiveRecord::Base - include BareMigration -end - -class Bare1Article < ActiveRecord::Base - include BareMigration -end - -class Bare1ArticlesCategory < ActiveRecord::Base - include BareMigration -end - -class InitialSchema < ActiveRecord::Migration - def self.up - ActiveRecord::Base.transaction do - create_table :users do |t| - t.column :login, :string - t.column :password, :string - end - - create_table :articles do |t| - t.column :title, :string - t.column :author, :string - t.column :body, :text - t.column :body_html, :text - t.column :extended, :text - t.column :excerpt, :text - t.column :keywords, :string - t.column :allow_comments, :integer - t.column :allow_pings, :integer - t.column :published, :integer, :default => 1 - t.column :text_filter, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :extended_html, :text - t.column :permalink, :string - end - - add_index :articles, :permalink - - create_table :categories do |t| - t.column :name, :string - t.column :position, :integer - end - - category = Bare1Category.create(:name => 'General', - :position => 1 - ) - - article = Bare1Article.create(:title=>'Hello World!', - :author=>'Mr Typo', - :body=>'Welcome to Typo. This is your first article. Edit or delete it, then start blogging!', - :allow_comments => 1, - :allow_pings =>1, - :published => 1, - :permalink => 'hello-world' - ) - - create_table :blacklist_patterns do |t| - t.column :type, :string - t.column :pattern, :string - end - - add_index :blacklist_patterns, :pattern - - create_table :comments do |t| - t.column :article_id, :integer - t.column :title, :string - t.column :author, :string - t.column :email, :string - t.column :url, :string - t.column :ip, :string - t.column :body, :text - t.column :body_html, :text - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - add_index :comments, :article_id - - create_table :pings do |t| - t.column :article_id, :integer - t.column :url, :string - t.column :created_at, :datetime - end - - add_index :pings, :article_id - - create_table :resources do |t| - t.column :size, :integer - t.column :filename, :string - t.column :mime, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - create_table :sessions do |t| - t.column :sessid, :string - t.column :data, :text - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - create_table :settings do |t| - t.column :name, :string - t.column :value, :string - t.column :position, :integer - end - - create_table :trackbacks do |t| - t.column :article_id, :integer - t.column :blog_name, :string - t.column :title, :string - t.column :excerpt, :string - t.column :url, :string - t.column :ip, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - add_index :trackbacks, :article_id - end - end - - def self.down - ActiveRecord::Base.transaction do - remove_index :articles, :permalink - remove_index :blacklist_patterns, :pattern - remove_index :comments, :article_id - remove_index :pings, :article_id - remove_index :trackbacks, :article_id - - drop_table :users - drop_table :articles - drop_table :categories - drop_table :blacklist_patterns - drop_table :comments - drop_table :pings - drop_table :resources - drop_table :sessions - drop_table :settings - drop_table :trackbacks - end - end -end diff --git a/db/migrate/002_add_user_email.rb b/db/migrate/002_add_user_email.rb deleted file mode 100644 index c8bdff899a..0000000000 --- a/db/migrate/002_add_user_email.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddUserEmail < ActiveRecord::Migration - class BareUser < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update([:add_column, BareUser, :email, :text], - [:add_column, BareUser, :name, :text]) do |u| - u.name = u.login - end - end - - def self.down - remove_column :users, :email - remove_column :users, :name - end -end diff --git a/db/migrate/003_add_article_user_id.rb b/db/migrate/003_add_article_user_id.rb deleted file mode 100644 index fd348d2001..0000000000 --- a/db/migrate/003_add_article_user_id.rb +++ /dev/null @@ -1,31 +0,0 @@ -class AddArticleUserId < ActiveRecord::Migration - class BareArticle < ActiveRecord::Base - include BareMigration - end - - class BareUser < ActiveRecord::Base - include BareMigration - end - - def self.up - say "Linking article authors to users" - modify_tables_and_update(:add_column, BareArticle, :user_id, :integer) do |art| - art.user_id = (BareUser.find_by_name(art.author).id rescue nil) - end - user_first = BareUser.first - if user_first.nil? - user_id = 1 - else - user_id = user_first.id - end - - BareArticle.find(:all, :conditions => 'user_id IS NULL').each do |art| - art.user_id = user_id - art.save! - end - end - - def self.down - remove_column :articles, :user_id - end -end diff --git a/db/migrate/004_add_sidebars.rb b/db/migrate/004_add_sidebars.rb deleted file mode 100644 index 62c1cc6d05..0000000000 --- a/db/migrate/004_add_sidebars.rb +++ /dev/null @@ -1,45 +0,0 @@ -class Bare4Sidebar < ActiveRecord::Base - include BareMigration - - # there's technically no need for these serialize declaration because in - # this script active_config and staged_config will always be NULL anyway. - serialize :active_config - serialize :staged_config -end - -class AddSidebars < ActiveRecord::Migration - def self.up - say "Creating sidebars" - Bare4Sidebar.transaction do - create_table :sidebars do |t| - t.column :controller, :string - t.column :active_position, :integer - t.column :active_config, :text - t.column :staged_position, :integer - t.column :staged_config, :text - end - - Bare4Sidebar.create(:active_position=>0, :controller=>'page', :active_config=>'--- !map:HashWithIndifferentAccess - maximum_pages: "10"') - Bare4Sidebar.create(:active_position=>1, :controller=>'category', :active_config=>'--- !map:HashWithIndifferentAccess - empty: false - count: true') - Bare4Sidebar.create(:active_position=>2, :controller=>'archives', :active_config=>'--- !map:HashWithIndifferentAccess - show_count: true - count: "10"') - Bare4Sidebar.create(:active_position=>3, :controller=>'static', :active_config=>'--- !map:HashWithIndifferentAccess - body: "\n" - title: Links' - ) - Bare4Sidebar.create(:active_position=>4, :controller=>'meta', :active_config=>'--- !map:HashWithIndifferentAccess - title: Meta') - end - end - - def self.down - drop_table :sidebars - end -end - - diff --git a/db/migrate/005_add_cache_table.rb b/db/migrate/005_add_cache_table.rb deleted file mode 100644 index ade663e3d5..0000000000 --- a/db/migrate/005_add_cache_table.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'fileutils' - -class AddCacheTable < ActiveRecord::Migration - def self.up - FileUtils.rm_rf("public/articles") - FileUtils.rm_rf("public/xml") - FileUtils.rm_rf("public/index.html") - create_table :page_caches do |t| - t.column :name, :string - end - add_index :page_caches, :name - end - - def self.down - # TODO: how can this script sweep the page cache? - # Like PageCache.sweep('/') but without calling a model? - remove_index :page_caches, :name - drop_table :page_caches - end -end diff --git a/db/migrate/006_add_pages.rb b/db/migrate/006_add_pages.rb deleted file mode 100644 index 8b21988797..0000000000 --- a/db/migrate/006_add_pages.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddPages < ActiveRecord::Migration - def self.up - create_table :pages do |t| - t.column :name, :string - t.column :user_id, :integer - t.column :body, :text - t.column :body_html, :text - t.column :text_filter, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - end - - def self.down - drop_table :pages - end -end diff --git a/db/migrate/007_add_permalink.rb b/db/migrate/007_add_permalink.rb deleted file mode 100644 index 7ea756b967..0000000000 --- a/db/migrate/007_add_permalink.rb +++ /dev/null @@ -1,36 +0,0 @@ -class AddPermalink < ActiveRecord::Migration - class BareArticle < ActiveRecord::Base - include BareMigration - - def stripped_title(title) - # this is a copynpaste of the routine in article.rb - # so the one in article.rb can change w/o breaking this. - self.title.gsub(/<[^>]*>/,'').to_url - end - end - - class BareCategory < ActiveRecord::Base - include BareMigration - - def stripped_name - # copynpaste from category.rb - self.name.to_url - end - end - - def self.up - say "Adding categories permalink" - modify_tables_and_update([:add_column, BareCategory, :permalink, :string], - [:add_index, BareCategory, :permalink]) do - BareCategory.find_and_update {|c| c.permalink ||= c.stripped_name } - BareArticle.find_and_update {|a| a.permalink ||= a.stripped_title } - end - end - - - def self.down - say "Removing categories permalink" - remove_index :categories, :permalink - remove_column :categories, :permalink - end -end diff --git a/db/migrate/008_add_page_title.rb b/db/migrate/008_add_page_title.rb deleted file mode 100644 index 9d7f642ca9..0000000000 --- a/db/migrate/008_add_page_title.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Bare8Page < ActiveRecord::Base - include BareMigration -end - -class AddPageTitle < ActiveRecord::Migration - def self.up - add_column :pages, :title, :string - - Bare8Page.create(:name=>"about", - :title=>"about", - :user_id=>1, - :body=>"This is an example of a Typo page. You can edit this to write information about yourself or your site so readers know who you are. You can create as many pages as this one as you like and manage all of your content inside Typo." - ) - - end - - def self.down - remove_column :pages, :title - end -end diff --git a/db/migrate/009_add_article_guid.rb b/db/migrate/009_add_article_guid.rb deleted file mode 100644 index 46ccf35915..0000000000 --- a/db/migrate/009_add_article_guid.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddArticleGuid < ActiveRecord::Migration - def self.up - # the guid itself will be added later in the migration - add_column :articles, :guid, :string - end - - def self.down - remove_column :articles, :guid - end -end diff --git a/db/migrate/010_add_tags.rb b/db/migrate/010_add_tags.rb deleted file mode 100644 index 0bdace77a3..0000000000 --- a/db/migrate/010_add_tags.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddTags < ActiveRecord::Migration - def self.up - create_table :tags do |t| - t.column :name, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - create_table :articles_tags, :id => false do |t| - t.column :article_id, :integer - t.column :tag_id, :integer - end - end - - def self.down - drop_table :tags - drop_table :articles_tags - end -end diff --git a/db/migrate/011_add_article_id.rb b/db/migrate/011_add_article_id.rb deleted file mode 100644 index e5ba373f87..0000000000 --- a/db/migrate/011_add_article_id.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Bare11Resource < ActiveRecord::Base - include BareMigration -end - -class AddArticleId < ActiveRecord::Migration - def self.up - Dir.mkdir("#{::Rails.root.to_s}/public/files") unless File.directory?("#{::Rails.root.to_s}/public/files") - add_column :resources, :article_id, :integer - Bare11Resource.reset_column_information - # TODO: resources probably don't get migrated properly. - # Resource.find(:all) { |r| r.update } - end - - def self.down - remove_column :resources, :article_id - end -end diff --git a/db/migrate/012_enlarge_settings.rb b/db/migrate/012_enlarge_settings.rb deleted file mode 100644 index 4a6656a2c5..0000000000 --- a/db/migrate/012_enlarge_settings.rb +++ /dev/null @@ -1,11 +0,0 @@ -class EnlargeSettings < ActiveRecord::Migration - def self.up - change_column :settings, :name, :string, :limit => 255 - change_column :settings, :value, :string, :limit => 255 - end - - def self.down - change_column :settings, :name, :string, :limit => 40 - change_column :settings, :value, :string, :limit => 40 - end -end diff --git a/db/migrate/013_add_textfilters.rb b/db/migrate/013_add_textfilters.rb deleted file mode 100644 index 5917802fac..0000000000 --- a/db/migrate/013_add_textfilters.rb +++ /dev/null @@ -1,33 +0,0 @@ -class Bare13TextFilter < ActiveRecord::Base - include BareMigration -end - -class AddTextfilters < ActiveRecord::Migration - def self.up - say "Adding TextFilters table" - Bare13TextFilter.transaction do - create_table :text_filters do |t| - t.column :name, :string - t.column :description, :string - t.column :markup, :string - t.column :filters, :text - t.column :params, :text - end - - Bare13TextFilter.create(:name => 'none', :description => 'None', - :markup => 'none', :filters => [], :params => {}) - Bare13TextFilter.create(:name => 'markdown', :description => 'Markdown', - :markup => "markdown", :filters => [], :params => {}) - Bare13TextFilter.create(:name => 'smartypants', :description => 'SmartyPants', - :markup => 'none', :filters => [:smartypants], :params => {}) - Bare13TextFilter.create(:name => 'markdown smartypants', :description => 'Markdown with SmartyPants', - :markup => 'markdown', :filters => [:smartypants], :params => {}) - Bare13TextFilter.create(:name => 'textile', :description => 'Textile', - :markup => 'textile', :filters => [], :params => {}) - end - end - - def self.down - drop_table :text_filters - end -end diff --git a/db/migrate/014_move_text_filter_to_text_filter_id.rb b/db/migrate/014_move_text_filter_to_text_filter_id.rb deleted file mode 100644 index 7c8875d692..0000000000 --- a/db/migrate/014_move_text_filter_to_text_filter_id.rb +++ /dev/null @@ -1,43 +0,0 @@ -class MoveTextFilterToTextFilterId < ActiveRecord::Migration - class BareArticle < ActiveRecord::Base - include BareMigration - end - - class BarePage < ActiveRecord::Base - include BareMigration - end - - class BareTextFilter < ActiveRecord::Base - include BareMigration - end - - def self.up - say "Converting Article and Page to use text_filter_id instead of text_filter" - id_of = BareTextFilter.find(:all).inject({}) {|h, f| h.merge({ h[f.name] => f.id }) } - - modify_tables_and_update([:add_column, BareArticle, :text_filter_id, :integer], - [:add_column, BarePage, :text_filter_id, :integer]) do - (BareArticle.find(:all) + BarePage.find(:all)).each do |content| - content.text_filter_id = id_of[content.attributes['text_filter']] - content.save! - end - end - remove_column :articles, :text_filter - remove_column :pages, :text_filter - end - - def self.down - say "Dropping text_filter_id in favor of text_filter" - name_of = BareTextFilter.find(:all).inject({}) {|h, f| h.merge({ h[f.id] => f.name })} - - modify_tables_and_update([:add_column, BareArticle, :text_filter, :string], - [:add_column, BarePage, :text_filter, :string]) do - (BareArticle.find(:all) + BarePage.find(:all)).each do |content| - content.attributes['text_filter'] = name_of[content.text_filter_id] - content.save! - end - end - remove_column :articles, :text_filter_id - remove_column :pages, :text_filter_id - end -end diff --git a/db/migrate/015_convert_mysql_to_innodb.rb b/db/migrate/015_convert_mysql_to_innodb.rb deleted file mode 100644 index f88b1d2ee5..0000000000 --- a/db/migrate/015_convert_mysql_to_innodb.rb +++ /dev/null @@ -1,19 +0,0 @@ -class ConvertMysqlToInnodb < ActiveRecord::Migration - def self.up - config = ActiveRecord::Base.configurations - begin - say "Migrating all existing tables to InnoDB" - schema = [] - select_all('SHOW TABLES').map do |table| - "ALTER TABLE #{table.to_a.first.last} ENGINE=InnoDB" - end - schema.each { |line| execute line } - end if config[::Rails.env]['adapter'] == 'mysql' unless $schema_generator - end - - def self.down - # don't do anything - # this is a one-way migration, but it's not "irreversable" - # because it doesn't change any code logic - end -end diff --git a/db/migrate/016_fix_is_primary_postgres.rb b/db/migrate/016_fix_is_primary_postgres.rb deleted file mode 100644 index ee22b68a7d..0000000000 --- a/db/migrate/016_fix_is_primary_postgres.rb +++ /dev/null @@ -1,16 +0,0 @@ -# The PostgreSQL schema for 2.0.6 differs from the MySQL schema-- -# pgsql had articles_categories.primary_item, while mysql had -# articles_categories.is_primary. More modenen schemas all have is_primary. -# This will break Postgres upgrades from 2.0.6, and apparently it bit #375. - -# Since we've removed the pointless articles_categories table from the migration -# we don't need to fix it up :) - -class FixIsPrimaryPostgres < ActiveRecord::Migration - def self.up - - end - - def self.down - end -end diff --git a/db/migrate/017_add_comment_user_id.rb b/db/migrate/017_add_comment_user_id.rb deleted file mode 100644 index d4f4820974..0000000000 --- a/db/migrate/017_add_comment_user_id.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AddCommentUserId < ActiveRecord::Migration - class BareComment < ActiveRecord::Base - include BareMigration - end - - class BareUser < ActiveRecord::Base - include BareMigration - end - - def self.up - id_for_address = BareUser.find(:all).inject({}) do |h, u| - h.merge({ u.email => u.id }) - end - - modify_tables_and_update(:add_column, BareComment, :user_id, :integer) do |c| - c.user_id = id_for_address[c.email] - end - end - - def self.down - remove_column :comments, :user_id - end -end diff --git a/db/migrate/018_add_guids.rb b/db/migrate/018_add_guids.rb deleted file mode 100644 index 10fd1871b6..0000000000 --- a/db/migrate/018_add_guids.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddGuids < ActiveRecord::Migration - def self.up - say "Adding GUIDs to Comments and Trackbacks" - - modify_tables_and_update([:add_column, :comments, :guid, :string], - [:add_column, :trackbacks, :guid, :string]) - end - - def self.down - remove_column :comments, :guid - remove_column :trackbacks, :guid - end -end diff --git a/db/migrate/019_add_whiteboards_to_content.rb b/db/migrate/019_add_whiteboards_to_content.rb deleted file mode 100644 index a368b43369..0000000000 --- a/db/migrate/019_add_whiteboards_to_content.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddWhiteboardsToContent < ActiveRecord::Migration - def self.up - say "Adding whiteboard to articles, comments and pages" - modify_tables_and_update([:add_column, :articles, :whiteboard, :text], - [:add_column, :comments, :whiteboard, :text], - [:add_column, :pages, :whiteboard, :text]) - end - - def self.down - say "Removing whiteboard from articles, comments and pages" - remove_column :articles, :whiteboard - remove_column :comments, :whiteboard - remove_column :pages, :whiteboard - end -end diff --git a/db/migrate/020_superclass_articles.rb b/db/migrate/020_superclass_articles.rb deleted file mode 100644 index a95cf7a9f8..0000000000 --- a/db/migrate/020_superclass_articles.rb +++ /dev/null @@ -1,168 +0,0 @@ -class Bare20Article < ActiveRecord::Base - include BareMigration - - # need to point the primary key somewhere else so we can manually - # set this field for each article. - #set_primary_key :boguskey -end - -class Bare20Content < ActiveRecord::Base - include BareMigration - -# From active_record/base.rb: "the primary key and inheritance column can -# never be set by mass-assignment for security reasons." Because this -# script wants to set 'id' and 'type', we need to fool activerecord by -# setting them to bogus values. - set_inheritance_column :bogustype - #set_primary_key :boguskey -end - -class SuperclassArticles < ActiveRecord::Migration - def self.config - ActiveRecord::Base.configurations - end - - def self.up - say "Merging Articles into Contents table" - - # Make sure our index is in a known state - # Comment because in migration 001, there are already a creation of this index - #add_index :articles, :permalink rescue nil - - Bare20Article.transaction do - create_table :contents do |t| -# ActiveRecord::Base.connection.send(:create_table, [:contents]) do |t| - t.column :type, :string - t.column :title, :string - t.column :author, :string - t.column :body, :text - t.column :body_html, :text - t.column :extended, :text - t.column :excerpt, :text - t.column :keywords, :string - t.column :allow_comments, :integer - t.column :allow_pings, :integer - t.column :published, :integer, :default => 1 - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :extended_html, :text - t.column :user_id, :integer - t.column :permalink, :string - t.column :guid, :string - t.column :text_filter_id, :integer - t.column :whiteboard, :text - end - - if config[::Rails.env]['adapter'] == 'postgresql' - execute "select nextval('contents_id_seq')" - end - - if not $schema_generator - - Bare20Article.find(:all).each do |a| - t = Bare20Content.new( - :type => 'Article', - :title => a.title, - :author => a.author, - :body => a.body, - :body_html => a.body_html, - :extended => a.extended, - :excerpt => a.excerpt, - :keywords => a.keywords, - :allow_comments => a.allow_comments, - :allow_pings => a.allow_pings, - :published => a.published, - :created_at => a.created_at, - :updated_at => a.updated_at, - :extended_html => a.extended_html, - :user_id => a.user_id, - :permalink => a.permalink, - :guid => a.guid, - :text_filter_id => a.text_filter_id, - :whiteboard => a.whiteboard) - # can't use id accessor because it uses the bogus primary key - t.send(:write_attribute, :id, a.send(:read_attribute, :id)) - t.save! - end - - if config[::Rails.env]['adapter'] == 'postgresql' - say "Resetting PostgreSQL sequences", true - execute "select setval('contents_id_seq',max(id)) from contents" - execute "select nextval('contents_id_seq')" - end - end - - remove_index :articles, :permalink - drop_table :articles - end - end - - def self.down - Bare20Content.transaction do - say "Recreating Articles from Contents table." - - create_table :articles do |t| - t.column :title, :string - t.column :author, :string - t.column :body, :text - t.column :body_html, :text - t.column :extended, :text - t.column :excerpt, :text - t.column :keywords, :string - t.column :allow_comments, :integer - t.column :allow_pings, :integer - t.column :published, :integer, :default => 1 - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :extended_html, :text - t.column :user_id, :integer - t.column :permalink, :string - t.column :guid, :string - t.column :text_filter_id, :integer - t.column :whiteboard, :text - end - - if config[::Rails.env]['adapter'] == 'postgresql' - execute "select nextval('articles_id_seq')" - end - - add_index :articles, :permalink - - if not $schema_generator - Bare20Content.find(:all, :conditions => "type = 'Article'").each do |a| - t = Bare20Article.new( - :title => a.title, - :author => a.author, - :body => a.body, - :body_html => a.body_html, - :extended => a.extended, - :excerpt => a.excerpt, - :keywords => a.keywords, - :allow_comments => a.allow_comments, - :allow_pings => a.allow_pings, - :published => a.published, - :created_at => a.created_at, - :updated_at => a.updated_at, - :extended_html => a.extended_html, - :user_id => a.user_id, - :permalink => a.permalink, - :guid => a.guid, - :text_filter_id => a.text_filter_id, - :whiteboard => a.whiteboard) - # can't use id accessor because it uses the bogus primary key - t.send(:write_attribute, :id, a.send(:read_attribute, :id)) - t.save! - end - - if config[::Rails.env]['adapter'] == 'postgres' - say "Resetting PostgreSQL sequences", true - execute "select setval('articles_id_seq',max(id)+1) from articles" - end - - end - - # script 21 saved the comments, this script saved the articles. - drop_table :contents - end - end -end diff --git a/db/migrate/021_superclass_comments.rb b/db/migrate/021_superclass_comments.rb deleted file mode 100644 index 7c48d1354a..0000000000 --- a/db/migrate/021_superclass_comments.rb +++ /dev/null @@ -1,94 +0,0 @@ -class SuperclassComments < ActiveRecord::Migration - class BareComment < ActiveRecord::Base - include BareMigration - end - - class BareContent < ActiveRecord::Base - include BareMigration - set_inheritance_column :bogustype # see migration #20 for why - end - - def self.up - say "Merging Comments into Contents table" - # Get our indices into a known good state. - # Mutter dark imprecations at having to do this. - #add_index(:comments, :article_id) rescue nil - #remove_index(:contents, :article_id) rescue nil - modify_tables_and_update([:add_column, BareContent, :article_id, :integer], - [:add_column, BareContent, :email, :string ], - [:add_column, BareContent, :url, :string ], - [:add_column, BareContent, :ip, :string ], - [:add_index, BareContent, :article_id ]) do - BareContent.transaction do - if not $schema_generator - BareComment.find(:all).each do |c| - BareContent.create!(:type => 'Comment', - :article_id => c.article_id, - :author => c.author, - :email => c.email, - :url => c.url, - :ip => c.ip, - :body => c.body, - :body_html => c.body_html, - :created_at => c.created_at, - :updated_at => c.updated_at, - :user_id => c.user_id, - :guid => c.guid, - :whiteboard => c.whiteboard) - end - end - end - remove_index(:comments, :article_id) - end - drop_table :comments - end - - def self.init_comments_table(t) - t.column :article_id, :integer - t.column :title, :string - t.column :author, :string - t.column :email, :string - t.column :url, :string - t.column :ip, :string - t.column :body, :text - t.column :body_html, :text - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :user_id, :integer - t.column :guid, :string - t.column :whiteboard, :text - end - - - def self.down - say "Recreating Comments from Contents table" - modify_tables_and_update([:create_table, BareComment, lambda {|t| self.init_comments_table(t)}], - [:add_index, BareComment, :article_id ]) do - BareContent.transaction do - BareComment.transaction do - BareContent.find(:all, :conditions => "type = 'Comment'").each do |c| - BareComment.create!(:article_id => c.article_id, - :title => c.title, - :author => c.author, - :email => c.email, - :url => c.url, - :ip => c.ip, - :body => c.body, - :body_html => c.body_html, - :created_at => c.created_at, - :updated_at => c.updated_at, - :user_id => c.user_id, - :guid => c.guid, - :whiteboard => c.whiteboard) - end - BareContent.delete_all "type = 'Comment'" - end - end - remove_index :contents, :article_id - remove_column :contents, :article_id - remove_column :contents, :email - remove_column :contents, :url - remove_column :contents, :ip - end - end -end diff --git a/db/migrate/022_superclass_trackbacks.rb b/db/migrate/022_superclass_trackbacks.rb deleted file mode 100644 index f62db8d454..0000000000 --- a/db/migrate/022_superclass_trackbacks.rb +++ /dev/null @@ -1,73 +0,0 @@ -class SuperclassTrackbacks < ActiveRecord::Migration - class BareContent < ActiveRecord::Base - include BareMigration - set_inheritance_column :bogustype # see migration #20 for why - end - - class BareTrackback < ActiveRecord::Base - include BareMigration - end - - def self.up - say "Merging Trackbacks into Content table" - # Ensure that the index we're going to remove in the transaction - # is actually there (otherwise Postgres breaks) - # Comment because already in migration 001 - #add_index(:trackbacks, :article_id) rescue nil - modify_tables_and_update([:add_column, BareContent, :blog_name, :string], - [:remove_index, BareTrackback, :article_id ]) do - BareContent.transaction do - if not $schema_generator - BareTrackback.find(:all).each do |tb| - a = BareContent.find(tb.article_id) - BareContent.create(:type => 'Trackback', - :article_id => tb.article_id, - :blog_name => tb.blog_name, - :title => tb.title, - :excerpt => tb.excerpt, - :url => tb.url, - :ip => tb.ip, - :created_at => tb.created_at, - :updated_at => tb.updated_at, - :guid => tb.guid) - end - end - end - end - drop_table :trackbacks - end - - def self.transactions_init(t) - t.column :article_id, :integer - t.column :blog_name, :string - t.column :title, :string - t.column :excerpt, :string - t.column :url, :string - t.column :ip, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :guid, :string - end - - def self.down - say "Recreating Trackbacks from Contents table" - modify_tables_and_update([:create_table, :trackbacks, lambda {|t| transactions_init(t)}], - [:add_index, :trackbacks, :article_id]) do - BareContent.transaction do - BareContent.find(:all, :conditions => ["type = ?", 'Trackback']).each do |tb| - BareTrackback.create(:article_id => tb.article_id, - :blog_name => tb.blog_name, - :title => tb.title, - :excerpt => tb.excerpt, - :url => tb.url, - :ip => tb.ip, - :created_at => tb.created_at, - :updated_at => tb.updated_at, - :guid => tb.guid) - end - BareContent.delete_all("type = 'Trackback'") - end - end - remove_column :contents, :blog_name - end -end diff --git a/db/migrate/023_superclass_pages.rb b/db/migrate/023_superclass_pages.rb deleted file mode 100644 index 62cabb58cb..0000000000 --- a/db/migrate/023_superclass_pages.rb +++ /dev/null @@ -1,65 +0,0 @@ -class Bare23Content < ActiveRecord::Base - include BareMigration - set_inheritance_column :bogustype # see migration #20 for why -end - -class Bare23Page < ActiveRecord::Base - include BareMigration -end - -class SuperclassPages < ActiveRecord::Migration - def self.up - say "Merging Pages into Content table" - modify_tables_and_update(:add_column, Bare23Content, :name, :string) do - Bare23Content.transaction do - if not $schema_generator - Bare23Page.find(:all).each do |p| - Bare23Content.create(:type => 'Page', - :name => p.name, - :user_id => p.user_id, - :body => p.body, - :body_html => p.body_html, - :created_at => p.created_at, - :updated_at => (p.modified_at rescue p.updated_at), - :title => p.title, - :text_filter_id => p.text_filter_id) - end - end - end - end - drop_table :pages - end - - def self.init_pages(t) - t.column :name, :string - t.column :user_id, :integer - t.column :body, :text - t.column :body_html, :text - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :title, :string - t.column :text_filter_id, :integer - t.column :whiteboard, :text - end - - def self.down - say "Recreating pages table" - modify_tables_and_update(:create_table, :pages, lambda {|t| init_pages(t)}) do - Bare23Content.transaction do - Bare23Content.find(:all, :conditions => "type = 'Page'").each do |p| - Bare23Page.create(:name => p.name, - :user_id => p.user_id, - :body => p.body, - :body_html => p.body_html, - :created_at => p.created_at, - :updated_at => p.updated_at, - :title => p.title, - :text_filter_id => p.text_filter_id, - :whiteboard => p.whiteboard) - end - Bare23Content.delete_all "type = 'Page'" - end - end - remove_column :contents, :name - end -end diff --git a/db/migrate/024_cleanup_contents.rb b/db/migrate/024_cleanup_contents.rb deleted file mode 100644 index e49ca7bd42..0000000000 --- a/db/migrate/024_cleanup_contents.rb +++ /dev/null @@ -1,44 +0,0 @@ -# BareMigration doesn't handle inheritance yet. Therefore, we need -# to mimic it manually using conditions on find(). Since this script -# doesn't need to set type or id, there's no need to move either of -# the protected fields out of the way like we do in #20-23. - -# BareMigration ALSO doesn't handle associations... yet. -# For now, that means your keywords won't be automatically converted -# to tags. That might not be a bad thing... - - -class Bare24Article < ActiveRecord::Base - include BareMigration - include TypoGuid - - set_table_name :contents - has_and_belongs_to_many :tags, - :class_name => 'Bare24Tag', :foreign_key => 'article_id', - :join_table => 'articles_tags', :association_foreign_key => 'tag_id' -end - -class Bare24Tag < ActiveRecord::Base - include BareMigration - has_and_belongs_to_many :articles, - :class_name => 'Bare24Article', :foreign_key => 'tag_id', - :join_table => 'articles_tags', :association_foreign_key => 'articles_id' -end - -class CleanupContents < ActiveRecord::Migration - def self.up - say "Updating all articles" - # This is needed when migrating from 2.5.x, because we skip GUID - # generation and tagging during earlier migrations. - Bare24Article.transaction do - Bare24Article.find(:all, :conditions => "type = 'Article'").each do |a| - a.create_guid - a.save! - end - end - end - - def self.down - # nothing - end -end diff --git a/db/migrate/025_add_itunes_metadata.rb b/db/migrate/025_add_itunes_metadata.rb deleted file mode 100644 index e8f8f272d6..0000000000 --- a/db/migrate/025_add_itunes_metadata.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Bare25Resource < ActiveRecord::Base - include BareMigration -end - -class AddItunesMetadata < ActiveRecord::Migration - def self.up - say "Adding podcast metadata fields" - modify_tables_and_update([:add_column, :resources, :itunes_metadata, :boolean], - [:add_column, :resources, :itunes_author, :string], - [:add_column, :resources, :itunes_subtitle, :string], - [:add_column, :resources, :itunes_duration, :integer], - [:add_column, :resources, :itunes_summary, :text], - [:add_column, :resources, :itunes_keywords, :string], - [:add_column, :resources, :itunes_category, :string], - [:add_column, :resources, :itunes_explicit, :boolean]) - end - - def self.down - say "Removing podcast metadata fields" - modify_tables_and_update([:remove_column, :resources, :itunes_metadata, :boolean], - [:remove_column, :resources, :itunes_author, :string], - [:remove_column, :resources, :itunes_subtitle, :string], - [:remove_column, :resources, :itunes_duration, :integer], - [:remove_column, :resources, :itunes_summary, :text], - [:remove_column, :resources, :itunes_keywords, :string], - [:remove_column, :resources, :itunes_category, :string], - [:remove_column, :resources, :itunes_explicit, :boolean]) - end -end diff --git a/db/migrate/026_add_redirect_table.rb b/db/migrate/026_add_redirect_table.rb deleted file mode 100644 index b66bacf283..0000000000 --- a/db/migrate/026_add_redirect_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddRedirectTable < ActiveRecord::Migration - def self.up - say "Adding Redirect Table" - create_table :redirects do |t| - t.column :from_path, :string - t.column :to_path, :string - end - end - - def self.down - drop_table :redirects - end -end diff --git a/db/migrate/027_set_comment_published_flag.rb b/db/migrate/027_set_comment_published_flag.rb deleted file mode 100644 index c6bfbf66e0..0000000000 --- a/db/migrate/027_set_comment_published_flag.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Bare27Content < ActiveRecord::Base - include BareMigration - # See #24 for a description of how we have to manually handle STI -end - -class SetCommentPublishedFlag < ActiveRecord::Migration - def self.up - say "Setting published flag on each comment" - Bare27Content.transaction do - Bare27Content.find(:all, :conditions => "type = 'Comment'").each do |c| - c.published = true - c.save! - end - end - end - - def self.down - end -end diff --git a/db/migrate/028_rename_redirect_to.rb b/db/migrate/028_rename_redirect_to.rb deleted file mode 100644 index 59d9b9fd3f..0000000000 --- a/db/migrate/028_rename_redirect_to.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Bare28Redirect < ActiveRecord::Base - include BareMigration -end - -class RenameRedirectTo < ActiveRecord::Migration - def self.up - # The original version of the redirects table used 'to' as a column name - # Postgres is okay with that, but not mysql. - # You need test if rename needed, because with migration transaction, all - # failed if rename failed - if Bare28Redirect.columns_hash.has_key? 'to' - rename_column :redirects, :to, :to_path - end - end - - def self.down - # don't rename column back to broken name. - # there's little chance this column will be used before now anyway. - end -end diff --git a/db/migrate/029_add_user_notification.rb b/db/migrate/029_add_user_notification.rb deleted file mode 100644 index 85deb33ea4..0000000000 --- a/db/migrate/029_add_user_notification.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Bare29User < ActiveRecord::Base - include BareMigration -end - -class AddUserNotification < ActiveRecord::Migration - def self.up - modify_tables_and_update([:add_column, Bare29User, :notify_via_email, :boolean], - [:add_column, Bare29User, :notify_on_new_articles, :boolean], - [:add_column, Bare29User, :notify_on_comments, :boolean], - [:add_column, Bare29User, :notify_watch_my_articles, :boolean]) do |u| - # Definitions: - # notify_via_email: use email to deliver notifications - # notify_on_new_articles: send a notification message (email, etc) when new articles added. - # notify_on_comments: send a notification message when new comments are added to watched articles. - # notify_watch_my_articles: tell the notifiation system to watch my articles. - u.notify_via_email = true - u.notify_on_new_articles = false - u.notify_on_comments = true - u.notify_watch_my_articles = true - end - end - - def self.down - modify_tables_and_update([:remove_column, Bare29User, :notify_via_email, :boolean], - [:remove_column, Bare29User, :notify_on_new_articles, :boolean], - [:remove_column, Bare29User, :notify_on_comments, :boolean], - [:remove_column, Bare29User, :notify_watch_my_articles, :boolean]) - end -end diff --git a/db/migrate/030_index_sessions.rb b/db/migrate/030_index_sessions.rb deleted file mode 100644 index 30a2881de8..0000000000 --- a/db/migrate/030_index_sessions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class IndexSessions < ActiveRecord::Migration - def self.up - add_index :sessions, :sessid - end - - def self.down - remove_index :sessions, :sessid - end -end diff --git a/db/migrate/031_add_notifications_table.rb b/db/migrate/031_add_notifications_table.rb deleted file mode 100644 index 156c574f57..0000000000 --- a/db/migrate/031_add_notifications_table.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddNotificationsTable < ActiveRecord::Migration - def self.up - create_table :notifications, :id => false do |t| - t.column :notify_user_id, :integer - t.column :notify_content_id, :integer - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - end - - def self.down - drop_table :notifications - end -end diff --git a/db/migrate/032_add_jabber_notification.rb b/db/migrate/032_add_jabber_notification.rb deleted file mode 100644 index cf2b3d37d1..0000000000 --- a/db/migrate/032_add_jabber_notification.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddJabberNotification < ActiveRecord::Migration - def self.up - add_column :users, :notify_via_jabber, :boolean - add_column :users, :jabber, :string - end - - def self.down - remove_column :users, :notify_via_jabber - remove_column :users, :jabber - end -end diff --git a/db/migrate/033_add_count_caching.rb b/db/migrate/033_add_count_caching.rb deleted file mode 100644 index c3fcb0f0c3..0000000000 --- a/db/migrate/033_add_count_caching.rb +++ /dev/null @@ -1,34 +0,0 @@ -class Bare33Content < ActiveRecord::Base - include BareMigration - - def count_children_of_type(type) - self.class.find(:all, - :conditions => ["article_id = ? and type = ?", - self.id, type ]).size - end - - def correct_counts - self.comments_count = self.count_children_of_type('Comment') - self.trackbacks_count = self.count_children_of_type('Trackback') - end -end - - -class AddCountCaching < ActiveRecord::Migration - def self.up - say "Adding comments_count, trackbacks_count" - modify_tables_and_update([:add_column, Bare33Content, :comments_count, :integer], - [:add_column, Bare33Content, :trackbacks_count, :integer]) do |a| - if not $schema_generator - a.correct_counts - end - end - end - - def self.down - say "Removing counts columns" - remove_column :contents, :comments_count - remove_column :contents, :trackbacks_count - end -end - diff --git a/db/migrate/034_boolify_published.rb b/db/migrate/034_boolify_published.rb deleted file mode 100644 index fa340ed69b..0000000000 --- a/db/migrate/034_boolify_published.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Bare34Content < ActiveRecord::Base - include BareMigration -end - -class BoolifyPublished < ActiveRecord::Migration - def self.up - say "Boolifying contents.published" - modify_tables_and_update([:rename_column, Bare34Content, :published, :old_pub], - [:add_column, Bare34Content, :published, :boolean, { :default => true }]) do |c| - unless $schema_generator - if c.old_pub.nil? - c.published = true - else - c.published = (!c.old_pub.to_i.zero? ? true : false) - end - end - end - remove_column :contents, :old_pub - end - - def self.down - say "Un-Boolifying contents.published" - modify_tables_and_update([:rename_column, Bare34Content, :published, :old_pub], - [:add_column, Bare34Content, :published, :integer]) do |c| - unless $schema_generator - say "Old published: #{c.old_pub}" - if c.old_pub.nil? - c.published = 1 - else - c.published = c.old_pub ? 1 : 0 - end - end - end - remove_column :contents, :old_pub - end -end diff --git a/db/migrate/035_boolify_content_allow_foo.rb b/db/migrate/035_boolify_content_allow_foo.rb deleted file mode 100644 index e67db62649..0000000000 --- a/db/migrate/035_boolify_content_allow_foo.rb +++ /dev/null @@ -1,36 +0,0 @@ -class Bare35Content < ActiveRecord::Base - include BareMigration -end - -class BoolifyContentAllowFoo < ActiveRecord::Migration - def self.up - say "Boolifying contents.allow_(comments|pings)" - - modify_tables_and_update([:rename_column, Bare35Content, :allow_pings, :old_ap], - [:add_column, Bare35Content, :allow_pings, :boolean], - [:rename_column, Bare35Content, :allow_comments, :old_ac], - [:add_column, Bare35Content, :allow_comments, :boolean]) do |c| - unless $schema_generator - c.allow_pings = !c.old_ap.to_i.zero? ? true : false unless c.old_ap.nil? - c.allow_comments = !c.old_ac.to_i.zero? ? true : false unless c.old_ac.nil? - end - end - remove_column :contents, :old_ap - remove_column :contents, :old_ac - end - - def self.down - say "Un-Boolifying contents.allow_(comments|pings)" - modify_tables_and_update([:rename_column, Bare35Content, :allow_pings, :old_ap], - [:add_column, Bare35Content, :allow_pings, :integer], - [:rename_column, Bare35Content, :allow_comments, :old_ac], - [:add_column, Bare35Content, :allow_comments, :integer]) do |c| - unless $schema_generator - c.allow_pings = c.old_ap ? 1 : 0 unless c.old_ap.nil? - c.allow_comments = c.old_ac ? 1 : 0 unless c.old_ac.nil? - end - end - remove_column :contents, :old_ap - remove_column :contents, :old_ac - end -end diff --git a/db/migrate/036_add_tag_display_name.rb b/db/migrate/036_add_tag_display_name.rb deleted file mode 100644 index 731fb3c565..0000000000 --- a/db/migrate/036_add_tag_display_name.rb +++ /dev/null @@ -1,51 +0,0 @@ -class AddTagDisplayName < ActiveRecord::Migration - class Tag < ActiveRecord::Base - has_and_belongs_to_many :articles - end - - class Content < ActiveRecord::Base - end - - class Article < Content - has_and_belongs_to_many :tags - end - - def self.up - say 'Adding display name to tags' - modify_tables_and_update(:add_column, Tag, :display_name, :string) do - unless $schema_generator - Tag.find(:all).each do |tag| - tag.display_name = tag.name - tag.name = tag.name.tr(' ', '').downcase - if tag.name != tag.display_name - # we need to make sure we're not attempting to create duplicate-named tags - # if so, we need to coalesce them - # Hopefully this code isn't necessary, but somebody may have tags "Monty Python" and "montypython" - # Please note that this code isn't going to be tested very well, if at all, because of my limited - # testing setup. But in my quickie tests it appears to be working right - if origtag = Tag.find(:first, :conditions => [%{name = ? AND id != ?}, tag.name, tag.id]) - tag.articles.each do |article| - # replace our tag with origtag in article.tags - article.tags = article.tags.collect { |x| x.id == tag.id ? origtag : x } - end - tag.destroy - else - # ok, original tag - tag.save! - end - else - tag.save! - end - end - end - end - end - - def self.down - say 'Removing display name from tags' - unless $schema_generator - Tag.update_all('name = display_name') - end - remove_column :tags, :display_name - end -end diff --git a/db/migrate/037_enlarge_ip_field.rb b/db/migrate/037_enlarge_ip_field.rb deleted file mode 100644 index beadc8bcce..0000000000 --- a/db/migrate/037_enlarge_ip_field.rb +++ /dev/null @@ -1,9 +0,0 @@ -class EnlargeIpField < ActiveRecord::Migration - def self.up - change_column :contents, :ip, :string, :limit => 40 - end - - def self.down - change_column :contents, :ip, :string - end -end diff --git a/db/migrate/038_add_blog_object.rb b/db/migrate/038_add_blog_object.rb deleted file mode 100644 index 6c77b5d94f..0000000000 --- a/db/migrate/038_add_blog_object.rb +++ /dev/null @@ -1,52 +0,0 @@ -class Bare38Blog < ActiveRecord::Base - include BareMigration -end - -class Bare38Setting < ActiveRecord::Base - include BareMigration -end - -class AddBlogObject < ActiveRecord::Migration - def self.up - begin - say "Adding a blogs table" - create_table :blogs do |t| - t.column :dummy, :string unless $schema_generator - end - unless $schema_generator - Bare38Blog.reset_column_information - - add_column :settings, :blog_id, :integer - Bare38Setting.reset_column_information - - Bare38Setting.transaction do - say "Creating default blog", true - default_blog = Bare38Blog.create! - - say "Connecting settings to the default blog", true - - say "New Default blog has id: " + default_blog.id.to_s, true - say "Migrating #{Bare38Setting.find(:all).size} settings to the new Blog", true - - Bare38Setting.find(:all).each do |setting| - setting.blog_id = default_blog.id - setting.save! - end - end - remove_column :blogs, :dummy - end - rescue Exception => e - say("Rolling back the changes") - drop_table(:blogs) rescue nil - remove_column(:settings, :blog_id) rescue nil - raise e - end - end - - def self.down - say "Unlinking settings and removing the blogs table" - Bare38Setting.delete_all(["blog_id != ?", Bare38Blog.find(:first)]) - remove_column :settings, :blog_id - drop_table :blogs - end -end diff --git a/db/migrate/039_serialize_blog_attributes.rb b/db/migrate/039_serialize_blog_attributes.rb deleted file mode 100644 index 16ea464061..0000000000 --- a/db/migrate/039_serialize_blog_attributes.rb +++ /dev/null @@ -1,167 +0,0 @@ -class SerializeBlogAttributes < ActiveRecord::Migration - class BareSetting < ActiveRecord::Base - include BareMigration - belongs_to :blog, :class_name => "SerializeBlogAttributes::BareBlog" - - def self.with_blog_scope(id, &block) - options = {} - options[:conditions] = ["blog_id = ?", id] - with_scope(:find => options, &block) - end - - end - - class BareBlog < ActiveRecord::Base - include BareMigration - serialize :settings - - class SettingSpec - attr_accessor :key, :type, :default - - def initialize(key, type, default) - self.key = key - self.type = type - self.default = default - end - - def normalize_value(line) - if !line || line.value.nil? - return default - end - value = line.value - case type - when :boolean - ! value.match(/^(?:f(?:alse)?|0|)$/) - when :integer - value.to_i - when :string - value - else - YAML::load(value) - end - end - - def stringify_value(value) - case type - when :boolean - value.to_s - when :integer - value.to_s - when :string - value - else - value.to_yaml - end - end - end - - def self.fields(key = nil) - @@fields ||= { } - key ? @@fields[key.to_sym] : @@fields - end - - def self.setting(key, type, default) - fields[key.to_sym] = SettingSpec.new(key.to_sym, type, default) - end - - # Description - setting :blog_name, :string, 'My Shiny Weblog!' - setting :blog_subtitle, :string, '' - setting :geourl_location, :string, '' - - # Spam - setting :sp_global, :boolean, false - setting :sp_article_auto_close, :integer, 0 - setting :sp_allow_non_ajax_comments, :boolean, true - setting :sp_url_limit, :integer, 0 - - # Podcasting - setting :itunes_explicit, :boolean, false - setting :itunes_author, :string, '' - setting :itunes_subtitle, :string, '' - setting :itunes_summary, :string, '' - setting :itunes_owner, :string, '' - setting :itunes_email, :string, '' - setting :itunes_name, :string, '' - setting :itunes_copyright, :string, '' - - # Mostly Behaviour - setting :text_filter, :string, '' - setting :comment_text_filter, :string, '' - setting :limit_article_display, :integer, 10 - setting :limit_rss_display, :integer, 10 - setting :default_allow_pings, :boolean, false - setting :default_allow_comments, :boolean, true - setting :link_to_author, :boolean, false - setting :show_extended_on_rss, :boolean, true - setting :theme, :string, 'azure' - setting :use_gravatar, :boolean, false - setting :ping_urls, :string, "http://rpc.technorati.com/rpc/ping\nhttp://ping.blo.gs/\nhttp://rpc.weblogs.com/RPC2" - setting :send_outbound_pings, :boolean, true - setting :email_from, :string, 'scott@sigkill.org' - - # Jabber config - setting :jabber_address, :string, '' - setting :jabber_password, :string, '' - end - - - def self.up - add_column :blogs, :settings, :text - unless $schema_generator - begin - BareSetting.transaction do - BareBlog.find(:all).each do |blog| - blog.settings = { } - BareSetting.with_blog_scope(blog.id) do - BareBlog.fields.each do |key, spec| - next unless setting = BareSetting.find_by_name(key.to_s, :limit => 1) - blog.settings[key.to_s] = - spec.normalize_value(setting) - BareSetting.delete(setting.id) - end - end - blog.save - end - end - rescue Exception => e - remove_column :blogs, :settings rescue nil - raise e - end - end - drop_table :settings - end - - def self.down - begin - create_settings - unless $schema_generator - BareSetting.transaction do - BareBlog.find(:all).each do |blog| - blog.settings ||= { } - BareSetting.with_scope(:create => { :blog_id => blog.id }) do - BareBlog.fields.each do |key, spec| - next unless blog.settings.has_key?(key.to_s) - BareSetting.create!(:name => key.to_s, - :value => spec.stringify_value(blog.settings[key.to_s])) - end - end - end - end - end - remove_column :blogs, :settings rescue nil - rescue Exception => e - drop_table :settings rescue nil - raise e - end - end - - def self.create_settings - create_table :settings do |t| - t.column :name, :string, :limit => 255 - t.column :value, :string, :limit => 255 - t.column :position, :integer - t.column :blog_id, :integer - end - end -end diff --git a/db/migrate/040_attach_content_to_blog.rb b/db/migrate/040_attach_content_to_blog.rb deleted file mode 100644 index 4c20216bb6..0000000000 --- a/db/migrate/040_attach_content_to_blog.rb +++ /dev/null @@ -1,28 +0,0 @@ -class AttachContentToBlog < ActiveRecord::Migration - class BareContent < ActiveRecord::Base - include BareMigration - end - - class BareBlog < ActiveRecord::Base - include BareMigration - end - - def self.up - begin - add_column :contents, :blog_id, :integer - blog_id = BareBlog.find(:first).id - BareContent.find(:all).each {|c| c.blog_id = blog_id; c.save! } - change_column :contents, :blog_id, :integer, :null => false - add_index :contents, :blog_id - rescue Exception => e - remove_index :contents, :blog_id rescue nil - remove_column :contents, :blog_id rescue nil - raise e - end - end - - def self.down - remove_index :contents, :blog_id - remove_column :contents, :blog_id - end -end diff --git a/db/migrate/041_fixup_default_sidebars.rb b/db/migrate/041_fixup_default_sidebars.rb deleted file mode 100644 index 6cfd9f86a0..0000000000 --- a/db/migrate/041_fixup_default_sidebars.rb +++ /dev/null @@ -1,18 +0,0 @@ -class FixupDefaultSidebars < ActiveRecord::Migration - class BareSidebar < ActiveRecord::Base - include BareMigration - end - - def self.up - BareSidebar.transaction do - BareSidebar.find(:all, :conditions => "staged_position IS NULL").each do |sb| - sb.staged_position = sb.active_position; - sb.save! - end - end - end - - def self.down - # There's nothing to do in the down step. - end -end diff --git a/db/migrate/042_remove_sidebar_staged_config.rb b/db/migrate/042_remove_sidebar_staged_config.rb deleted file mode 100644 index 54f5db51b8..0000000000 --- a/db/migrate/042_remove_sidebar_staged_config.rb +++ /dev/null @@ -1,22 +0,0 @@ -class RemoveSidebarStagedConfig < ActiveRecord::Migration - class BareSidebar < ActiveRecord::Base - include BareMigration - serialize :active_config - serialize :staged_config - end - - - def self.up - remove_column :sidebars, :staged_config - rename_column :sidebars, :active_config, :config - end - - def self.down - modify_tables_and_update([:rename_column, BareSidebar, :config, :active_config], - [:add_column, BareSidebar, :staged_config, :text]) do |sb| - unless $schema_generator - sb.staged_config = sb.active_config - end - end - end -end diff --git a/db/migrate/043_create_triggers.rb b/db/migrate/043_create_triggers.rb deleted file mode 100644 index 30f245ff10..0000000000 --- a/db/migrate/043_create_triggers.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateTriggers < ActiveRecord::Migration - def self.up - create_table :triggers do |t| - t.column :pending_item_id, :integer - t.column :pending_item_type, :string - t.column :due_at, :datetime - t.column :trigger_method, :string - end - end - - def self.down - drop_table :triggers - end -end diff --git a/db/migrate/044_add_published_at_to_content.rb b/db/migrate/044_add_published_at_to_content.rb deleted file mode 100644 index cd1f6e8ed5..0000000000 --- a/db/migrate/044_add_published_at_to_content.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddPublishedAtToContent < ActiveRecord::Migration - class Content < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update(:add_column, Content, - :published_at, :datetime) do |content| - unless $schema_generator - content.published_at = content.created_at - end - end - end - - def self.down - remove_column :contents, :published_at - end -end diff --git a/db/migrate/045_fix_contents_published_default.rb b/db/migrate/045_fix_contents_published_default.rb deleted file mode 100644 index bb94559cd2..0000000000 --- a/db/migrate/045_fix_contents_published_default.rb +++ /dev/null @@ -1,9 +0,0 @@ -class FixContentsPublishedDefault < ActiveRecord::Migration - def self.up - change_column :contents, :published, :boolean, :default => false - end - - def self.down - change_column :contents, :published, :boolean, :default => true - end -end diff --git a/db/migrate/046_fixup_forthcoming_publications.rb b/db/migrate/046_fixup_forthcoming_publications.rb deleted file mode 100644 index aa34f09cd4..0000000000 --- a/db/migrate/046_fixup_forthcoming_publications.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'bare_migration' -class FixupForthcomingPublications < ActiveRecord::Migration - class Trigger < ActiveRecord::Base - belongs_to :pending_item, :polymorphic => true - end - - class Content < ActiveRecord::Base - end - - class Article < Content - end - - def self.up - return if $schema_generator - Article.transaction do - Trigger.transaction do - Article.find(:all, :conditions => ['published = ? AND published_at > ?', - true, Time.now]).each do |art| - Trigger.create!(:pending_item => art, - :due_at => art.published_at, - :trigger_method => 'publish!') - art.update_attribute(:published, false) - end - end - end - end - - def self.down - return if $schema_generator - Article.transaction do - Trigger.transaction do - Trigger.find(:all, - :conditions => "pending_item_type = 'Article' AND trigger_method = 'publish!'").each do |t| - t.pending_item.update_attribute(:published, :true) - t.destroy - end - end - end - end -end diff --git a/db/migrate/047_add_content_state_field.rb b/db/migrate/047_add_content_state_field.rb deleted file mode 100644 index 5ed0638cf0..0000000000 --- a/db/migrate/047_add_content_state_field.rb +++ /dev/null @@ -1,24 +0,0 @@ -class AddContentStateField < ActiveRecord::Migration - class Content < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update(:add_column, Content, - :state, :text) do |content| - unless $schema_generator - if content.published? - content.state = 'Published' - elsif content.published_at - content.state = 'PublicationPending' - else - content.state = 'Draft' - end - end - end - end - - def self.down - remove_column :contents, :state - end -end diff --git a/db/migrate/048_remove_count_caching.rb b/db/migrate/048_remove_count_caching.rb deleted file mode 100644 index 332fd1a077..0000000000 --- a/db/migrate/048_remove_count_caching.rb +++ /dev/null @@ -1,31 +0,0 @@ -class RemoveCountCaching < ActiveRecord::Migration - class Content < ActiveRecord::Base - include BareMigration - - def count_children_of_type(type) - self.class.find(:all, - :conditions => ["article_id = ? and type = ?", - self.id, type]).size - end - - def correct_counts - self.comments_count = self.count_children_of_type('Comment') - self.trackbacks_count = self.count_children_of_type('Trackback') - end - end - - def self.up - remove_column :contents, :comments_count - remove_column :contents, :trackbacks_count - end - - def self.down - modify_tables_and_update( - [:add_column, Content, :comments_count, :integer], - [:add_column, Content, :trackbacks_count, :integer]) do |a| - if not $schema_generator - a.correct_counts - end - end - end -end diff --git a/db/migrate/049_move_feedback_to_new_state_machine.rb b/db/migrate/049_move_feedback_to_new_state_machine.rb deleted file mode 100644 index 849e5c2fad..0000000000 --- a/db/migrate/049_move_feedback_to_new_state_machine.rb +++ /dev/null @@ -1,33 +0,0 @@ -class MoveFeedbackToNewStateMachine < ActiveRecord::Migration - class Content < ActiveRecord::Base - include BareMigration - end - - def self.up - return if $schema_generator - Content.find(:all, - :conditions => ['type = ? or type = ?', - 'Trackback', 'Comment']).each do |c| - c.state = if c.published? - 'ContentState::PresumedHam' - else - 'ContentState::PresumedSpam' - end - c.save! - end - end - - def self.down - return if $schema_generator - Content.find(:all, - :conditions => ['type = ? or type = ?', - 'Trackback', 'Comment']).each do |c| - c.state = if c.published? - 'ContentState::Published' - else - 'ContentState::Withdrawn' - end - c.save! - end - end -end diff --git a/db/migrate/050_add_status_confirmed_field_to_content.rb b/db/migrate/050_add_status_confirmed_field_to_content.rb deleted file mode 100644 index 989e545dc6..0000000000 --- a/db/migrate/050_add_status_confirmed_field_to_content.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddStatusConfirmedFieldToContent < ActiveRecord::Migration - class Content < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update \ - [:add_column, Content, :status_confirmed, :boolean] do |a| - if not $schema_generator - a.status_confirmed = (a.state =~ /ContentState::(Sp|H)am/ ? true : false) - a.save! - end - end - end - - def self.down - remove_column :contents, :status_confirmed - end -end diff --git a/db/migrate/051_fix_canonical_server_url.rb b/db/migrate/051_fix_canonical_server_url.rb deleted file mode 100644 index 418ef97ca1..0000000000 --- a/db/migrate/051_fix_canonical_server_url.rb +++ /dev/null @@ -1,17 +0,0 @@ -class FixCanonicalServerUrl < ActiveRecord::Migration - class Blog < ActiveRecord::Base - include BareMigration - serialize :settings, Hash - end - def self.up - unless $schema_generator - Blog.find(:all).each do |b| - b.settings['canonical_server_url'] = b.settings['canonical_server_url'].to_s.gsub(%r{/$},'') - b.save - end - end - end - - def self.down - end -end diff --git a/db/migrate/052_remove_cached_html.rb b/db/migrate/052_remove_cached_html.rb deleted file mode 100644 index f8a951b589..0000000000 --- a/db/migrate/052_remove_cached_html.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveCachedHtml < ActiveRecord::Migration - def self.up - remove_column :contents, :body_html - remove_column :contents, :extended_html - end - - def self.down - add_column :contents, :body_html, :text - add_column :contents, :extended_html, :text - end -end diff --git a/db/migrate/053_promote_canonical_server_url.rb b/db/migrate/053_promote_canonical_server_url.rb deleted file mode 100644 index 0862e89c29..0000000000 --- a/db/migrate/053_promote_canonical_server_url.rb +++ /dev/null @@ -1,22 +0,0 @@ -class PromoteCanonicalServerUrl < ActiveRecord::Migration - class Blog < ActiveRecord::Base - include BareMigration - serialize :settings, Hash - end - - def self.up - add_column :blogs, :base_url, :string - Blog.find(:all).each do |blog| - begin - blog.base_url = blog.settings['canonical_server_url'] - blog.save - rescue - # if base_url doesn't exist, then we don't really care. - end - end - end - - def self.down - remove_column :blogs, :base_url - end -end diff --git a/db/migrate/054_upgrade_sidebar_objects.rb b/db/migrate/054_upgrade_sidebar_objects.rb deleted file mode 100644 index ad4271cc24..0000000000 --- a/db/migrate/054_upgrade_sidebar_objects.rb +++ /dev/null @@ -1,26 +0,0 @@ -class UpgradeSidebarObjects < ActiveRecord::Migration - class Sidebar < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update(:add_column, Sidebar, :type, :string) do |sb| - next if $schema_generator - if sb.controller.nil? - raise "Found a sidebar, \"#{sb.id}\", which doesn't know its controller so can't convert it. Settings are:\n #{sb.settings}. Please either correct the controller or delete the sidebar." - end - sb.type = sb.controller.camelcase + 'Sidebar' - sb.save! - end - remove_column :sidebars, :controller - end - - def self.down - modify_tables_and_update(:add_column, Sidebar, :controller, :string) do |sb| - next if $schema_generator - sb.controller = sb[:type].underscore.sub(/_sidebar$/, '') - sb.save! - end - remove_column :sidebars, :type - end -end diff --git a/db/migrate/055_link_sidebars_to_blog.rb b/db/migrate/055_link_sidebars_to_blog.rb deleted file mode 100644 index eec20f3521..0000000000 --- a/db/migrate/055_link_sidebars_to_blog.rb +++ /dev/null @@ -1,17 +0,0 @@ -class LinkSidebarsToBlog < ActiveRecord::Migration - class Sidebar < ActiveRecord::Base - include BareMigration - end - - def self.up - modify_tables_and_update(:add_column, Sidebar, :blog_id, :integer) do |sb| - next if $schema_generator - sb.blog_id = 1 - sb.save! - end - end - - def self.down - remove_column :sidebars, :blog_id - end -end diff --git a/db/migrate/056_create_notifications.rb b/db/migrate/056_create_notifications.rb deleted file mode 100644 index 2902db03da..0000000000 --- a/db/migrate/056_create_notifications.rb +++ /dev/null @@ -1,33 +0,0 @@ -class CreateNotifications < ActiveRecord::Migration - class OldNotification < ActiveRecord::Base - end - - class Notification < ActiveRecord::Base - end - - def self.up - rename_table :notifications, :old_notifications - - create_table :notifications do |t| - t.column :content_id, :integer - t.column :user_id, :integer - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - OldNotification.reset_column_information - Notification.reset_column_information - if $schema_generator - OldNotification.find(:all).each do |on| - Notification.create!(on.attributes) - end - end - drop_table :old_notifications - end - - def self.down - remove_column :notifications, :id - rename_column :notifications, :user_id, :notify_user_id - rename_column :notifications, :content_id, :notify_content_id - end -end diff --git a/db/migrate/057_add_categorization_model.rb b/db/migrate/057_add_categorization_model.rb deleted file mode 100644 index 5be705a73c..0000000000 --- a/db/migrate/057_add_categorization_model.rb +++ /dev/null @@ -1,69 +0,0 @@ -class AddCategorizationModel < ActiveRecord::Migration - class ArticlesCategory < ActiveRecord::Base - include BareMigration - end - - class Categorization < ActiveRecord::Base - include BareMigration - end - - class User < ActiveRecord::Base - end - class Content < ActiveRecord::Base - end - class Article < Content - end - class Category < ActiveRecord::Base - end - - def self.up - create_table :categorizations do |t| - t.column :article_id, :integer - t.column :category_id, :integer - t.column :is_primary, :boolean - end - - unless $schema_generator - # You need test if ArticlesCategory object exist because if - # exception raise even rescue in migration and migration failed and stop - # :( - if table_exists? :articles_categories - ArticlesCategory.all.each do |ac| - Categorization.create!(:article_id => ac.article_id, - :category_id => ac.category_id, - :is_primary => (ac.is_primary == 1)) - end - drop_table :articles_categories - end - end - # Adds the article category to the first post if and only if generating the schema - if User.count.zero? - article = Article.find(:first) - category = Category.find(:first) - say "Adding category to default article" - unless article.nil? or category.nil? - Categorization.create!(:article_id => article.id, - :category_id => category.id, - :is_primary => 1) - end - end - end - - def self.down - create_table :articles_categories, :id => false do |t| - t.column :article_id, :integer - t.column :category_id, :integer - t.column :is_primary, :integer - end - - unless $schema_generator - Categorization.find(:all).each do |c| - ArticlesCategory.create!(:article_id => c.article_id, - :category_id => c.category_id, - :is_primary => c.is_primary ? 1 : 0) - end - end - - drop_table :categorizations - end -end diff --git a/db/migrate/058_separate_entries_and_feedback.rb b/db/migrate/058_separate_entries_and_feedback.rb deleted file mode 100644 index 9789805de3..0000000000 --- a/db/migrate/058_separate_entries_and_feedback.rb +++ /dev/null @@ -1,83 +0,0 @@ -class SeparateEntriesAndFeedback < ActiveRecord::Migration - class Content < ActiveRecord::Base - set_inheritance_column :bogustype - end - - class Feedback < ActiveRecord::Base - set_table_name "feedback" - end - - def self.up - # Comment this out once you've made a backup - - create_table :feedback, :force => true do |t| - t.column "type", :string - t.column "title", :string - t.column "author", :string - t.column "body", :text - t.column "extended", :text - t.column "excerpt", :text - t.column "keywords", :string - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "user_id", :integer - t.column "permalink", :string - t.column "guid", :string - t.column "text_filter_id", :integer - t.column "whiteboard", :text - t.column "article_id", :integer - t.column "email", :string - t.column "url", :string - t.column "ip", :string, :limit => 40 - t.column "blog_name", :string - t.column "name", :string - t.column "published", :boolean, :default => false - t.column "allow_pings", :boolean - t.column "allow_comments", :boolean - t.column "blog_id", :integer, :null => false - t.column "published_at", :datetime - t.column "state", :text - t.column "status_confirmed", :boolean - end - - # Forgot to fixup the state field earlier. Thanks to Ryan Kinderman for the spot. - Content.transaction do - Content.update_all("state = 'spam'", :state => 'ContentState::Spam') - Content.update_all("state = 'ham'", :state => 'ContentState::Ham') - Content.update_all("state = 'presumed_spam'", :state => 'ContentState::PresumedSpam') - Content.update_all("state = 'presumed_ham'", :state => 'ContentState::PresumedHam') - Content.update_all("state = 'published'", :state => 'ContentState::Published') - Content.update_all("state = 'publication_pending'", :state => 'ContentState::PublicationPending') - Content.update_all("state = 'draft'", :state => 'ContentState::Draft') - Content.update_all("state = 'withdrawn'", :state => 'ContentState::Withdrawn') - end - - Content.transaction do - Feedback.transaction do - Content.find(:all, :conditions => {:type => %w{ Comment Trackback }}).each do |content| - Feedback.new(content.attributes) do |fb| - fb[:type] = content[:type] - fb.published = (fb.state == 'ham' || fb.state == 'presumed_ham') - fb.save! - end - end - Content.delete_all(:type => %w{ Comment Trackback }) - end - end - end - - def self.down - Content.transaction do - Feedback.transaction do - Feedback.find(:all).each do |fb| - Content.new(fb.attributes) do |cnt| - cnt[:type] = fb[:type] - cnt.save! - end - end - end - end - - drop_table :feedback - end -end diff --git a/db/migrate/059_cleanup_feedback_table.rb b/db/migrate/059_cleanup_feedback_table.rb deleted file mode 100644 index 8d68d18f3f..0000000000 --- a/db/migrate/059_cleanup_feedback_table.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CleanupFeedbackTable < ActiveRecord::Migration - def self.up - remove_column :feedback, :extended - remove_column :feedback, :keywords - remove_column :feedback, :permalink - remove_column :feedback, :allow_pings - remove_column :feedback, :allow_comments - remove_column :feedback, :name - - add_index :feedback, :article_id - add_index :feedback, :text_filter_id - end - - def self.down - add_column :feedback, :extended, :text - add_column :feedback, :keywords, :string - add_column :feedback, :permalink, :string - add_column :feedback, :allow_pings, :boolean - add_column :feedback, :allow_comments, :boolean - add_column :feedback, :name, :string - - remove_index :feedback, :article_id - remove_index :feedback, :text_filter_id - end -end diff --git a/db/migrate/060_cleanup_contents_table.rb b/db/migrate/060_cleanup_contents_table.rb deleted file mode 100644 index 175109a744..0000000000 --- a/db/migrate/060_cleanup_contents_table.rb +++ /dev/null @@ -1,37 +0,0 @@ -class CleanupContentsTable < ActiveRecord::Migration - def self.up - if adapter_name == 'PostgreSQL' - indexes(:contents).each do |index| - if index.name =~ /article_id/ - remove_index(:contents, :name => index.name) - end - end - else - remove_index :contents, :article_id rescue nil - end - - remove_column :contents, :article_id rescue nil - remove_column :contents, :email - remove_column :contents, :url - remove_column :contents, :ip - remove_column :contents, :blog_name - remove_column :contents, :status_confirmed - - add_index :contents, :published - add_index :contents, :text_filter_id - end - - def self.down - remove_index :contents, :published - remove_index :contents, :text_filter_id - - add_column :contents, :article_id, :integer - add_column :contents, :email, :string - add_column :contents, :url, :string - add_column :contents, :ip, :string, :limit => 40 - add_column :contents, :blog_name, :string - add_column :contents, :status_confirmed, :boolean - - add_index :contents, :article_id - end -end diff --git a/db/migrate/061_convert_title_prefix_setting.rb b/db/migrate/061_convert_title_prefix_setting.rb deleted file mode 100644 index 1ad1e47874..0000000000 --- a/db/migrate/061_convert_title_prefix_setting.rb +++ /dev/null @@ -1,25 +0,0 @@ -class ConvertTitlePrefixSetting < ActiveRecord::Migration - class BareBlog < ActiveRecord::Base - include BareMigration - - serialize :settings, Hash - end - - def self.up - BareBlog.find(:all).each do |b| - if b.settings.has_key? "title_prefix" - b.settings["title_prefix"] = (b.settings["title_prefix"] ? 1 : 0) - b.save! - end - end - end - - def self.down - BareBlog.find(:all).each do |b| - if b.settings.has_key? "title_prefix" - b.settings["title_prefix"] = (b.settings["title_prefix"] == 1) - b.save! - end - end - end -end diff --git a/db/migrate/062_add_sitealizer_plugin.rb b/db/migrate/062_add_sitealizer_plugin.rb deleted file mode 100644 index 872230e7ee..0000000000 --- a/db/migrate/062_add_sitealizer_plugin.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddSitealizerPlugin < ActiveRecord::Migration - - def self.up - create_table :sitealizer do |t| - t.column :path, :string - t.column :ip, :string - t.column :referer, :string - t.column :language, :string - t.column :user_agent, :string - t.column :created_at, :datetime - t.column :created_on, :date - end - end - - def self.down - drop_table :sitealizer - end -end diff --git a/db/migrate/063_rejig_state_field.rb b/db/migrate/063_rejig_state_field.rb deleted file mode 100644 index 70d92d33e8..0000000000 --- a/db/migrate/063_rejig_state_field.rb +++ /dev/null @@ -1,42 +0,0 @@ -class RejigStateField < ActiveRecord::Migration - class BareContent < ActiveRecord::Base - include BareMigration - end - - class BareFeedback < ActiveRecord::Base - include BareMigration - set_table_name 'feedback' - end - - def self.up - ActiveRecord::Base.record_timestamps = false - BareContent.transaction do - BareFeedback.transaction do - [BareContent, BareFeedback].each do |klass| - klass.find(:all).each do |value| - value[:state] = value.state.to_s.demodulize.underscore - value.save! - end - end - end - end - change_column :contents, :state, :string - change_column :feedback, :state, :string - ActiveRecord::Base.record_timestamps = true - end - - def self.down - BareContent.transaction do - BareFeedback.transaction do - [BareContent, BareFeedback].each do |klass| - klass.find(:all).each do |value| - value[:state] = "ContentState::" + value.state.to_s.classify - value.save! - end - end - end - end - change_column :contents, :state, :text - change_column :feedback, :state, :string - end -end diff --git a/db/migrate/064_add_users_profile.rb b/db/migrate/064_add_users_profile.rb deleted file mode 100644 index fa517cad32..0000000000 --- a/db/migrate/064_add_users_profile.rb +++ /dev/null @@ -1,32 +0,0 @@ -class AddUsersProfile < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - # there's technically no need for these serialize declaration because in - # this script active_config and staged_config will always be NULL anyway. - serialize :active_config - serialize :staged_config - end - - def self.up - say "Creating users profiles" - create_table :profiles do |t| - t.column :label, :string - t.column :nicename, :string - add_column(:users, :profile_id, :integer, :default => 1) - end - - Profile.transaction do - admin = Profile.create(:label => 'admin', :nicename => 'Typo administrator') - Profile.create(:label => 'publisher', :nicename => 'Blog publisher') - Profile.create(:label => 'contributor', :nicename => 'Contributor') - end - end - - def self.down - drop_table :profiles - remove_column :users, :profile_id - end -end - - diff --git a/db/migrate/065_add_users_rights.rb b/db/migrate/065_add_users_rights.rb deleted file mode 100644 index 2e46e20ac3..0000000000 --- a/db/migrate/065_add_users_rights.rb +++ /dev/null @@ -1,119 +0,0 @@ -class AddUsersRights < ActiveRecord::Migration - class Right < ActiveRecord::Base - include BareMigration - - # there's technically no need for these serialize declaration because in - # this script active_config and staged_config will always be NULL anyway. - serialize :active_config - serialize :staged_config - end - - class ProfilesToRight < ActiveRecord::Base - include BareMigration - - # there's technically no need for these serialize declaration because in - # this script active_config and staged_config will always be NULL anyway. - serialize :active_config - serialize :staged_config - end - - class Profile < ActiveRecord::Base - end - - def self.up - say "Creating users rights" - create_table :rights, :force => true do |t| - t.column :name, :string - t.column :description, :string - end - - create_table :profiles_to_rights, :force => true do |t| - t.column :profile_id, :int - t.column :right_id, :int - end - - Right.transaction do - admin = Profile.find_by_label('admin') - publisher = Profile.find_by_label('publisher') - contributor = Profile.find_by_label('contributor') - - # Global admin rights - right = Right.create(:name => 'admin', :description => 'Global administration') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - - # Article rights - right = Right.create(:name => 'content_create', :description => 'Create article') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'content_edit', :description => 'Edit article') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'content_delete', :description => 'Delete article') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - - # Categories rights - right = Right.create(:name => 'category_create', :description => 'Create a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'category_edit', :description => 'Edit a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'category_delete', :description => 'Delete a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - - # Page rights - right = Right.create(:name => 'page_create', :description => 'Create a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'page_edit', :description => 'Edit a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - right = Right.create(:name => 'page_delete', :description => 'Delete a category') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - - # Feedback - right = Right.create(:name => 'feedback_create', :description => 'Add a comment') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - right = Right.create(:name => 'feedback_self_edit', :description => 'Edit self comments') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - right = Right.create(:name => 'feedback_edit', :description => 'Edit any comment') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - right = Right.create(:name => 'feedback_self_delete', :description => 'Delete self comments') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - right = Right.create(:name => 'feedback_delete', :description => 'Delete any comment') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - - # Users - right = Right.create(:name => 'user_create', :description => 'Create users') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - right = Right.create(:name => 'user_edit', :description => 'Edit users') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - right = Right.create(:name => 'user_self_edit', :description => 'Edit self account') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => publisher.id, :right_id => right.id) - ProfilesToRight.create(:profile_id => contributor.id, :right_id => right.id) - right = Right.create(:name => 'user_delete', :description => 'Delete users') - ProfilesToRight.create(:profile_id => admin.id, :right_id => right.id) - end - end - - def self.down - drop_table :rights - drop_table :profiles_to_rights - end -end - - diff --git a/db/migrate/066_fix_profiles.rb b/db/migrate/066_fix_profiles.rb deleted file mode 100644 index 046ab77dc7..0000000000 --- a/db/migrate/066_fix_profiles.rb +++ /dev/null @@ -1,23 +0,0 @@ -class FixProfiles < ActiveRecord::Migration - # We got this migration wrong before. Easiest fix is to undo it, then reapply - # correctly - - class User < ActiveRecord::Base - include BareMigration - end - - class Profile < ActiveRecord::Base - end - - def self.up - remove_column :users, :profile_id - add_column :users, :profile_id, :integer - admin_id = Profile.find_by_label('admin').id - User.update_all("profile_id = #{admin_id}") - end - - def self.down - remove_column :users, :profile_id - add_column :users, :profile_id, :integer, :default => 1 - end -end diff --git a/db/migrate/067_remove_blog_ids.rb b/db/migrate/067_remove_blog_ids.rb deleted file mode 100644 index e7e5293cd5..0000000000 --- a/db/migrate/067_remove_blog_ids.rb +++ /dev/null @@ -1,43 +0,0 @@ -class RemoveBlogIds < ActiveRecord::Migration - class Content < ActiveRecord::Base - set_inheritance_column :bogustype - end - - class Feedback < ActiveRecord::Base - set_table_name "feedback" - end - - class Sidebar < ActiveRecord::Base - end - - def self.up - if adapter_name == 'PostgreSQL' - indexes(:contents).each do |index| - if index.name =~ /blog_id/ - remove_index(:contents, :name => index.name) - end - end - else - remove_index :contents, :blog_id rescue nil - end - remove_column :contents, :blog_id - remove_column :sidebars, :blog_id - remove_column :feedback, :blog_id - end - - def self.down - add_column :contents, :blog_id, :integer - add_column :sidebars, :blog_id, :integer - add_column :feedback, :blog_id, :integer - - default_blog_id = Blog.find(:first, :order => 'id').id - - Content.update_all("blog_id = #{default_blog_id}") - Feedback.update_all("blog_id = #{default_blog_id}") - Sidebar.update_all("blog_id = #{default_blog_id}") - - change_column :sidebars, :blog_id, :integer, :null => false - - add_index :contents, :blog_id - end -end diff --git a/db/migrate/068_fix_grants.rb b/db/migrate/068_fix_grants.rb deleted file mode 100644 index 2976e03e15..0000000000 --- a/db/migrate/068_fix_grants.rb +++ /dev/null @@ -1,13 +0,0 @@ -class FixGrants < ActiveRecord::Migration - def self.up - say_with_time "Renaming ProfilesToRight to ProfilesRight" do - rename_table :profiles_to_rights, :profiles_rights - end - end - - def self.down - rename_table :profiles_rights, :profiles_to_rights - end -end - - diff --git a/db/migrate/069_add_modules_to_profile.rb b/db/migrate/069_add_modules_to_profile.rb deleted file mode 100644 index 9b9a289915..0000000000 --- a/db/migrate/069_add_modules_to_profile.rb +++ /dev/null @@ -1,18 +0,0 @@ -class AddModulesToProfile < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - serialize :profiles - end - - def self.up - add_column :profiles, :modules, :text - - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings]) - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback ]) - end - - def self.down - remove_column :profiles, :modules - end -end diff --git a/db/migrate/070_add_users_to_non_admins.rb b/db/migrate/070_add_users_to_non_admins.rb deleted file mode 100644 index 2ed0d65dd9..0000000000 --- a/db/migrate/070_add_users_to_non_admins.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddUsersToNonAdmins < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - serialize :profiles - end - - def self.up - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :users ]) - Profile.find_by_label("contributor").update_attributes(:modules => [:dashboard, :users ]) - end - - def self.down - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback ]) - Profile.find_by_label("contributor").update_attributes(:modules => []) - end -end diff --git a/db/migrate/071_fix_tags_naming.rb b/db/migrate/071_fix_tags_naming.rb deleted file mode 100644 index 7d754f88d7..0000000000 --- a/db/migrate/071_fix_tags_naming.rb +++ /dev/null @@ -1,21 +0,0 @@ -class FixTagsNaming < ActiveRecord::Migration - class Tag < ActiveRecord::Base - end - - def self.up - tags = Tag.find(:all) - tags.each do |tag| - tag.name = tag.name.gsub('.', '-') - tag.save! - end - end - - def self.down - tags = Tag.find(:all) - tags.each do |tag| - tag.name = tag.display_name.gsub('-', '.') - tag.name = tag.name.gsub(' ', '').downcase - tag.save! - end - end -end diff --git a/db/migrate/072_add_remember_token.rb b/db/migrate/072_add_remember_token.rb deleted file mode 100644 index ff6c874ea0..0000000000 --- a/db/migrate/072_add_remember_token.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRememberToken < ActiveRecord::Migration - def self.up - add_column :users, :remember_token, :string - end - - def self.down - remove_column :users, :remember_token - end -end \ No newline at end of file diff --git a/db/migrate/073_add_meta_and_subcategories.rb b/db/migrate/073_add_meta_and_subcategories.rb deleted file mode 100644 index f7d0463dd6..0000000000 --- a/db/migrate/073_add_meta_and_subcategories.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddMetaAndSubcategories < ActiveRecord::Migration - def self.up - add_column :categories, :keywords, :text - add_column :categories, :description, :text - add_column :categories, :parent_id, :integer - end - - def self.down - remove_column :categories, :keywords - remove_column :categories, :description - remove_column :categories, :parent_id - end -end diff --git a/db/migrate/074_add_remember_token_expires_at.rb b/db/migrate/074_add_remember_token_expires_at.rb deleted file mode 100644 index 10df497465..0000000000 --- a/db/migrate/074_add_remember_token_expires_at.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddRememberTokenExpiresAt < ActiveRecord::Migration - def self.up - add_column :users, :remember_token_expires_at, :datetime - end - - def self.down - remove_column :users, :remember_token_expires_at - end -end \ No newline at end of file diff --git a/db/migrate/075_move_editor_to_user.rb b/db/migrate/075_move_editor_to_user.rb deleted file mode 100644 index 453c493a63..0000000000 --- a/db/migrate/075_move_editor_to_user.rb +++ /dev/null @@ -1,13 +0,0 @@ -class MoveEditorToUser < ActiveRecord::Migration - class User < ActiveRecord::Base - end - - def self.up - add_column :users, :editor, :integer, :default => 2 - User.update_all("editor = #{Blog.default.editor.to_i}") - end - - def self.down - remove_column :users, :editor - end -end diff --git a/db/migrate/076_fix_users_empty_email.rb b/db/migrate/076_fix_users_empty_email.rb deleted file mode 100644 index ddce017262..0000000000 --- a/db/migrate/076_fix_users_empty_email.rb +++ /dev/null @@ -1,18 +0,0 @@ -class FixUsersEmptyEmail < ActiveRecord::Migration - class User < ActiveRecord::Base - end - - def self.up - users = User.find(:all) - users.each do |user| - if user.email.empty? - user.email = "typo@typo" - user.save! - end - end - end - - def self.down - - end -end diff --git a/db/migrate/077_fix_userless_articles.rb b/db/migrate/077_fix_userless_articles.rb deleted file mode 100644 index 91cd8a9537..0000000000 --- a/db/migrate/077_fix_userless_articles.rb +++ /dev/null @@ -1,27 +0,0 @@ -class FixUserlessArticles < ActiveRecord::Migration - class User < ActiveRecord::Base - end - class Content < ActiveRecord::Base - end - class Article < Content - end - - def self.up - unless $schema_generator - articles = Article.find(:all) - say "Fixing articles with empty user_id" - - articles.each do |article| - if article.user.nil? - say "Fixing article #{article.id} having empty user", true - article.user_id = 1 - article.save! - end - end - end - end - - def self.down - - end -end diff --git a/db/migrate/078_add_textfilter_to_users.rb b/db/migrate/078_add_textfilter_to_users.rb deleted file mode 100644 index 535356c19a..0000000000 --- a/db/migrate/078_add_textfilter_to_users.rb +++ /dev/null @@ -1,20 +0,0 @@ -class AddTextfilterToUsers < ActiveRecord::Migration - class TextFilter < ActiveRecord::Base - end - class User < ActiveRecord::Base - end - - def self.up - f = TextFilter.find(:first, :conditions => ["name = ?", "none"]) - add_column :users, :text_filter_id, :string, :default => f.id - - unless Blog.default.nil? - t = TextFilter.find(:first, :conditions => "name= '#{Blog.default.text_filter}'") - User.update_all("text_filter_id = #{t.id}") - end - end - - def self.down - remove_column :users, :text_filter_id, :integer - end -end diff --git a/db/migrate/079_move_editor_as_string.rb b/db/migrate/079_move_editor_as_string.rb deleted file mode 100644 index 9623b59a0f..0000000000 --- a/db/migrate/079_move_editor_as_string.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MoveEditorAsString < ActiveRecord::Migration - class User < ActiveRecord::Base - end - - def self.up - remove_column :users, :editor - add_column :users, :editor, :string, :default => 'simple' - - unless $schema_generator - User.update_all("editor = 'simple'") - end - - end - - def self.down - remove_column :users, :editor - add_column :users, :editor, :integer, :default => 0 - end -end diff --git a/db/migrate/080_add_state_to_user.rb b/db/migrate/080_add_state_to_user.rb deleted file mode 100644 index 73cc05462e..0000000000 --- a/db/migrate/080_add_state_to_user.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddStateToUser < ActiveRecord::Migration - class User < ActiveRecord::Base - end - - def self.up - add_column :users, :state, :string, :default => 'active' - - unless $schema_generator - User.update_all("state = 'active'") - end - - end - - def self.down - remove_column :users, :state - end -end diff --git a/db/migrate/081_create_cache_informations.rb b/db/migrate/081_create_cache_informations.rb deleted file mode 100644 index 52eb36965b..0000000000 --- a/db/migrate/081_create_cache_informations.rb +++ /dev/null @@ -1,66 +0,0 @@ -class CreateCacheInformations < ActiveRecord::Migration - class PageCache < ActiveRecord::Base - - def self.public_path - ActionController::Base.page_cache_directory - end - - def self.zap_pages(paths) - # Ensure no one is going to wipe his own blog public directory - # It happened once on a release and was no fun at all - return if public_path == "#{::Rails.root.to_s}/public" - srcs = paths.map { |v| - Dir.glob(public_path + "/#{v}") - }.flatten - return true if srcs.empty? - trash = ::Rails.root.to_s + "/tmp/typodel.#{UUIDTools::UUID.random_create}" - FileUtils.makedirs(trash) - FileUtils.mv(srcs, trash, :force => true) - FileUtils.rm_rf(trash) - end - - def self.old_sweep_all - logger.debug "PageCache - sweep_all called by #{caller[1].inspect}" - unless Blog.default.nil? - self.zap_pages(%w{index.* articles.* pages page - pages.* feedback feedback.* - comments comments.* - category categories.* xml - sitemap.xml - *.rss *.atom - tag tags.* category archives.*}) - - self.zap_pages((1990..2020)) - self.zap_pages([*1990..2020].collect { |y| "#{y}.*" }) - end - end - - end - - def self.up - - # With this migration, Old cache is useless. So we need delete all old cache - # Now what page is in cache is manage by cache_informations table - PageCache.old_sweep_all - - # In commit before, cache manage by file. We delete this cache if exist. - # It's use only to all edge blog updated several time - if File.exist?(File.join(Rails.root,'path_cache')) - File.read(File.join(Rails.root,'path_cache')).split("\n").each do |page_save| - FileUtils.rm File.join(PageCache.public_path, page_save) - end - FileUtils.rm_f File.join(Rails.root,'path_cache') - end - - create_table :cache_informations do |t| - t.string :path - t.timestamps - end - # Add index on path because there are validates_uniqueness on it - add_index :cache_informations, :path - end - - def self.down - drop_table :cache_informations - end -end diff --git a/db/migrate/082_add_users_options.rb b/db/migrate/082_add_users_options.rb deleted file mode 100644 index eade96b28f..0000000000 --- a/db/migrate/082_add_users_options.rb +++ /dev/null @@ -1,39 +0,0 @@ -class AddUsersOptions < ActiveRecord::Migration - class User < ActiveRecord::Base - end - - def self.up - add_column :users, :firstname, :string - add_column :users, :lastname, :string - add_column :users, :nickname, :string - add_column :users, :url, :string - add_column :users, :msn, :string - add_column :users, :aim, :string - add_column :users, :yahoo, :string - add_column :users, :twitter, :string - add_column :users, :description, :text - remove_column :users, :notify_via_jabber - - unless $schema_generator - users = User.find(:all) - users.each do |user| - user.nickname = user.name - user.save! - end - end - end - - def self.down - remove_column :users, :firstname - remove_column :users, :lastname - remove_column :users, :nickname - remove_column :users, :url - remove_column :users, :msn - remove_column :users, :aim - remove_column :users, :jabber - remove_column :users, :twitter - remove_column :users, :yahoo - remove_column :users, :description - add_column :users, :notify_via_jabber, :tinyint - end -end diff --git a/db/migrate/083_add_users_display_perms.rb b/db/migrate/083_add_users_display_perms.rb deleted file mode 100644 index ec73ac6b3b..0000000000 --- a/db/migrate/083_add_users_display_perms.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AddUsersDisplayPerms < ActiveRecord::Migration - def self.up - add_column :users, :show_url, :boolean - add_column :users, :show_msn, :boolean - add_column :users, :show_aim, :boolean - add_column :users, :show_yahoo, :boolean - add_column :users, :show_twitter, :boolean - add_column :users, :show_jabber, :boolean - end - - def self.down - remove_column :users, :show_url - remove_column :users, :show_msn - remove_column :users, :show_aim - remove_column :users, :show_yahoo - remove_column :users, :show_twitter - remove_column :users, :show_jabber - end -end diff --git a/db/migrate/084_move_users_to_profiles.rb b/db/migrate/084_move_users_to_profiles.rb deleted file mode 100644 index 0d9a69ce1f..0000000000 --- a/db/migrate/084_move_users_to_profiles.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MoveUsersToProfiles < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - serialize :profiles - end - - def self.up - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :profile ]) - Profile.find_by_label("contributor").update_attributes(:modules => [:dashboard, :profile ]) - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings, :profile]) - end - - def self.down - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :users ]) - Profile.find_by_label("contributor").update_attributes(:modules => [:dashboard, :users ]) - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings ]) - end -end diff --git a/db/migrate/085_add_article_parent_draft.rb b/db/migrate/085_add_article_parent_draft.rb deleted file mode 100644 index 0b10409ff2..0000000000 --- a/db/migrate/085_add_article_parent_draft.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddArticleParentDraft < ActiveRecord::Migration - def self.up - add_column :contents, :parent_id, :integer - end - - def self.down - remove_column :contents, :parent_id - end -end diff --git a/db/migrate/086_add_user_last_connection.rb b/db/migrate/086_add_user_last_connection.rb deleted file mode 100644 index dc988d48f1..0000000000 --- a/db/migrate/086_add_user_last_connection.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddUserLastConnection < ActiveRecord::Migration - def self.up - add_column :users, :last_connection, :datetime - end - - def self.down - remove_column :users, :last_connection - end -end diff --git a/db/migrate/087_drop_blacklist_patterns.rb b/db/migrate/087_drop_blacklist_patterns.rb deleted file mode 100644 index 4e683c3da5..0000000000 --- a/db/migrate/087_drop_blacklist_patterns.rb +++ /dev/null @@ -1,14 +0,0 @@ -class DropBlacklistPatterns < ActiveRecord::Migration - def self.up - drop_table :blacklist_patterns - end - - def self.down - create_table :blacklist_patterns do |t| - t.column :type, :string - t.column :pattern, :string - end - - add_index :blacklist_patterns, :pattern - end -end diff --git a/db/migrate/088_drop_session_table.rb b/db/migrate/088_drop_session_table.rb deleted file mode 100644 index dccd970fde..0000000000 --- a/db/migrate/088_drop_session_table.rb +++ /dev/null @@ -1,16 +0,0 @@ -class DropSessionTable < ActiveRecord::Migration - def self.up - drop_table :sessions - end - - def self.down - create_table :sessions do |t| - t.column :sessid, :string - t.column :data, :text - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - - add_index :sessions, :sessid - end -end diff --git a/db/migrate/089_drop_cache_information_table.rb b/db/migrate/089_drop_cache_information_table.rb deleted file mode 100644 index e6b3ac3a24..0000000000 --- a/db/migrate/089_drop_cache_information_table.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Dummy class to declare the model before droping -class CacheInformation < ActiveRecord::Base - -end - -class DropCacheInformationTable < ActiveRecord::Migration - def self.up - # On 99.9% existing blogs, cache will be installed in public/ - # That means we first need to wipe existing files or they will be served - # And the cache will never be accessed - list = CacheInformation.find(:all) - - list.each do |file| - path = File.join(::Rails.root.to_s, 'public', file.path) - if File.exist?(path) - FileUtils.rm(path) - end - end - - drop_table :cache_informations - end - - def self.down - create_table :cache_informations do |t| - t.string :path - t.timestamps - end - # Add index on path because there are validates_uniqueness on it - add_index :cache_informations, :path - end -end diff --git a/db/migrate/090_remove_keywords_from_posts.rb b/db/migrate/090_remove_keywords_from_posts.rb deleted file mode 100644 index 15d0f4a75a..0000000000 --- a/db/migrate/090_remove_keywords_from_posts.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveKeywordsFromPosts < ActiveRecord::Migration - def self.up - remove_column :contents, :keywords - end - - def self.down - add_column :contents, :keywords, :string - end -end diff --git a/db/migrate/091_adds_password_protection_to_posts.rb b/db/migrate/091_adds_password_protection_to_posts.rb deleted file mode 100644 index e48feccd15..0000000000 --- a/db/migrate/091_adds_password_protection_to_posts.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddsPasswordProtectionToPosts < ActiveRecord::Migration - def self.up - add_column :contents, :password, :string - end - - def self.down - remove_column :contents, :password - end -end diff --git a/db/migrate/092_drops_profile_rights_primary_key.rb b/db/migrate/092_drops_profile_rights_primary_key.rb deleted file mode 100644 index ff3360fcbf..0000000000 --- a/db/migrate/092_drops_profile_rights_primary_key.rb +++ /dev/null @@ -1,9 +0,0 @@ -class DropsProfileRightsPrimaryKey < ActiveRecord::Migration - def self.up - remove_column :profiles_rights, :id - end - - def self.down - add_column :profiles_rights, :id, :integer - end -end diff --git a/db/migrate/093_add_redirections_model.rb b/db/migrate/093_add_redirections_model.rb deleted file mode 100644 index d55af61fa3..0000000000 --- a/db/migrate/093_add_redirections_model.rb +++ /dev/null @@ -1,58 +0,0 @@ -class AddRedirectionsModel < ActiveRecord::Migration - class Redirect < ActiveRecord::Base - has_many :redirections - has_many :contents, :through => :redirections - end - - class Redirection < ActiveRecord::Base - belongs_to :content - belongs_to :redirect - end - - class Content < ActiveRecord::Base - has_many :redirections - has_many :redirects, :through => :redirections - scope :already_published, { - :conditions => ['published = ? AND published_at < ?', true, Time.now] } - - # Avoid STI errors - set_inheritance_column :bogustype - end - - def self.up - create_table :redirections do |t| - t.column :content_id, :integer - t.column :redirect_id, :integer - end - - say_with_time "Creating shortened URL for existing contents, this may take a moment" do - Content.already_published.each do |art| - - # Begin / rescue statement is mandatory here because I have something - # fishy in my database coming from a very old Wordpress import - # This can happen you too - begin - say "Processing #{art.type} #{art.id}", true - red = Redirect.new - red.from_path = red.shorten - red.to_path = art.permalink_url - art.redirects << red - art.save - rescue - nil - end - end - end - end - - def self.down - Content.already_published.each do |art| - art.redirects.each do |red| - red.destroy - end - end - - drop_table :redirections - end -end - diff --git a/db/migrate/094_fix_extended_on_rss_behavior.rb b/db/migrate/094_fix_extended_on_rss_behavior.rb deleted file mode 100644 index 10db5e02ef..0000000000 --- a/db/migrate/094_fix_extended_on_rss_behavior.rb +++ /dev/null @@ -1,14 +0,0 @@ -class FixExtendedOnRssBehavior < ActiveRecord::Migration - def self.up - unless Blog.default.nil? - Blog.default.hide_extended_on_rss = true unless Blog.default.show_extended_on_rss - Blog.default.save! - end - end - - def self.down - blog = Blog.first - Blog.default.show_extended_on_rss = true unless Blog.default.hide_extended_on_rss - Blog.default.save! - end -end diff --git a/db/migrate/095_adds_seo_to_profiles.rb b/db/migrate/095_adds_seo_to_profiles.rb deleted file mode 100644 index 54bf2cb264..0000000000 --- a/db/migrate/095_adds_seo_to_profiles.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddsSeoToProfiles < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - serialize :profiles - end - - def self.up - say "Adding the seo module to admin profile" - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings, :profile, :seo]) - end - - def self.down - say "Removing the seo module to admin profile" - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings, :profile ]) - end -end diff --git a/db/migrate/096_add_origin_to_redirects.rb b/db/migrate/096_add_origin_to_redirects.rb deleted file mode 100644 index 385914470c..0000000000 --- a/db/migrate/096_add_origin_to_redirects.rb +++ /dev/null @@ -1,47 +0,0 @@ -class AddOriginToRedirects < ActiveRecord::Migration - class Redirect < ActiveRecord::Base - has_many :redirections - has_many :contents, :through => :redirections - end - - class Redirection < ActiveRecord::Base - belongs_to :content - belongs_to :redirect - end - - class Content < ActiveRecord::Base - has_many :redirections - has_many :redirects, :through => :redirections - scope :already_published, { - :conditions => ['published = ? AND published_at < ?', true, Time.now] } - - # Avoid STI errors - set_inheritance_column :bogustype - end - - def self.up - add_column :redirects, :origin, :string - - say "Adding origin to redirects made by URL shortener" - Content.already_published.each do |art| - - # Begin / rescue statement is mandatory here because I have something - # fishy in my database coming from a very old Wordpress import - # This can happen you too - begin - say "Processing #{art.type} #{art.id}", true - art.redirects.each do |r| - r.origin = "shortener" - r.save! - end - rescue - nil - end - end - end - - def self.down - remove_column :redirects, :origin - end -end - diff --git a/db/migrate/097_fix_nofollow_options_behavior.rb b/db/migrate/097_fix_nofollow_options_behavior.rb deleted file mode 100644 index 93467995c0..0000000000 --- a/db/migrate/097_fix_nofollow_options_behavior.rb +++ /dev/null @@ -1,18 +0,0 @@ -class FixNofollowOptionsBehavior < ActiveRecord::Migration - def self.up - unless Blog.default.nil? - Blog.default.unindex_categories = false if Blog.default.index_categories - Blog.default.unindex_tags = false if Blog.default.index_tags - Blog.default.dofollowify = true unless Blog.default.nofollowify - Blog.default.save! - end - end - - def self.down - blog = Blog.first - Blog.default.index_categories = true unless Blog.default.unindex_categories - Blog.default.index_tags = true unless Blog.default.unindex_tags - Blog.default.dofollowify = true unless Blog.default.nofollowify - Blog.default.save! - end -end diff --git a/db/migrate/098_add_users_settings.rb b/db/migrate/098_add_users_settings.rb deleted file mode 100644 index be2fbb028c..0000000000 --- a/db/migrate/098_add_users_settings.rb +++ /dev/null @@ -1,228 +0,0 @@ -class AddUsersSettings < ActiveRecord::Migration - class BareSetting < ActiveRecord::Base - include BareMigration - belongs_to :user, :class_name => "AddUsersSettings::BareUser" - end - - class BareUser < ActiveRecord::Base - include BareMigration - serialize :settings - - class SettingSpec - attr_accessor :key, :type, :default - - def initialize(key, type, default) - self.key = key - self.type = type - self.default = default - end - - def normalize_value(line) - if !line || line.value.nil? - return default - end - value = line.value - case type - when :boolean - ! value.match(/^(?:f(?:alse)?|0|)$/) - when :integer - value.to_i - when :string - value - else - YAML::load(value) - end - end - - def stringify_value(value) - case type - when :boolean - value.to_s - when :integer - value.to_s - when :string - value - else - value.to_yaml - end - end - end - - def self.fields(key = nil) - @@fields ||= { } - key ? @@fields[key.to_sym] : @@fields - end - - def self.setting(key, type, default) - fields[key.to_sym] = SettingSpec.new(key.to_sym, type, default) - end - - setting :notify_watch_my_articles, :boolean, true - setting :editor, :string, 'visual' - setting :firstname, :string, '' - setting :lastname, :string, '' - setting :nickname, :string, '' - setting :description, :string, '' - setting :url, :string, '' - setting :msn, :string, '' - setting :aim, :string, '' - setting :yahoo, :string, '' - setting :twitter, :string, '' - setting :jabber, :string, '' - setting :show_url, :boolean, false - setting :show_msn, :boolean, false - setting :show_aim, :boolean, false - setting :show_yahoo, :boolean, false - setting :show_twitter, :boolean, false - setting :show_jabber, :boolean, false - - end - - def self.up - # There must be a better way to do it but... - # 1. I didn't find it. - # 2. I'm lost in the countryside where I need to go to the back of the - # garden to have a phone connection and in the middle of a field to have - # a chance to get my emails. - # - # Problem: settings names overlap fields names. - # Solution: rename columns, migrate, remove columns. - # - # At least it works - # - # Some fields were not migrated because we do some User.find on them : - # – notify_via_email - # – notify_on_new_articles - # – notify_on_comments - # - - rename_column :users, :notify_watch_my_articles, :s_notify_watch_my_articles - rename_column :users, :editor, :s_editor - rename_column :users, :firstname, :s_firstname - rename_column :users, :lastname, :s_lastname - rename_column :users, :nickname, :s_nickname - rename_column :users, :description, :s_description - rename_column :users, :url, :s_url - rename_column :users, :msn, :s_msn - rename_column :users, :aim, :s_aim - rename_column :users, :yahoo, :s_yahoo - rename_column :users, :twitter, :s_twitter - rename_column :users, :jabber, :s_jabber - rename_column :users, :show_url, :s_show_url - rename_column :users, :show_msn, :s_show_msn - rename_column :users, :show_aim, :s_show_aim - rename_column :users, :show_yahoo, :s_show_yahoo - rename_column :users, :show_twitter, :s_show_twitter - rename_column :users, :show_jabber, :s_show_jabber - add_column :users, :settings, :text - - unless $schema_generator - begin - BareSetting.transaction do - BareUser.find(:all).each do |user| - user.settings = { } -# user.settings['notify_via_email'] = user.s_notify_via_email -# user.settings['notify_on_new_articles'] = user.s_notify_on_new_articles -# user.settings['notify_on_comments'] = user.s_notify_on_comments - user.settings['notify_watch_my_articles'] = user.s_notify_watch_my_articles -# user.settings['text_filter_id'] = user.s_text_filter_id - user.settings['editor'] = user.s_editor - user.settings['firstname'] = user.s_firstname - user.settings['lastname'] = user.s_lastname - user.settings['nickname'] = user.s_nickname - user.settings['description'] = user.s_description - user.settings['url'] = user.s_url - user.settings['msn'] = user.s_msn - user.settings['aim'] = user.s_aim - user.settings['yahoo'] = user.s_yahoo - user.settings['twitter'] = user.s_twitter - user.settings['jabber'] = user.s_jabber - user.settings['show_url'] = user.s_show_url - user.settings['show_msn'] = user.s_show_msn - user.settings['show_aim'] = user.s_show_aim - user.settings['show_yahoo'] = user.s_show_yahoo - user.settings['show_twitter'] = user.s_show_twitter - user.settings['show_jabber'] = user.s_show_jabber - user.save - end - end - rescue Exception => e - rename_column :users, :s_notify_watch_my_articles, :notify_watch_my_articles - rename_column :users, :s_editor, :editor - rename_column :users, :s_firstname, :firstname - rename_column :users, :s_lastname, :lastname - rename_column :users, :s_nickname, :nickname - rename_column :users, :s_description, :description - rename_column :users, :s_url, :url - rename_column :users, :s_msn, :msn - rename_column :users, :s_aim, :aim - rename_column :users, :s_yahoo, :yahoo - rename_column :users, :s_twitter, :twitter - rename_column :users, :s_jabber, :jabber - rename_column :users, :s_show_url, :show_url - rename_column :users, :s_show_msn, :show_msn - rename_column :users, :s_show_aim, :show_aim - rename_column :users, :s_show_yahoo, :show_yahoo - rename_column :users, :s_show_twitter, :show_twitter - rename_column :users, :s_show_jabber, :show_jabber - remove_column :users, :settings rescue nil - raise e - end - end - - remove_column :users, :s_notify_watch_my_articles - remove_column :users, :s_editor - remove_column :users, :s_firstname - remove_column :users, :s_lastname - remove_column :users, :s_nickname - remove_column :users, :s_description - remove_column :users, :s_url - remove_column :users, :s_msn - remove_column :users, :s_aim - remove_column :users, :s_yahoo - remove_column :users, :s_twitter - remove_column :users, :s_jabber - remove_column :users, :s_show_url - remove_column :users, :s_show_msn - remove_column :users, :s_show_aim - remove_column :users, :s_show_yahoo - remove_column :users, :s_show_twitter - remove_column :users, :s_show_jabber - - end - - def self.down - # FIXME: The code below does not reverse this migration! - raise ActiveRecord::IrreversibleMigration - begin - create_settings - unless $schema_generator - BareSetting.transaction do - BareBlog.find(:all).each do |blog| - blog.settings ||= { } - BareSetting.with_scope(:create => { :blog_id => blog.id }) do - BareBlog.fields.each do |key, spec| - next unless blog.settings.has_key?(key.to_s) - BareSetting.create!(:name => key.to_s, - :value => spec.stringify_value(blog.settings[key.to_s])) - end - end - end - end - end - remove_column :blogs, :settings rescue nil - rescue Exception => e - drop_table :settings rescue nil - raise e - end - end - - def self.create_settings - create_table :settings do |t| - t.column :name, :string, :limit => 255 - t.column :value, :string, :limit => 255 - t.column :position, :integer - t.column :blog_id, :integer - end - end -end diff --git a/db/migrate/099_splits_content_rules_articles_pages.rb b/db/migrate/099_splits_content_rules_articles_pages.rb deleted file mode 100644 index fdd8005847..0000000000 --- a/db/migrate/099_splits_content_rules_articles_pages.rb +++ /dev/null @@ -1,19 +0,0 @@ -class SplitsContentRulesArticlesPages < ActiveRecord::Migration - class Profile < ActiveRecord::Base - include BareMigration - - serialize :profiles - end - - def self.up - say "Splits content modules into pages and articles" - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :articles, :pages, :media, :feedback, :themes, :sidebar, :users, :settings, :profile, :seo]) - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :articles, :media, :pages, :feedback, :profile]) - end - - def self.down - say "Merges pages and articles to content" - Profile.find_by_label("admin").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :themes, :sidebar, :users, :settings, :profile, :seo ]) - Profile.find_by_label("publisher").update_attributes(:modules => [:dashboard, :write, :content, :feedback, :profile ]) - end -end diff --git a/db/migrate/100_adds_content_settings.rb b/db/migrate/100_adds_content_settings.rb deleted file mode 100644 index 8e6a099b42..0000000000 --- a/db/migrate/100_adds_content_settings.rb +++ /dev/null @@ -1,132 +0,0 @@ -class AddsContentSettings < ActiveRecord::Migration - class BareSetting < ActiveRecord::Base - include BareMigration - belongs_to :user, :class_name => "AddsContentSettings::BareContent" - end - - class BareContent < ActiveRecord::Base - include BareMigration - serialize :settings - - class SettingSpec - attr_accessor :key, :type, :default - - def initialize(key, type, default) - self.key = key - self.type = type - self.default = default - end - - def normalize_value(line) - if !line || line.value.nil? - return default - end - value = line.value - case type - when :boolean - ! value.match(/^(?:f(?:alse)?|0|)$/) - when :integer - value.to_i - when :string - value - else - YAML::load(value) - end - end - - def stringify_value(value) - case type - when :boolean - value.to_s - when :integer - value.to_s - when :string - value - else - value.to_yaml - end - end - end - - def self.fields(key = nil) - @@fields ||= { } - key ? @@fields[key.to_sym] : @@fields - end - - def self.setting(key, type, default) - fields[key.to_sym] = SettingSpec.new(key.to_sym, type, default) - end - - setting :password, :string, '' - end - - def self.up - # There must be a better way to do it but... - # 1. I didn't find it. - # 2. I'm lost in the countryside where I need to go to the back of the - # garden to have a phone connection and in the middle of a field to have - # a chance to get my emails. - # - # Problem: settings names overlap fields names. - # Solution: rename columns, migrate, remove columns. - # - # At least it works - # - - rename_column :contents, :password, :s_password - add_column :contents, :settings, :text - - unless $schema_generator - begin - BareSetting.transaction do - BareContent.find(:all).each do |content| - content.settings = { } - content.settings['password'] = content.s_password - content.save - end - end - rescue Exception => e - rename_column :contents, :s_password, :password - remove_column :contents, :settings rescue nil - raise e - end - end - - remove_column :contents, :s_password - end - - def self.down - # FIXME: The code below does not reverse this migration! - raise ActiveRecord::IrreversibleMigration - begin - create_settings - unless $schema_generator - BareSetting.transaction do - BareBlog.find(:all).each do |blog| - blog.settings ||= { } - BareSetting.with_scope(:create => { :blog_id => blog.id }) do - BareBlog.fields.each do |key, spec| - next unless blog.settings.has_key?(key.to_s) - BareSetting.create!(:name => key.to_s, - :value => spec.stringify_value(blog.settings[key.to_s])) - end - end - end - end - end - remove_column :blogs, :settings rescue nil - rescue Exception => e - drop_table :settings rescue nil - raise e - end - end - - def self.create_settings - create_table :settings do |t| - t.column :name, :string, :limit => 255 - t.column :value, :string, :limit => 255 - t.column :position, :integer - t.column :blog_id, :integer - end - end -end diff --git a/db/migrate/101_adds_content_type.rb b/db/migrate/101_adds_content_type.rb deleted file mode 100644 index d131c66012..0000000000 --- a/db/migrate/101_adds_content_type.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddsContentType < ActiveRecord::Migration - def self.up - add_column :contents, :post_type, :string, :default => 'read' - - create_table :post_types do |t| - t.column :name, :string - t.column :permalink, :string - t.column :description, :string - end - end - - def self.down - remove_column :contents, :post_type - drop_table :post_types - end -end diff --git a/db/migrate/102_fixes_existing_articles_with_no_type.rb b/db/migrate/102_fixes_existing_articles_with_no_type.rb deleted file mode 100644 index 7d2cf27167..0000000000 --- a/db/migrate/102_fixes_existing_articles_with_no_type.rb +++ /dev/null @@ -1,20 +0,0 @@ -class FixesExistingArticlesWithNoType < ActiveRecord::Migration - - class Content < ActiveRecord::Base - end - class Article < Content - end - - - def self.up - say "Fixes existing articles with no post types" - Article.find(:all).each do |art| - art.post_type = "read" if art.post_type.empty? - art.save! - end - end - - def self.down - say "This migration does absolutely nothing" - end -end diff --git a/db/migrate/103_really_update_existing_articles_with_nil_or_empty_post_type.rb b/db/migrate/103_really_update_existing_articles_with_nil_or_empty_post_type.rb deleted file mode 100644 index db98a91168..0000000000 --- a/db/migrate/103_really_update_existing_articles_with_nil_or_empty_post_type.rb +++ /dev/null @@ -1,27 +0,0 @@ -class ReallyUpdateExistingArticlesWithNilOrEmptyPostType < ActiveRecord::Migration - class Content < ActiveRecord::Base - inheritance_column = :ignore_inheritance_column - end - - def self.up - say_with_time "Really fix existing articles with no post type." do - Content.find(:all, - :conditions => ['type = ?', 'Article']).each do |art| - if art.post_type.nil? or art.post_type.empty? - say "Fixing '#{art.title}'", 1 - art.post_type = "read" - - # this doesn't really belong here but since this migration - # would otherwise reset tags, it's better than nothing. - art.keywords = art.tags.collect(&:name).join(" ") - - art.save! - end - end - end - end - - def self.down - say "This rollback does nothing, but that's okay." - end -end diff --git a/db/migrate/104_adds_created_at_to_redirects.rb b/db/migrate/104_adds_created_at_to_redirects.rb deleted file mode 100644 index 3751c94411..0000000000 --- a/db/migrate/104_adds_created_at_to_redirects.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddsCreatedAtToRedirects < ActiveRecord::Migration - - def self.up - add_column :redirects, :created_at, :datetime - add_column :redirects, :updated_at, :datetime - - end - - def self.down - remove_column :redirects, :created_at - remove_column :redirects, :updated_at - end -end - diff --git a/db/schema.mysql-v3.sql b/db/schema.mysql-v3.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.mysql-v3.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema.mysql.sql b/db/schema.mysql.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.mysql.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema.postgresql.sql b/db/schema.postgresql.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.postgresql.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema.sqlite.sql b/db/schema.sqlite.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.sqlite.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema.sqlite3.sql b/db/schema.sqlite3.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.sqlite3.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema.sqlserver.sql b/db/schema.sqlserver.sql deleted file mode 100644 index 236e981c37..0000000000 --- a/db/schema.sqlserver.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Leaving this file empty forces the whole migration --- and fixes a bug when using Typo installer. --- Please, leave them as is. \ No newline at end of file diff --git a/db/schema_version b/db/schema_version deleted file mode 100644 index 8c0474e323..0000000000 --- a/db/schema_version +++ /dev/null @@ -1 +0,0 @@ -69 \ No newline at end of file diff --git a/db/scripts/fix_permalinks.rb b/db/scripts/fix_permalinks.rb deleted file mode 100755 index 0e9d6a6728..0000000000 --- a/db/scripts/fix_permalinks.rb +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/environment' -Article.find(:all).each do |a| - (puts "Processing #{a.title} (#{a.stripped_title})" ; a.save) if a.permalink.blank? -end diff --git a/db/seeds.rb b/db/seeds.rb deleted file mode 100644 index e62d0dfe5c..0000000000 --- a/db/seeds.rb +++ /dev/null @@ -1,44 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => cities.first) -Blog.create(:id => 1, :settings => {"canonical_server_url"=>""}, :base_url => "http://example.com/") -Category.create(:id => 1, :name => "General", :permalink => "general", :position => 1) -Profile.create(:id => 1, :label => "admin", :modules => [:dashboard, :articles, :pages, :media, :feedback, :themes, :sidebar, :users, :settings, :profile, :seo], :nicename => "Typo administrator") -Profile.create(:id => 2, :label => "publisher", :modules => [:dashboard, :articles, :media, :pages, :feedback, :profile], :nicename => "Blog publisher") -Profile.create(:id => 3, :label => "contributor", :modules => [:dashboard, :profile], :nicename => "Contributor") -Right.create(:description => "Global administration", :id => 1, :name => "admin") -Right.create(:description => "Create article", :id => 2, :name => "content_create") -Right.create(:description => "Edit article", :id => 3, :name => "content_edit") -Right.create(:description => "Delete article", :id => 4, :name => "content_delete") -Right.create(:description => "Create a category", :id => 5, :name => "category_create") -Right.create(:description => "Edit a category", :id => 6, :name => "category_edit") -Right.create(:description => "Delete a category", :id => 7, :name => "category_delete") -Right.create(:description => "Create a category", :id => 8, :name => "page_create") -Right.create(:description => "Edit a category", :id => 9, :name => "page_edit") -Right.create(:description => "Delete a category", :id => 10, :name => "page_delete") -Right.create(:description => "Add a comment", :id => 11, :name => "feedback_create") -Right.create(:description => "Edit self comments", :id => 12, :name => "feedback_self_edit") -Right.create(:description => "Edit any comment", :id => 13, :name => "feedback_edit") -Right.create(:description => "Delete self comments", :id => 14, :name => "feedback_self_delete") -Right.create(:description => "Delete any comment", :id => 15, :name => "feedback_delete") -Right.create(:description => "Create users", :id => 16, :name => "user_create") -Right.create(:description => "Edit users", :id => 17, :name => "user_edit") -Right.create(:description => "Edit self account", :id => 18, :name => "user_self_edit") -Right.create(:description => "Delete users", :id => 19, :name => "user_delete") -Sidebar.create(:active_position => 0, :config => {"maximum_pages"=>"10"}, :id => 1, :staged_position => 0, :type => "PageSidebar") -Sidebar.create(:active_position => 1, :config => {"empty"=>false, "count"=>true}, :id => 2, :staged_position => 1, :type => "CategorySidebar") -Sidebar.create(:active_position => 2, :config => {"show_count"=>true, "count"=>"10"}, :id => 3, :staged_position => 2, :type => "ArchivesSidebar") -Sidebar.create(:active_position => 3, :config => {"body"=>"\n", "title"=>"Links"}, :id => 4, :staged_position => 3, :type => "StaticSidebar") -Sidebar.create(:active_position => 4, :config => {"title"=>"Meta"}, :id => 5, :staged_position => 4, :type => "MetaSidebar") -TextFilter.create(:description => "None", :filters => [], :id => 1, :markup => "none", :name => "none", :params => {}) -TextFilter.create(:description => "Markdown", :filters => [], :id => 2, :markup => "markdown", :name => "markdown", :params => {}) -TextFilter.create(:description => "SmartyPants", :filters => [:smartypants], :id => 3, :markup => "none", :name => "smartypants", :params => {}) -TextFilter.create(:description => "Markdown with SmartyPants", :filters => [:smartypants], :id => 4, :markup => "markdown", :name => "markdown smartypants", :params => {}) -TextFilter.create(:description => "Textile", :filters => [], :id => 5, :markup => "textile", :name => "textile", :params => {}) -Article.create(:allow_comments => true, :allow_pings => true, :author => "Mr Typo", :body => "Welcome to Typo. This is your first article. Edit or delete it, then start blogging!", :guid => "1bf3e2ca-ed7b-4562-8a4a-8ce8438822c8", :id => 1, :permalink => "hello-world", :post_type => "read", :published => true, :published_at => "2012-06-09 21:51:55 UTC", :settings => {"password"=>""}, :state => "published", :text_filter_id => 5, :title => "Hello World!", :type => "Article", :user_id => 1) -Page.create(:body => "This is an example of a Typo page. You can edit this to write information about yourself or your site so readers know who you are. You can create as many pages as this one as you like and manage all of your content inside Typo.", :id => 2, :name => "about", :post_type => "read", :published => true, :published_at => "2012-06-09 21:51:55 UTC", :settings => {"password"=>""}, :state => "published", :text_filter_id => 5, :title => "about", :type => "Page", :user_id => 1) diff --git a/db/updates/update.168.to.200.mysql.sql b/db/updates/update.168.to.200.mysql.sql deleted file mode 100644 index 21aa4611fa..0000000000 --- a/db/updates/update.168.to.200.mysql.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE IF NOT EXISTS `blacklist_patterns` ( - `id` int(11) NOT NULL auto_increment, - `type` varchar(15) default NULL, - `pattern` varchar(255) default NULL, - PRIMARY KEY (`id`) -); - -CREATE TABLE IF NOT EXISTS `settings` ( - `id` int(11) NOT NULL auto_increment, - `name` varchar(40) default NULL, - `value` varchar(40) default NULL, - PRIMARY KEY (`id`) -); - -CREATE TABLE IF NOT EXISTS `sessions` ( - `id` int(11) unsigned NOT NULL auto_increment, - `sessid` varchar(32) default NULL, - `data` text, - `updated_at` datetime default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `sessid` (`sessid`) -); - -CREATE TABLE IF NOT EXISTS `users` ( - `id` int(11) NOT NULL auto_increment, - `login` varchar(80) default NULL, - `password` varchar(40) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `login` (`login`) -); - -ALTER TABLE `comments` ADD `ip` varchar(15) DEFAULT NULL; -ALTER TABLE `articles` ADD `text_filter` varchar(20) DEFAULT NULL; diff --git a/db/updates/update.168.to.200.psql.sql b/db/updates/update.168.to.200.psql.sql deleted file mode 100644 index e27509927e..0000000000 --- a/db/updates/update.168.to.200.psql.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE blacklist_patterns ( - id SERIAL PRIMARY KEY NOT NULL, - type varchar(15) default NULL, - pattern varchar(255) default NULL -); - -CREATE TABLE sessions ( - id SERIAL PRIMARY KEY NOT NULL, - sessid varchar(255) default NULL, - data text, - created_at TIMESTAMP DEFAULT now(), - updated_at TIMESTAMP DEFAULT now() -); - -CREATE TABLE settings ( - id SERIAL PRIMARY KEY NOT NULL, - name varchar(255) default NULL, - value varchar(255) default NULL, - position int default NULL -); - -CREATE TABLE users ( - id SERIAL PRIMARY KEY NOT NULL, - login varchar(40) default NULL, - password varchar(40) default NULL, - UNIQUE (login) -); - -ALTER TABLE comments ADD ip varchar(15) DEFAULT NULL; -ALTER TABLE articles ADD text_filter varchar(20) DEFAULT NULL; diff --git a/features/manage_categories.feature b/features/manage_categories.feature new file mode 100644 index 0000000000..5f0e8d7338 --- /dev/null +++ b/features/manage_categories.feature @@ -0,0 +1,34 @@ +Feature: Manage Categories + As a blog administrator + In order to organize my posts + I want to be able to add and edit categories + + Background: + Given the blog is set up + And I am logged into the admin panel + + Scenario: Successfully add a category + Given there are no categories + When I follow "Categories" + And I fill in "Name" with "Test" + And I press "Save" + Then I should see "Category was successfully saved." + And I should see "Test" + And I should have 1 category + + Scenario: Successfully edit a category + Given I have 1 category + When I follow "Categories" + When I follow "Edit" + And I fill in "Name" with "Another Test" + And I press "Save" + Then I should see "Category was successfully saved." + And I should see "Another Test" + And I should have 1 category + + Scenario: Unsuccessfully add a category + Given there are no categories + When I follow "Categories" + And I press "Save" + Then I should see "1 error prohibited this category from being saved" + And I should have 0 category diff --git a/features/merge_articles.feature b/features/merge_articles.feature new file mode 100644 index 0000000000..5db98ffdda --- /dev/null +++ b/features/merge_articles.feature @@ -0,0 +1,21 @@ +Feature: Merge Articles + As a blog administrator + In order to reduce blog clutter + I want to be able to merge together any two articles + + Background: + Given the blog is set up + And I am logged into the admin panel + And I have 2 articles published + + Scenario: Successfully merege two articles + Given I am on the admin content page + When I follow "Foobar" + Then I should be on the admin content edit page + And I should see "Lorem Ipsum" + And I should see "Merge Articles" + When I fill in "Merge Articles" with "2" + And I press "Merge" + Then I should be on the article show page + And I should see "Your artices have successfully merged" + And I should see "Lorem Ipsum./nLorem Ipsum." diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 6315105872..75ca29f768 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -18,6 +18,39 @@ # * http://elabs.se/blog/15-you-re-cuking-it-wrong # +Given /^there are no categories$/ do + Category.delete_all +end + +Then /^I should have (\d+) category$/ do |num| + Category.all.count == num.to_i +end + +Given /^I have (\d+) category$/ do |num| + num.to_i.times do + Category.create(name:"Test #{num}") + end +end + +Given /^I have (\d+) articles published$/ do |num| + num.to_i.times do + Article.create!({:type => "Article", + :title => "Foobar #{num}", + :author => "Test User", + :body => "Lorem Ipsum #{num}", + :extended => nil, + :excerpt => nil, + :user_id => 1, + :published => true, + :allow_pings => nil, + :allow_comments => nil, + :published_at => nil, + :state => "published", + :parent_id => nil, + :settings => {}, + :post_type => "read"}) + end +end require 'uri' require 'cgi' @@ -250,7 +283,7 @@ def with_scope(locator) end end end - + Then /^(?:|I )should be on (.+)$/ do |page_name| current_path = URI.parse(current_url).path if current_path.respond_to? :should @@ -264,8 +297,8 @@ def with_scope(locator) query = URI.parse(current_url).query actual_params = query ? CGI.parse(query) : {} expected_params = {} - expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} - + expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')} + if actual_params.respond_to? :should actual_params.should == expected_params else diff --git a/features/support/paths.rb b/features/support/paths.rb index e7e00e5d89..d62bcc1445 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -17,6 +17,8 @@ def path_to(page_name) '/' when /^the new article page$/ '/admin/content/new' + when /^the admin content edit page$/i + "/admin/content/edit/4" # Add more mappings here. # Here is an example that pulls values out of the Regexp: diff --git a/public/javascripts/ckeditor/config.bak b/public/javascripts/ckeditor/config.bak old mode 100644 new mode 100755 index 187db086f2..492800fd66 --- a/public/javascripts/ckeditor/config.bak +++ b/public/javascripts/ckeditor/config.bak @@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config ) config.PreserveSessionOnFileBrowser = true; // Define changes to default configuration here. For example: //config.language = ''; - config.uiColor = '#E0ECFF'; + config.uiColor = '#eee'; config.toolbar = 'Basic'; config.entities_greek = false; config.entities_latin = false; diff --git a/public/javascripts/ckeditor/config.js b/public/javascripts/ckeditor/config.js old mode 100644 new mode 100755 index 187db086f2..492800fd66 --- a/public/javascripts/ckeditor/config.js +++ b/public/javascripts/ckeditor/config.js @@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function( config ) config.PreserveSessionOnFileBrowser = true; // Define changes to default configuration here. For example: //config.language = ''; - config.uiColor = '#E0ECFF'; + config.uiColor = '#eee'; config.toolbar = 'Basic'; config.entities_greek = false; config.entities_latin = false; diff --git a/spec/controllers/admin/categories_controller_spec.rb b/spec/controllers/admin/categories_controller_spec.rb index bb290f4a0d..fa4df8e80a 100644 --- a/spec/controllers/admin/categories_controller_spec.rb +++ b/spec/controllers/admin/categories_controller_spec.rb @@ -16,6 +16,12 @@ assert_response :redirect, :action => 'index' end + it "should render the new template" do + get "new" + expect(subject).to render_template :new + end + end + describe "test_edit" do before(:each) do get :edit, :id => Factory(:category).id @@ -48,7 +54,7 @@ it 'should render destroy template' do assert_response :success - assert_template 'destroy' + assert_template 'destroy' end end @@ -62,5 +68,5 @@ assert_raise(ActiveRecord::RecordNotFound) { Category.find(test_id) } end - + end