mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-26 00:36:01 +08:00
Use built-in methods for Postgres extensions enabling [SCI-2864]
This commit is contained in:
parent
9621f0b372
commit
7cd1c12a4f
3 changed files with 2 additions and 28 deletions
|
@ -4,20 +4,6 @@ module DatabaseHelper
|
|||
ActiveRecord::Base.connection.adapter_name == adapter_name
|
||||
end
|
||||
|
||||
# Create PostgreSQL extension. PostgreSQL only!
|
||||
def create_extension(ext_name)
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"CREATE EXTENSION #{ext_name};"
|
||||
)
|
||||
end
|
||||
|
||||
# Drop PostgreSQL extension. PostgreSQL only!
|
||||
def drop_extension(ext_name)
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"DROP EXTENSION #{ext_name};"
|
||||
)
|
||||
end
|
||||
|
||||
# Create gist trigram index. PostgreSQL only!
|
||||
def add_gist_index(table, column)
|
||||
ActiveRecord::Base.connection.execute(
|
||||
|
|
|
@ -4,13 +4,7 @@ include DatabaseHelper
|
|||
class AddPgTrgmSupport < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
if db_adapter_is? "PostgreSQL" then
|
||||
create_extension :pg_trgm
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
if db_adapter_is? "PostgreSQL" then
|
||||
drop_extension :pg_trgm
|
||||
enable_extension :pg_trgm
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,13 +4,7 @@ include DatabaseHelper
|
|||
class AddBtreeGistExtension < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
if db_adapter_is? "PostgreSQL" then
|
||||
create_extension :btree_gist
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
if db_adapter_is? "PostgreSQL" then
|
||||
drop_extension :btree_gist
|
||||
enable_extension :btree_gist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue