aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb21
-rw-r--r--activerecord/lib/active_record/railties/databases.rake8
2 files changed, 1 insertions, 28 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 2395a744a3..68ee88bba4 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -658,27 +658,6 @@ module ActiveRecord
end
end
- # Creates a schema for the given user
- #
- # Example:
- # create_schema('products', 'postgres')
- def create_schema(schema_name, pg_username)
- execute("CREATE SCHEMA \"#{schema_name}\" AUTHORIZATION \"#{pg_username}\"")
- end
-
- # Drops a schema
- #
- # Example:
- # drop_schema('products')
- def drop_schema(schema_name)
- execute("DROP SCHEMA \"#{schema_name}\"")
- end
-
- # Returns an array of all schemas in the database
- def all_schemas
- query('SELECT schema_name FROM information_schema.schemata').flatten
- end
-
# Returns the list of all tables in the schema search path or a specified schema.
def tables(name = nil)
query(<<-SQL, name).map { |row| row[0] }
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index a107befef3..0229793a9a 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -84,15 +84,9 @@ namespace :db do
end
end
when 'postgresql'
- @encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
- schema_search_path = config['schema_search_path'] || 'public'
- first_in_schema_search_path = schema_search_path.split(',').first.strip
+ @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
begin
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
- unless ActiveRecord::Base.connection.all_schemas.include?(first_in_schema_search_path)
- ActiveRecord::Base.connection.create_schema(first_in_schema_search_path, config['username'])
- $stderr.puts "Schema #{first_in_schema_search_path} has been created."
- end
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
ActiveRecord::Base.establish_connection(config)
rescue