Sha256: 18b83c251ff77e0661c9fd0490680d294d249d6814a8ad2558b646eff6b02506
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module SchemaPlusMultischema module Middleware module PostgreSQL DEFAULT_SCHEMA_SEARCH_PATH = %r{"\$user",\s*public} module Schema module Tables def implement(env) use_prefix = (env.connection.schema_search_path !~ DEFAULT_SCHEMA_SEARCH_PATH) query = <<-SQL SELECT schemaname, tablename FROM pg_tables WHERE schemaname = ANY(current_schemas(false)) SQL env.tables += env.connection.exec_query(query, 'SCHEMA').map { |row| if use_prefix "#{row['schemaname']}.#{row['tablename']}" else row['tablename'] end } end end end module Dumper module Initial def after(env) if (path = env.connection.schema_search_path) !~ DEFAULT_SCHEMA_SEARCH_PATH path.split(',').each do |name| env.initial << %Q{ connection.execute "CREATE SCHEMA IF NOT EXISTS #{name}"} end env.initial << %Q{ connection.schema_search_path = #{path.inspect}} end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schema_plus_multischema-0.1.1 | lib/schema_plus_multischema/middleware.rb |