Skip to content

Commit

Permalink
dump schema names in lexical order
Browse files Browse the repository at this point in the history
Task 2395
  • Loading branch information
Mike Sandler committed Mar 5, 2012
1 parent e3642b0 commit 7537631
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pg_power/tools.rb
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ def drop_schema(schema_name)

# Returns an array of existing schemas.
def schemas
sql = "SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*'"
sql = "SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*' order by nspname"
ActiveRecord::Base.connection.query(sql).flatten
end

5 changes: 5 additions & 0 deletions spec/active_record/schema_dumper_spec.rb
Original file line number Diff line number Diff line change
@@ -12,6 +12,11 @@
context 'Schemas' do
it 'dumps schemas' do
@dump.should =~ /create_schema "demography"/
@dump.should =~ /create_schema "later"/
@dump.should =~ /create_schema "latest"/
end
it 'dumps schemas in alphabetical order' do
@dump.should =~ /create_schema "demography".*create_schema "later".*create_schema "latest"/m
end
end

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class CreateDemographySchema < ActiveRecord::Migration
def change
create_schema 'latest'
create_schema 'demography'
create_schema 'later'
end
end
2 changes: 2 additions & 0 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
ActiveRecord::Schema.define(:version => 20120224204546) do

create_schema "demography"
create_schema "later"
create_schema "latest"

create_table "pets", :force => true do |t|
t.string "name"

0 comments on commit 7537631

Please sign in to comment.