Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Avram::Credentials to build unix sockets #986

Open
jwoertink opened this issue Nov 13, 2023 · 0 comments
Open

Allow Avram::Credentials to build unix sockets #986

jwoertink opened this issue Nov 13, 2023 · 0 comments
Labels
hacktoberfest Valid Issue for Hacktoberfest help wanted Additional expertise needed

Comments

@jwoertink
Copy link
Member

jwoertink commented Nov 13, 2023

If you need to build a unix socket, but want to use the Avram::Credentials object, it's a bit messy. I think we can make this easier to work with.

Here's an example of how to connect with a unix socket

# this ENV must be set otherwise it defaults to the current user's name on the system
# export PGDATABASE=my_db_development
Avram::Credentials.parse("postgresql:///my_db_development?host=/var/lib/postgresql/.s.PGSQL.5432&dbname=my_db_development")

I think you can also set a username and password using

Avram::Credentials.parse("postgresql://user:pass@/my_db_development?host=/var/lib/postgresql/.s.PGSQL.5432&dbname=my_db_development")

We would just need to make sure these methods account for the change

def self.drop_db(quiet? : Bool = false)
DB.connect("#{credentials.connection_string}/#{db_user}") do |db|
db.exec "DROP DATABASE IF EXISTS #{db_name}"
end
unless quiet?
puts "Done dropping #{Avram::Migrator::Runner.db_name.colorize(:green)}"
end
end
def self.create_db(quiet? : Bool = false)
DB.connect("#{credentials.connection_string}/#{db_user}") do |db|

Related: #776

@jwoertink jwoertink added the help wanted Additional expertise needed label Mar 17, 2024
@jwoertink jwoertink added the hacktoberfest Valid Issue for Hacktoberfest label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Valid Issue for Hacktoberfest help wanted Additional expertise needed
Projects
None yet
Development

No branches or pull requests

1 participant