<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,6 +10,12 @@ module RailsSqlViews
       # This setting is only used if ActiveRecord::Base.schema_format == :ruby
       base.cattr_accessor :ignore_views
       base.ignore_views = []
+      # Optional: specify the order that in which views are created.
+      # This allows views to depend on and include fields from other views.
+      # It is not necessary to specify all the view names, just the ones that 
+      # need to be created first
+      base.cattr_accessor :view_creation_order
+      base.view_creation_order = []
     end
     
     def trailer_with_views(stream)
@@ -36,7 +42,15 @@ module RailsSqlViews
     
     # Add views to the stream
     def views(stream)
-      @connection.views.sort.each do |v|
+      if view_creation_order.empty?
+        sorted_views = @connection.views.sort
+      else
+        # set union, merge by joining arrays, removing dups
+        # this will float the view name sin view_creation_order to the top
+        # without requiring all the views to be specified
+        sorted_views = view_creation_order | @connection.views
+      end
+      sorted_views.each do |v|
         next if [ActiveRecord::Migrator.schema_migrations_table_name, ignore_views].flatten.any? do |ignored|
           case ignored
           when String then v == ignored</diff>
      <filename>lib/rails_sql_views/schema_dumper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,12 @@ class SchemaDumperTest &lt; Test::Unit::TestCase
     
     assert_dump_and_load_succeed
   end
+  def test_view_creation_order
+    ActiveRecord::SchemaDumper.view_creation_order &lt;&lt; :v_people
+    create_people_view
+    assert_dump_and_load_succeed
+    ActiveRecord::SchemaDumper.view_creation_order.pop
+  end
   def test_symbol_ignore
     ActiveRecord::SchemaDumper.ignore_views &lt;&lt; :v_people
     create_people_view</diff>
      <filename>test/schema_dumper_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8ba4d92eda32f58ed33ec34739e431ffccea6bce</id>
    </parent>
  </parents>
  <author>
    <name>Robert Wahler</name>
    <email>robert@gearheadforhire.com</email>
  </author>
  <url>http://github.com/robertwahler/rails_sql_views/commit/3e70425950e96c116f2de5c7d396208965f15919</url>
  <id>3e70425950e96c116f2de5c7d396208965f15919</id>
  <committed-date>2009-08-27T11:20:39-07:00</committed-date>
  <authored-date>2009-08-27T11:20:39-07:00</authored-date>
  <message>optionally specify the order in which views are created

This allows views to depend on and include fields from other views.
It is not necessary to specify all the view names, just the ones that
need to be created first</message>
  <tree>0ad70f25409e87a92a9fed9f750defb77188a255</tree>
  <committer>
    <name>Robert Wahler</name>
    <email>robert@gearheadforhire.com</email>
  </committer>
</commit>
