lib/dexter/indexer.rb in pgdexter-0.3.8 vs lib/dexter/indexer.rb in pgdexter-0.3.9
- old
+ new
@@ -2,10 +2,11 @@
class Indexer
include Logging
def initialize(options)
@create = options[:create]
+ @tablespace = options[:tablespace]
@log_level = options[:log_level]
@exclude_tables = options[:exclude]
@include_tables = Array(options[:include].split(",")) if options[:include]
@log_sql = options[:log_sql]
@log_explain = options[:log_explain]
@@ -477,10 +478,11 @@
# 3. create indexes that still don't exist
# 4. release lock
with_advisory_lock do
new_indexes.each do |index|
unless index_exists?(index)
- statement = "CREATE INDEX CONCURRENTLY ON #{quote_ident(index[:table])} (#{index[:columns].map { |c| quote_ident(c) }.join(", ")})"
+ statement = String.new("CREATE INDEX CONCURRENTLY ON #{quote_ident(index[:table])} (#{index[:columns].map { |c| quote_ident(c) }.join(", ")})")
+ statement << " TABLESPACE #{quote_ident(@tablespace)}" if @tablespace
log "Creating index: #{statement}"
started_at = Time.now
begin
execute(statement)
log "Index created: #{((Time.now - started_at) * 1000).to_i} ms"