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:
- 5546 Bytes
1 | class Bare20Article < ActiveRecord::Base |
2 | include BareMigration |
3 | |
4 | # need to point the primary key somewhere else so we can manually |
5 | # set this field for each article. |
6 | set_primary_key :boguskey |
7 | end |
8 | |
9 | class Bare20Content < ActiveRecord::Base |
10 | include BareMigration |
11 | |
12 | # From active_record/base.rb: "the primary key and inheritance column can |
13 | # never be set by mass-assignment for security reasons." Because this |
14 | # script wants to set 'id' and 'type', we need to fool activerecord by |
15 | # setting them to bogus values. |
16 | set_inheritance_column :bogustype |
17 | set_primary_key :boguskey |
18 | end |
19 | |
20 | class SuperclassArticles < ActiveRecord::Migration |
21 | def self.config |
22 | ActiveRecord::Base.configurations |
23 | end |
24 | |
25 | def self.up |
26 | STDERR.puts "Merging Articles into Contents table" |
27 | |
28 | # Make sure our index is in a known state |
29 | add_index :articles, :permalink rescue nil |
30 | |
31 | Bare20Article.transaction do |
32 | create_table :contents do |t| |
33 | # ActiveRecord::Base.connection.send(:create_table, [:contents]) do |t| |
34 | t.column :type, :string |
35 | t.column :title, :string |
36 | t.column :author, :string |
37 | t.column :body, :text |
38 | t.column :body_html, :text |
39 | t.column :extended, :text |
40 | t.column :excerpt, :text |
41 | t.column :keywords, :string |
42 | t.column :allow_comments, :integer |
43 | t.column :allow_pings, :integer |
44 | t.column :published, :integer, :default => 1 |
45 | t.column :created_at, :datetime |
46 | t.column :updated_at, :datetime |
47 | t.column :extended_html, :text |
48 | t.column :user_id, :integer |
49 | t.column :permalink, :string |
50 | t.column :guid, :string |
51 | t.column :text_filter_id, :integer |
52 | t.column :whiteboard, :text |
53 | end |
54 | |
55 | if config[RAILS_ENV]['adapter'] == 'postgresql' |
56 | execute "select nextval('contents_id_seq')" |
57 | end |
58 | |
59 | if not $schema_generator |
60 | |
61 | Bare20Article.find(:all).each do |a| |
62 | t = Bare20Content.new( |
63 | :type => 'Article', |
64 | :title => a.title, |
65 | :author => a.author, |
66 | :body => a.body, |
67 | :body_html => a.body_html, |
68 | :extended => a.extended, |
69 | :excerpt => a.excerpt, |
70 | :keywords => a.keywords, |
71 | :allow_comments => a.allow_comments, |
72 | :allow_pings => a.allow_pings, |
73 | :published => a.published, |
74 | :created_at => a.created_at, |
75 | :updated_at => a.updated_at, |
76 | :extended_html => a.extended_html, |
77 | :user_id => a.user_id, |
78 | :permalink => a.permalink, |
79 | :guid => a.guid, |
80 | :text_filter_id => a.text_filter_id, |
81 | :whiteboard => a.whiteboard) |
82 | # can't use id accessor because it uses the bogus primary key |
83 | t.send(:write_attribute, :id, a.send(:read_attribute, :id)) |
84 | t.save! |
85 | end |
86 | |
87 | if config[RAILS_ENV]['adapter'] == 'postgresql' |
88 | STDERR.puts "Resetting PostgreSQL sequences" |
89 | execute "select setval('contents_id_seq',max(id)) from contents" |
90 | execute "select nextval('contents_id_seq')" |
91 | end |
92 | end |
93 | |
94 | remove_index :articles, :permalink |
95 | drop_table :articles |
96 | end |
97 | end |
98 | |
99 | def self.down |
100 | Bare20Content.transaction do |
101 | STDERR.puts "Recreating Articles from Contents table." |
102 | |
103 | create_table :articles do |t| |
104 | t.column :title, :string |
105 | t.column :author, :string |
106 | t.column :body, :text |
107 | t.column :body_html, :text |
108 | t.column :extended, :text |
109 | t.column :excerpt, :text |
110 | t.column :keywords, :string |
111 | t.column :allow_comments, :integer |
112 | t.column :allow_pings, :integer |
113 | t.column :published, :integer, :default => 1 |
114 | t.column :created_at, :datetime |
115 | t.column :updated_at, :datetime |
116 | t.column :extended_html, :text |
117 | t.column :user_id, :integer |
118 | t.column :permalink, :string |
119 | t.column :guid, :string |
120 | t.column :text_filter_id, :integer |
121 | t.column :whiteboard, :text |
122 | end |
123 | |
124 | if config[RAILS_ENV]['adapter'] == 'postgresql' |
125 | execute "select nextval('articles_id_seq')" |
126 | end |
127 | |
128 | add_index :articles, :permalink |
129 | |
130 | if not $schema_generator |
131 | Bare20Content.find(:all, :conditions => "type = 'Article'").each do |a| |
132 | t = Bare20Article.new( |
133 | :title => a.title, |
134 | :author => a.author, |
135 | :body => a.body, |
136 | :body_html => a.body_html, |
137 | :extended => a.extended, |
138 | :excerpt => a.excerpt, |
139 | :keywords => a.keywords, |
140 | :allow_comments => a.allow_comments, |
141 | :allow_pings => a.allow_pings, |
142 | :published => a.published, |
143 | :created_at => a.created_at, |
144 | :updated_at => a.updated_at, |
145 | :extended_html => a.extended_html, |
146 | :user_id => a.user_id, |
147 | :permalink => a.permalink, |
148 | :guid => a.guid, |
149 | :text_filter_id => a.text_filter_id, |
150 | :whiteboard => a.whiteboard) |
151 | # can't use id accessor because it uses the bogus primary key |
152 | t.send(:write_attribute, :id, a.send(:read_attribute, :id)) |
153 | t.save! |
154 | end |
155 | |
156 | if config[RAILS_ENV]['adapter'] == 'postgres' |
157 | STDERR.puts "Resetting PostgreSQL sequences" |
158 | execute "select setval('articles_id_seq',max(id)+1) from articles" |
159 | end |
160 | |
161 | end |
162 | |
163 | # script 21 saved the comments, this script saved the articles. |
164 | drop_table :contents |
165 | end |
166 | end |
167 | end |