-
Notifications
You must be signed in to change notification settings - Fork 1k
DB seed script #6432
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
base: master
Are you sure you want to change the base?
DB seed script #6432
Conversation
|
If we're going to use |
bin/setup
Outdated
|
|
||
| puts "== Installing dependencies ==" | ||
| system("bundle check") || system!("bundle install") | ||
| system("bin/yarn check") || system!("bin/yarn install") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rails template actually has this if node support is enabled:
# Install JavaScript dependencies
system("yarn install --check-files")Not sure if the difference is meaningful though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I suspect that it's a bit faster as it won't traverse the dependency graph twice. In any case, when in doubt I prefer to do exactly as provided by Rails. Changed now.
|
I think that |
|
|
||
| # Install JavaScript dependencies | ||
| system("yarn install --check-files") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use bundle exec bin/yarn install in the install notes, Docker file, and vagrant provisioning, and so I would expect this to be consistent with those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about going the other way around?
- From the discussion at Vagrant and Docker installations are unmaintained #2344, I think we agree that we can drop Vagrant, so let's do that: Remove support for development environment with Vagrant #6438.
- Then there's the devcontainer support coming up (Support for Development Containers (devcontainers) #6424) which will lead to dropping the "manual" Docker option and related files.
- The install notes are slightly different: it makes sense to simplify them and therefore we can remove the
--check-filesoption. - Then there's the
bin/updatescript comes from the update to Rails 5.2.0. Nowadays you dorails app:update, I think that can be removed too (different PR).
All this is in the spirit of trying to stay as similar to stock Rails as possible, which will help in future updates.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to align with upstream. My main concern, by far, is to make sure that what is written in the install notes (including any options) is as close to possible as what is done in CI. We've had so many cases over the years where the install notes don't work, and we haven't noticed because CI was doing something subtly different, and who knows how many people tried and failed before anyone contacted us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍 In that case: happy for me to leave this as is and update the install note in this PR?
Tangentially: I should review the install notes. I think I noticed some inconsistencies there. But that'd be separate work.
| email = "admin_#{SecureRandom.uuid}@example.com" | ||
| role = "administrator" | ||
|
|
||
| admin = User.find_or_create_by!(:display_name => display_name) do |user| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid putting non-essential data into the seeds file. This file should only contain the data that's essential to running the site, in all deployments, since the seeds can be run in all environments (test, development and production). These seeds can end up in production databases, perhaps inadvertently, depending on which commands a sysadmin users to set up the database.
See #3030 (comment) for more details on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'm thinking of two options:
- I turn this into a
dev:populatetask, with guards to avoid running on production. - I remove this script (keeping the refactor and the bin/yarn thing), and we focus on getting your
dev:populatetask (Create a dev:populate task to add fake data to your dev environment #3101) through. This can be augmented with the newOauth::Util.register_appsutility.
Another extraction from #6424
In order:
oauth:register_appstask into a method, to allow reuse.admin.yarn installinbin/setup, or it may not work.bin/setup, which includesdb:prepareand in turn runsdb:seed.This takes inspiration from @mmd's https://gist.github.com/mmd-osm/a3a0b5a8799a333e7fae578038aa7a93, but is much simpler. We can think about adding more in the future.
Also related to @gravitystorm's #3101 (I should have a look at that).