Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 1770 Bytes
1 | class AddTagDisplayName < ActiveRecord::Migration |
2 | class Tag < ActiveRecord::Base |
3 | has_and_belongs_to_many :articles |
4 | end |
5 | |
6 | class Content < ActiveRecord::Base |
7 | end |
8 | |
9 | class Article < Content |
10 | has_and_belongs_to_many :tags |
11 | end |
12 | |
13 | def self.up |
14 | STDERR.puts 'Adding display name to tags' |
15 | modify_tables_and_update(:add_column, Tag, :display_name, :string) do |
16 | unless $schema_generator |
17 | Tag.find(:all).each do |tag| |
18 | tag.display_name = tag.name |
19 | tag.name = tag.name.tr(' ', '').downcase |
20 | if tag.name != tag.display_name |
21 | # we need to make sure we're not attempting to create duplicate-named tags |
22 | # if so, we need to coalesce them |
23 | # Hopefully this code isn't necessary, but somebody may have tags "Monty Python" and "montypython" |
24 | # Please note that this code isn't going to be tested very well, if at all, because of my limited |
25 | # testing setup. But in my quickie tests it appears to be working right |
26 | if origtag = Tag.find(:first, :conditions => [%{name = ? AND id != ?}, tag.name, tag.id]) |
27 | tag.articles.each do |article| |
28 | # replace our tag with origtag in article.tags |
29 | article.tags = article.tags.collect { |x| x.id == tag.id ? origtag : x } |
30 | end |
31 | tag.destroy |
32 | else |
33 | # ok, original tag |
34 | tag.save! |
35 | end |
36 | else |
37 | tag.save! |
38 | end |
39 | end |
40 | end |
41 | end |
42 | end |
43 | |
44 | def self.down |
45 | STDERR.puts 'Removing display name from tags' |
46 | unless $schema_generator |
47 | Tag.find_and_update(:all) do |tag| |
48 | tag.name = tag.display_name |
49 | end |
50 | end |
51 | remove_column :tags, :display_name |
52 | end |
53 | end |