chore: update and default initializer for Rails 7
This commit is contained in:
parent
940405cea8
commit
5ee60cbb0c
5 changed files with 155 additions and 11 deletions
1
bin/rake
1
bin/rake
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
load File.expand_path("spring", __dir__)
|
|
||||||
require_relative "../config/boot"
|
require_relative "../config/boot"
|
||||||
require "rake"
|
require "rake"
|
||||||
Rake.application.run
|
Rake.application.run
|
||||||
|
|
20
bin/setup
20
bin/setup
|
@ -2,7 +2,7 @@
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
|
|
||||||
# path to your application root.
|
# path to your application root.
|
||||||
APP_ROOT = File.expand_path('..', __dir__)
|
APP_ROOT = File.expand_path("..", __dir__)
|
||||||
|
|
||||||
def system!(*args)
|
def system!(*args)
|
||||||
system(*args) || abort("\n== Command #{args} failed ==")
|
system(*args) || abort("\n== Command #{args} failed ==")
|
||||||
|
@ -13,9 +13,9 @@ FileUtils.chdir APP_ROOT do
|
||||||
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
||||||
# Add necessary setup steps to this file.
|
# Add necessary setup steps to this file.
|
||||||
|
|
||||||
puts '== Installing dependencies =='
|
puts "== Installing dependencies =="
|
||||||
system! 'gem install bundler --conservative'
|
system! "gem install bundler --conservative"
|
||||||
system('bundle check') || system!('bundle install')
|
system("bundle check") || system!("bundle install")
|
||||||
|
|
||||||
# Install JavaScript dependencies
|
# Install JavaScript dependencies
|
||||||
system! 'node --version'
|
system! 'node --version'
|
||||||
|
@ -29,13 +29,17 @@ FileUtils.chdir APP_ROOT do
|
||||||
FileUtils.cp 'config/env.example', '.env'
|
FileUtils.cp 'config/env.example', '.env'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create the database, load the schema, and initialize it with the seed data
|
# puts "\n== Copying sample files =="
|
||||||
|
# unless File.exist?("config/database.yml")
|
||||||
|
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
||||||
|
# end
|
||||||
|
|
||||||
puts "\n== Preparing database =="
|
puts "\n== Preparing database =="
|
||||||
system! 'bin/rails db:prepare'
|
system! "bin/rails db:prepare"
|
||||||
|
|
||||||
puts "\n== Removing old logs and tempfiles =="
|
puts "\n== Removing old logs and tempfiles =="
|
||||||
system! 'bin/rails log:clear tmp:clear'
|
system! "bin/rails log:clear tmp:clear"
|
||||||
|
|
||||||
puts "\n== Restarting application server =="
|
puts "\n== Restarting application server =="
|
||||||
system! 'bin/rails restart'
|
system! "bin/rails restart"
|
||||||
end
|
end
|
||||||
|
|
133
config/initializers/new_framework_defaults_7_0.rb
Normal file
133
config/initializers/new_framework_defaults_7_0.rb
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
#
|
||||||
|
# This file eases your Rails 7.0 framework defaults upgrade.
|
||||||
|
#
|
||||||
|
# Uncomment each configuration one by one to switch to the new default.
|
||||||
|
# Once your application is ready to run with all new defaults, you can remove
|
||||||
|
# this file and set the `config.load_defaults` to `7.0`.
|
||||||
|
#
|
||||||
|
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||||
|
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
|
||||||
|
|
||||||
|
# `button_to` view helper will render `<button>` element, regardless of whether
|
||||||
|
# or not the content is passed as the first argument or as a block.
|
||||||
|
# Rails.application.config.action_view.button_to_generates_button_tag = true
|
||||||
|
|
||||||
|
# `stylesheet_link_tag` view helper will not render the media attribute by default.
|
||||||
|
# Rails.application.config.action_view.apply_stylesheet_media_default = false
|
||||||
|
|
||||||
|
# Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.
|
||||||
|
# Changing this default means invalidate all encrypted messages generated by
|
||||||
|
# your application and, all the encrypted cookies. Only change this after you
|
||||||
|
# rotated all the messages using the key rotator.
|
||||||
|
#
|
||||||
|
# See upgrading guide for more information on how to build a rotator.
|
||||||
|
# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html
|
||||||
|
# Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
||||||
|
|
||||||
|
# Change the digest class for ActiveSupport::Digest.
|
||||||
|
# Changing this default means that for example Etags change and
|
||||||
|
# various cache keys leading to cache invalidation.
|
||||||
|
# Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
||||||
|
|
||||||
|
# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby
|
||||||
|
# implementation.
|
||||||
|
# Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
|
||||||
|
|
||||||
|
# Calls `Rails.application.executor.wrap` around test cases.
|
||||||
|
# This makes test cases behave closer to an actual request or job.
|
||||||
|
# Several features that are normally disabled in test, such as Active Record query cache
|
||||||
|
# and asynchronous queries will then be enabled.
|
||||||
|
# Rails.application.config.active_support.executor_around_test_case = true
|
||||||
|
|
||||||
|
# Define the isolation level of most of Rails internal state.
|
||||||
|
# If you use a fiber based server or job processor, you should set it to `:fiber`.
|
||||||
|
# Otherwise the default of `:thread` if preferable.
|
||||||
|
# Rails.application.config.active_support.isolation_level = :thread
|
||||||
|
|
||||||
|
# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.
|
||||||
|
# Rails.application.config.action_mailer.smtp_timeout = 5
|
||||||
|
|
||||||
|
# The ActiveStorage video previewer will now use scene change detection to generate
|
||||||
|
# better preview images (rather than the previous default of using the first frame
|
||||||
|
# of the video).
|
||||||
|
# Rails.application.config.active_storage.video_preview_arguments =
|
||||||
|
# "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
|
||||||
|
|
||||||
|
# Automatically infer `inverse_of` for associations with a scope.
|
||||||
|
# Rails.application.config.active_record.automatic_scope_inversing = true
|
||||||
|
|
||||||
|
# Raise when running tests if fixtures contained foreign key violations
|
||||||
|
# Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true
|
||||||
|
|
||||||
|
# Disable partial inserts.
|
||||||
|
# This default means that all columns will be referenced in INSERT queries
|
||||||
|
# regardless of whether they have a default or not.
|
||||||
|
# Rails.application.config.active_record.partial_inserts = false
|
||||||
|
|
||||||
|
# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
|
||||||
|
# Rails.application.config.action_controller.raise_on_open_redirects = true
|
||||||
|
|
||||||
|
# Change the variant processor for Active Storage.
|
||||||
|
# Changing this default means updating all places in your code that
|
||||||
|
# generate variants to use image processing macros and ruby-vips
|
||||||
|
# operations. See the upgrading guide for detail on the changes required.
|
||||||
|
# The `:mini_magick` option is not deprecated; it's fine to keep using it.
|
||||||
|
# Rails.application.config.active_storage.variant_processor = :vips
|
||||||
|
|
||||||
|
# Enable parameter wrapping for JSON.
|
||||||
|
# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
|
||||||
|
# To disable parameter wrapping entirely, set this config to `false`.
|
||||||
|
# Rails.application.config.action_controller.wrap_parameters_by_default = true
|
||||||
|
|
||||||
|
# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a
|
||||||
|
# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.
|
||||||
|
#
|
||||||
|
# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for
|
||||||
|
# more information.
|
||||||
|
# Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true
|
||||||
|
|
||||||
|
# Change the default headers to disable browsers' flawed legacy XSS protection.
|
||||||
|
# Rails.application.config.action_dispatch.default_headers = {
|
||||||
|
# "X-Frame-Options" => "SAMEORIGIN",
|
||||||
|
# "X-XSS-Protection" => "0",
|
||||||
|
# "X-Content-Type-Options" => "nosniff",
|
||||||
|
# "X-Download-Options" => "noopen",
|
||||||
|
# "X-Permitted-Cross-Domain-Policies" => "none",
|
||||||
|
# "Referrer-Policy" => "strict-origin-when-cross-origin"
|
||||||
|
# }
|
||||||
|
|
||||||
|
# ** Please read carefully, this must be configured in config/application.rb **
|
||||||
|
# Change the format of the cache entry.
|
||||||
|
# Changing this default means that all new cache entries added to the cache
|
||||||
|
# will have a different format that is not supported by Rails 6.1 applications.
|
||||||
|
# Only change this value after your application is fully deployed to Rails 7.0
|
||||||
|
# and you have no plans to rollback.
|
||||||
|
# When you're ready to change format, add this to `config/application.rb` (NOT this file):
|
||||||
|
# config.active_support.cache_format_version = 7.0
|
||||||
|
|
||||||
|
# Cookie serializer: 2 options
|
||||||
|
#
|
||||||
|
# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
|
||||||
|
# is `:marshal`. The default for new apps is `:json`.
|
||||||
|
#
|
||||||
|
# Rails.application.config.action_dispatch.cookies_serializer = :json
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
|
||||||
|
#
|
||||||
|
# Rails transparently deserializes existing (Marshal-serialized) cookies on read and
|
||||||
|
# re-writes them in the JSON format.
|
||||||
|
#
|
||||||
|
# It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
|
||||||
|
# have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
|
||||||
|
# initializer or to `config/application.rb`.
|
||||||
|
#
|
||||||
|
# Rails.application.config.action_dispatch.cookies_serializer = :hybrid
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
|
||||||
|
#
|
||||||
|
# If you have configured the serializer elsewhere, you can remove this section of the file.
|
||||||
|
#
|
||||||
|
# See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
|
|
@ -0,0 +1,8 @@
|
||||||
|
# This migration comes from active_storage (originally 20211119233751)
|
||||||
|
class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
return unless table_exists?(:active_storage_blobs)
|
||||||
|
|
||||||
|
change_column_null(:active_storage_blobs, :checksum, true)
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,8 +10,8 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_03_31_125931) do
|
|
||||||
|
|
||||||
|
ActiveRecord::Schema[7.0].define(version: 2023_03_31_125931) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -39,7 +39,7 @@ ActiveRecord::Schema.define(version: 2023_03_31_125931) do
|
||||||
|
|
||||||
create_table "active_storage_blobs", force: :cascade do |t|
|
create_table "active_storage_blobs", force: :cascade do |t|
|
||||||
t.bigint "byte_size", null: false
|
t.bigint "byte_size", null: false
|
||||||
t.string "checksum", null: false
|
t.string "checksum"
|
||||||
t.string "content_type"
|
t.string "content_type"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.string "filename", null: false
|
t.string "filename", null: false
|
||||||
|
|
Loading…
Reference in a new issue