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

We don't just prefer, but require the use of Postgres #1245

Open
nickcharlton opened this issue Dec 20, 2024 · 4 comments · May be fixed by #1248
Open

We don't just prefer, but require the use of Postgres #1245

nickcharlton opened this issue Dec 20, 2024 · 4 comments · May be fixed by #1248

Comments

@nickcharlton
Copy link
Member

I've been working on updating a little script I have for testing out Administrate, where I'll go about creating a bunch of small Rails applications for testing. This has one problem of leaving a lot of unused, potentially clashing Postgres databases sitting around.

To work around this problem, I considered using SQLite — especially as there's been significant renewed interest in it up to and including Rails 8.0.

Whilst we prefer Postgres (and I don't see a need to generally diverge from this opinion), the way we've implemented lib/install/web.rb stops us from using another database type, for example:

$ rails new app_name \
 --suspenders-local \
 --skip-rubocop \
 --skip-test \
 -d=postgresql \
 -m=~/projects/thoughtbot/suspenders/lib/install/web.rb

[… snip …]

remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_8_0.rb
       apply  /Users/nickcharlton/projects/thoughtbot/suspenders/lib/install/web.rb
  in the local project!
The template [/Users/nickcharlton/projects/thoughtbot/suspenders/lib/install/web.rb] could not be loaded. Error:

=== Please use the correct options ===

# Use the latest suspenders release:
rails new <app_name> \
--skip-rubocop \
--skip-test \
-d=postgresql \
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb

# OR use the current (possibly unreleased) `main` branch of suspenders:
rails new <app_name> \
--suspenders-main \
--skip-rubocop \
--skip-test \
-d=postgresql \
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb

The implementation of lib/install/web.rb looks like this:

if options[:database] == "postgresql" && options[:skip_test] && options[:skip_rubocop]
after_bundle do
gem_group :development, :test do
if ARGV.include?("--suspenders-main")
gem "suspenders", github: "thoughtbot/suspenders", branch: "main"
else
gem "suspenders"
end
end

Can anyone think of a better way to do that test in options[:database], etc? The intention is to see if we should setup and run our suspenders generator, but it's doing more than that.

@stevepolitodesign
Copy link
Contributor

@nickcharlton thank you for bringing this up. We're currently working on an internal project to help us re-evaluate our assumptions when it comes to building new Rails 8 applications, and choosing a database is one of the issues I'm most interested in.

@nickcharlton
Copy link
Member Author

Yeah, I think it's going to be interesting to see what we might like to change.

I think in this particular situation, we can be less strict about what we allow to use suspenders, but still push towards Postgres. What do you think?

@stevepolitodesign
Copy link
Contributor

I think in this particular situation, we can be less strict about what we allow to use suspenders, but still push towards Postgres.

I agree.

nickcharlton added a commit that referenced this issue Feb 12, 2025
With increasing interest in SQLite across the Rails community as a
whole, it's valuable for us to start exploring it too. This expands the
existing checks for PostgreSQL to also include SQLite so that where we
want to try out SQLite we're able to. It also adjusts the CI workflow to
exclude PostgreSQL when generating a SQLite-based application.

https://rubyonrails.org/2024/11/7/rails-8-no-paas-required
https://fractaledmind.github.io/tags/sqlite/

Closes #1245
@nickcharlton nickcharlton linked a pull request Feb 12, 2025 that will close this issue
@nickcharlton
Copy link
Member Author

I was thinking a lot about how to loosen the check instead of simply adding SQLite, but I couldn't come up with a way of doing it. Instead, I started down the path of having a "supported" database, which inspired how #1248 is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants