diff --git a/app/models/rails_release.rb b/app/models/rails_release.rb index 71fefae..fbd7b18 100644 --- a/app/models/rails_release.rb +++ b/app/models/rails_release.rb @@ -41,6 +41,16 @@ def earlier? !self.class.latest_major.exists?(id: self) end + def self.print_all + all.each do |release| + puts "# #{release}" + + puts "Minimum ruby version: #{release.minimum_ruby_version}" + puts "Minimum bundler version: #{release.minimum_bundler_version}" + puts "Minimum rubygems version: #{release.minimum_rubygems_version}" + end + end + def compatible_ruby_version if version Gem::Version.new(version < Gem::Version.new("5") ? "2.7" : RUBY_VERSION) diff --git a/db/migrate/20240930143554_add_columns_to_rails_releases_table.rb b/db/migrate/20240930143554_add_columns_to_rails_releases_table.rb new file mode 100644 index 0000000..b3ee3b2 --- /dev/null +++ b/db/migrate/20240930143554_add_columns_to_rails_releases_table.rb @@ -0,0 +1,10 @@ +class AddColumnsToRailsReleasesTable < ActiveRecord::Migration[7.1] + def change + add_column :rails_releases, :minimum_ruby_version, :string + add_column :rails_releases, :minimum_bundler_version, :string + add_column :rails_releases, :minimum_rubygems_version, :string + add_column :rails_releases, :maximum_ruby_version, :string + add_column :rails_releases, :maximum_bundler_version, :string + add_column :rails_releases, :maximum_rubygems_version, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index cfbb776..15f64fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_09_27_154305) do +ActiveRecord::Schema[7.1].define(version: 2024_09_30_143554) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -70,6 +70,12 @@ t.text "version" t.timestamptz "created_at" t.timestamptz "updated_at" + t.string "minimum_ruby_version" + t.string "minimum_bundler_version" + t.string "minimum_rubygems_version" + t.string "maximum_ruby_version" + t.string "maximum_bundler_version" + t.string "maximum_rubygems_version" end end diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake new file mode 100644 index 0000000..d15ab20 --- /dev/null +++ b/lib/tasks/data.rake @@ -0,0 +1,136 @@ +# lib/tasks/update_rails_releases.rake +namespace :data do + SUPPORTED_RAILS_VERSIONS = %w( + 2.3 + 3.0 + 3.1 + 3.2 + 4.0 + 4.1 + 4.2 + 5.0 + 5.1 + 5.2 + 6.0 + 6.1 + 7.0 + 7.1 + 7.2 + ) + + task find_or_create_rails_releases: :environment do + SUPPORTED_RAILS_VERSIONS.each do |version| + RailsRelease.find_or_create_by(version: version) + end + end + + desc "Update minimum Ruby versions from Rails 2.3 to 7.2" + task update_rails_releases: :find_or_create_rails_releases do + min_versions = { + "2.3" => { + minimum_ruby_version: "1.8.7", + maximum_ruby_version: "1.9.3", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "3.0" => { + minimum_ruby_version: "1.8.7", + maximum_ruby_version: "1.9.3", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "3.1" => { + minimum_ruby_version: "1.8.7", + maximum_ruby_version: "2.1.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "3.2" => { + minimum_ruby_version: "1.8.7", + maximum_ruby_version: "2.1.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "4.0" => { + minimum_ruby_version: "1.9.3", + maximum_ruby_version: "2.1.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "4.1" => { + minimum_ruby_version: "1.9.3", + maximum_ruby_version: "2.1.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "4.2" => { + minimum_ruby_version: "1.9.3", + maximum_ruby_version: "2.2.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "5.0" => { + minimum_ruby_version: "2.2.2", + maximum_ruby_version: "2.5.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "5.1" => { + minimum_ruby_version: "2.2.2", + maximum_ruby_version: "2.6.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "5.2" => { + minimum_ruby_version: "2.2.2", + maximum_ruby_version: "2.7.0", + minimum_bundler_version: "1.17.3", + minimum_rubygems_version: "1.3.6" + }, + "6.0" => { + minimum_ruby_version: "2.5.0", + maximum_ruby_version: "3.0.0", + minimum_bundler_version: "2.3.0", + minimum_rubygems_version: "2.5.0" + }, + "6.1" => { + minimum_ruby_version: "2.5.0", + maximum_ruby_version: "3.0.0", + minimum_bundler_version: "2.3.0", + minimum_rubygems_version: "2.5.0" + }, + "7.0" => { + minimum_ruby_version: "2.7.0", + maximum_ruby_version: "3.1.0", + minimum_bundler_version: "2.4.0", + minimum_rubygems_version: "3.0.1" + }, + "7.1" => { + minimum_ruby_version: "2.7.0", + maximum_ruby_version: "3.2.0", + minimum_bundler_version: "2.4.0", + maximum_bundler_version: "2.5.20", + minimum_rubygems_version: "3.0.1" + }, + "7.2" => { + minimum_ruby_version: "3.1.0", + maximum_ruby_version: "3.3.0", + minimum_bundler_version: "2.5.20", + maximum_bundler_version: "2.5.20", + minimum_rubygems_version: "3.2.3" + } + } + + min_versions.each do |version, attrs| + if rails_release = RailsRelease.find_by(version: version) + puts "Updating Rails Release #{rails_release} with #{attrs}" + rails_release.update_columns(attrs) + puts "Updated Rails Release versions" + else + puts "Skipping Rails Release #{version} as it does not exist" + end + end + + puts "Rails Releases updated successfully." + end +end \ No newline at end of file