Browse files

Added flat_functions_view to support API calls

  • Loading branch information...
1 parent b605b42 commit 9e662e666d7f883be777d572797eaf3e1b137a14 @zk committed Oct 14, 2010
Showing with 42 additions and 1 deletion.
  1. +20 −0 db/migrate/20101014192108_add_flat_functions_view.rb
  2. +22 −1 db/schema.rb
View
20 db/migrate/20101014192108_add_flat_functions_view.rb
@@ -0,0 +1,20 @@
+class AddFlatFunctionsView < ActiveRecord::Migration
+ def self.up
+ #flat_function_view is used by the api to simplify querying
+ puts "Adding flat_function_view view."
+ connection.execute <<-EOC
+ CREATE VIEW flat_functions_view as
+ SELECT functions.*,
+ libraries.name as library,
+ namespaces.name as ns,
+ libraries.id as library_id
+ FROM functions
+ LEFT JOIN namespaces ON functions.namespace_id = namespaces.id
+ LEFT JOIN libraries ON namespaces.library_id = libraries.id;
+ EOC
+ end
+
+ def self.down
+ connection.execute "DROP VIEW IF EXISTS flat_functions_view;"
+ end
+end
View
23 db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20101011035100) do
+ActiveRecord::Schema.define(:version => 20101014192108) do
create_table "comments", :force => true do |t|
t.integer "commentable_id", :default => 0
@@ -51,6 +51,27 @@
add_index "examples", ["function_id"], :name => "function_id_idx"
+ create_table "flat_functions_view", :id => false, :force => true do |t|
+ t.integer "id", :default => 0, :null => false
+ t.string "name"
+ t.string "file"
+ t.string "line"
+ t.string "arglists_comp"
+ t.string "added"
+ t.text "doc"
+ t.text "source"
+ t.integer "weight", :default => 0
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "shortdoc", :limit => 70
+ t.string "version"
+ t.string "url_friendly_name"
+ t.integer "namespace_id"
+ t.string "library"
+ t.string "ns"
+ t.integer "library_id", :default => 0
+ end
+
create_table "function_references", :id => false, :force => true do |t|
t.integer "from_function_id"
t.integer "to_function_id"

0 comments on commit 9e662e6

Please sign in to comment.