4 def add_index_options(table_name, column_name, options = {})
5 columns = options.delete(:columns)
6 index_name, index_type, index_columns, index_options, algorithm, using = super(table_name, column_name, options)
7 [index_name, index_type, columns || index_columns, index_options, algorithm, using]
11 module PostgreSQLAdapter
12 def quote_column_name(name)
13 Array(name).map { |n| super(n) }.join(", ")
16 def add_primary_key(table_name, column_name, _options = {})
17 execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(column_name)})"
20 def remove_primary_key(table_name)
21 execute "ALTER TABLE #{quote_table_name(table_name)} DROP PRIMARY KEY"
24 def alter_primary_key(table_name, new_columns)
25 execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_table_name(table_name + '_pkey')}"
26 execute "ALTER TABLE #{quote_table_name(table_name)} ADD PRIMARY KEY (#{quote_column_name(new_columns)})"
29 def create_enumeration(enumeration_name, values)
30 execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')"
33 def drop_enumeration(enumeration_name)
34 execute "DROP TYPE #{enumeration_name}"
37 def rename_enumeration(old_name, new_name)
38 execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}"
44 ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend(OpenStreetMap::ActiveRecord::AbstractAdapter)
45 ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(OpenStreetMap::ActiveRecord::PostgreSQLAdapter)