Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README

  • Loading branch information...
commit c2619e65cd9848f772adf6c64d5b296990695d27 1 parent 434884e
Elad Meidar authored November 12, 2009

Showing 2 changed files with 59 additions and 13 deletions. Show diff stats Hide diff stats

  1. 13  README
  2. 59  README.textile
13  README
... ...
@@ -1,13 +0,0 @@
1  
-PlainViews
2  
-==========
3  
-
4  
-Introduction goes here.
5  
-
6  
-
7  
-Example
8  
-=======
9  
-
10  
-Example goes here.
11  
-
12  
-
13  
-Copyright (c) 2009 [name of plugin creator], released under the MIT license
59  README.textile
Source Rendered
... ...
@@ -0,0 +1,59 @@
  1
+h1. PlainView
  2
+
  3
+PlainView adds another tool to your Rails migrations toolkit @create_view@ (and @drop_view@ of course).
  4
+which will allow you to harness the power of "database views":http://en.wikipedia.org/wiki/View_(database) in your application.
  5
+
  6
+
  7
+h3. Installation
  8
+
  9
+as for now this is only available as a plugin, install as follows:
  10
+<pre>script/plugin install git://github.com/eladmeidar/PlainViews.git</pre>
  11
+
  12
+h3. Usage
  13
+
  14
+First you'll have to generate a migration
  15
+<pre>script/generate migration create_users_and_views</pre>
  16
+
  17
+Than, on @self.up@ you can use the @create_view@ helper:
  18
+<pre>class TestView < ActiveRecord::Migration
  19
+  def self.up
  20
+    create_view :v_people do |t|
  21
+      t.base_model :user
  22
+      t.select :select => 'id, name', :conditions => {:name => 'elad'}
  23
+      t.use_security_mode :definer
  24
+      t.use_algorithm :merge
  25
+      t.use_check_option :cascaded
  26
+    end
  27
+  end
  28
+
  29
+  def self.down
  30
+    drop_view :v_people
  31
+  end
  32
+end</pre>
  33
+
  34
+* *select* - required, select is the actual select statement, you can either use ActiveRecord#find conventions or specify a plain test query.
  35
+* *base_mode* this is used only if you use the ActiveRecord conventions on the *select* statement, otherwise it is not required
  36
+* *use_security* - i don't know if this is supported on all databases, but in MySQL you can choose either @:merge@ or @:temptable@.
  37
+* *use_algorithm* - again, don't know if this is a cross DBMS option but on MySQL you can choose between @:definer@ or @:invoker@
  38
+* *check_option*  - same deal, on MySQL you can choose between @:cascaded@ and @:local@
  39
+
  40
+h3. Database support
  41
+
  42
+I investigated a bit, and the basic usage (@select@ / @base_model@) should run successfully on:
  43
+
  44
+* MySQL
  45
+* OCI
  46
+* Oracle
  47
+* Postgresql
  48
+* SQLite
  49
+* SQLServer
  50
+
  51
+although i was unable to actually test it on all of them, help is appreciated here :)
  52
+
  53
+h3. Tests
  54
+
  55
+Not yet actually, there will be some soon.
  56
+
  57
+h3. Todos
  58
+
  59
+Tests!

0 notes on commit c2619e6

Please sign in to comment.
Something went wrong with that request. Please try again.