Module: Pakyow::Data::Adapters::Sql::Migrator::AdapterMethods::Postgres Private
- Defined in:
- lib/pakyow/data/adapters/sql/migrator/adapter_methods.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
Instance Method Summary collapse
- #create! ⇒ Object private
- #drop! ⇒ Object private
Class Method Details
.globalize_connection_opts!(connection_opts) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 65 |
# File 'lib/pakyow/data/adapters/sql/migrator/adapter_methods.rb', line 62 def self.globalize_connection_opts!(connection_opts) connection_opts[:initial] = Sql.build_opts(path: connection_opts[:path]) connection_opts[:path] = "template1" end |
Instance Method Details
#create! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 |
# File 'lib/pakyow/data/adapters/sql/migrator/adapter_methods.rb', line 38 def create! handle_error do @connection.adapter.connection.run("CREATE DATABASE \"#{database}\"") end end |
#drop! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pakyow/data/adapters/sql/migrator/adapter_methods.rb', line 44 def drop! handle_error do @connection.adapter.connection.run " SELECT\n pg_terminate_backend(pid)\n FROM\n pg_stat_activity\n WHERE\n -- don't kill my own connection!\n pid <> pg_backend_pid()\n -- don't kill the connections to other databases\n AND datname = '\#{@connection.opts[:path]}';\n SQL\n\n @connection.adapter.connection.run(\"DROP DATABASE \\\"\#{database}\\\"\")\n end\nend\n" |