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

Fix and improvements for postgres and asdf #38

Merged
merged 2 commits into from
Mar 15, 2023
Merged

Conversation

liamstevens111
Copy link
Member

@liamstevens111 liamstevens111 commented Feb 21, 2023

Close #37

What happened

  • Fixed postgres installation by changing the brew package from postgres to postgresql@<version>
  • asdf:
    • asdf.sh is situated inside an additional directory /libexec during install so the paths have been updated
    • Fixed existing shims export in .zshrc as it had a trailing " so the commands wouldn't be available (I actually added an opening " with $HOME instead of keeping existing ~ and deleting the trailing comma. I think this change is same.
    • Included the above shims export to .zshrc if the oh-my-zsh add-on was chosen at the end (because it overwrites it). If this isn't added then the same errors "command not found" would re-occur again.
  • Added a check for existing postgres on the system prior to installing the postgresql brew package and the function responsible for starting/stopping postgres service and creating the new database user.

Insight

  1. The explicit version of postgresql seems to be required for brew. The following error is shown if just changed to postgresql without version:
Warning: No available formula with the name "postgresql". Did you mean postgresql@13, postgresql@12, postgresql@11, postgresql@15, postgresql@10, postgresql@14, [email protected], [email protected], postgrest or qt-postgresql?
postgresql breaks existing databases on upgrade without human intervention.

So have chosen 14 which would be 14.7 which is only a few months old (didn't want to try 15 but willing to change).

  1. For the postgres existing installation pre-check I have included the location of /Applications/Postgres.app (https://postgresapp.com) in addition to brew in case a user has an existing installation by this method instead (willing to change)

Potential improvements

  • Make a global variable for postgresql version number
  • Change existing shell command which to a folder check depending on if M1 or otherwise for existing postgres check.

Proof Of Work

Success output when running script - https://pastebin.com/N8kVaTBE

@liamstevens111 liamstevens111 changed the title Bug/37 postgres asdf Fix postgres and asdf. Also included check for existing posgres installation Feb 21, 2023
@liamstevens111 liamstevens111 self-assigned this Feb 21, 2023
@liamstevens111 liamstevens111 marked this pull request as ready for review February 21, 2023 05:15
@liamstevens111 liamstevens111 requested a review from a team February 21, 2023 07:30
@olivierobert olivierobert changed the title Fix postgres and asdf. Also included check for existing posgres installation Fix and improvements for postgres and asdf Feb 22, 2023
mac Show resolved Hide resolved
mac Outdated Show resolved Hide resolved
@olivierobert olivierobert requested review from longnd and a team February 23, 2023 07:10
mac
@@ -212,17 +215,17 @@ install_asdf_erlang() {

install_asdf_elixir() {
# shellcheck disable=SC1090
. "$(brew --prefix asdf)/asdf.sh"
. "$(brew --prefix asdf)/libexec/asdf.sh"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move it to a separate method? So, in case it is changed in the future, we don't need to modify it again in all places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A method or a variable? Unsure to be honest, maybe we can do this in a refactor task if needed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

mac
@@ -301,7 +304,7 @@ append_web_dependencies() {
brew "imagemagick"

# Databases
brew "postgres"
brew "postgresql@14"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth to do option from "Potential improvements" in this PR:

Make a global variable for postgresql version number

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it but wasn't 100% sure the version number would directly map to the folder paths in the future, and unsure if we will remove/refactor the setup_postgres where it's used 3 out of the 4 times.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

mac
@@ -106,6 +106,9 @@ config_zsh() {

zsh_config_homebrew

# shellcheck disable=SC2016
append_to_zshrc 'export PATH=~/.asdf/shims:$PATH'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we added it here, should we remove it from install_asdf()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so because if the user decides to not install oh-my-zsh at the last step they won't have it at all.

@olivierobert olivierobert merged commit 0e9edd4 into main Mar 15, 2023
@olivierobert olivierobert deleted the bug/37-postgres-asdf branch March 15, 2023 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix: postgres brew package changes, and asdf installation issues on M1
3 participants