OSDN Git Service

copy arc.thumbs
authornomeu <nomeu@users.sourceforge.jp>
Thu, 7 Jul 2011 09:10:32 +0000 (18:10 +0900)
committernomeu <nomeu@users.sourceforge.jp>
Thu, 7 Jul 2011 09:10:32 +0000 (18:10 +0900)
bin/copy-arc_thumbs.rb [new file with mode: 0644]
db/groonga/migrate/20110707085913_add_thumbs_to_arc.rb [new file with mode: 0644]
db/groonga/schema.rb

diff --git a/bin/copy-arc_thumbs.rb b/bin/copy-arc_thumbs.rb
new file mode 100644 (file)
index 0000000..1c2a914
--- /dev/null
@@ -0,0 +1,5 @@
+Record::Arc.all.each do |rec|
+  arc = Arc.find(rec.code)
+  arc.thumbs = rec.thumbs.map { |t| t.video_id }
+  arc.save
+end
diff --git a/db/groonga/migrate/20110707085913_add_thumbs_to_arc.rb b/db/groonga/migrate/20110707085913_add_thumbs_to_arc.rb
new file mode 100644 (file)
index 0000000..269a990
--- /dev/null
@@ -0,0 +1,13 @@
+class AddThumbsToArc < ActiveGroonga::Migration
+  def up
+    change_table(:arcs) do |table|
+      table.reference(:thumbs, "thumbs", :type => :vector)
+    end
+  end
+
+  def down
+    change_table(:arcs) do |table|
+      table.remove_column(:thumbs)
+    end
+  end
+end
index de7c94e..6b31d52 100644 (file)
@@ -1,4 +1,4 @@
-ActiveGroonga::Schema.define(:version => 20110707050534) do |schema|
+ActiveGroonga::Schema.define(:version => 20110707085913) do |schema|
   schema.instance_eval do
     create_table("arcs",
                  :type => :hash,
@@ -62,6 +62,7 @@ ActiveGroonga::Schema.define(:version => 20110707050534) do |schema|
 
     change_table("arcs") do |table|
       table.reference("site", "sites")
+      table.reference("thumbs", "thumbs")
     end
 
     change_table("pmds") do |table|