chore: update AWS SDK dependencies and improve schema

- Downgraded `aws-sdk-s3` to version 1.170 and updated
  `aws-sdk-core` to 3.211 to maintain compatibility with
  existing code.
- Updated various column types in the database schema
  from `integer` to `bigint` to handle larger values and
  improve data integrity.
- Modified the `sync_geo_data.rake` task to use
  `find_or_create_by` for `Country`, improving the logic
  for ensuring unique countries based on ISO code.

These changes enhance dependency management and improve
schema robustness while maintaining functionality.
This commit is contained in:
songtianlun 2025-02-10 14:43:34 +08:00
parent edbfb32d65
commit 3f1e8892f9
4 changed files with 26 additions and 20 deletions

View File

@ -56,7 +56,8 @@ gem "ahoy_matey", "~> 5.2"
gem "ruby-openai", "~> 7.3" gem "ruby-openai", "~> 7.3"
gem "httparty", "~> 0.22.0" gem "httparty", "~> 0.22.0"
gem "down", "~> 5.4" gem "down", "~> 5.4"
gem "aws-sdk-s3", "~> 1.177" gem "aws-sdk-s3", "~> 1.170"
gem "aws-sdk-core", "3.211"
gem "sidekiq", "~> 7.3" gem "sidekiq", "~> 7.3"
gem "sidekiq-scheduler", "~> 5.0" gem "sidekiq-scheduler", "~> 5.0"

View File

@ -94,16 +94,16 @@ GEM
ast (2.4.2) ast (2.4.2)
aws-eventstream (1.3.0) aws-eventstream (1.3.0)
aws-partitions (1.1044.0) aws-partitions (1.1044.0)
aws-sdk-core (3.217.1) aws-sdk-core (3.211.0)
aws-eventstream (~> 1, >= 1.3.0) aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0) aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9) aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1) jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.97.0) aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.216.0) aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5) aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.179.0) aws-sdk-s3 (1.177.0)
aws-sdk-core (~> 3, >= 3.216.0) aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1) aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5) aws-sigv4 (~> 1.5)
aws-sigv4 (1.11.0) aws-sigv4 (1.11.0)
@ -511,7 +511,8 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
activeadmin (~> 3.2) activeadmin (~> 3.2)
ahoy_matey (~> 5.2) ahoy_matey (~> 5.2)
aws-sdk-s3 (~> 1.177) aws-sdk-core (= 3.211)
aws-sdk-s3 (~> 1.170)
bootsnap bootsnap
brakeman brakeman
capybara capybara

27
db/schema.rb generated
View File

@ -11,13 +11,16 @@
# 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[8.0].define(version: 2025_02_08_052634) do ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "active_admin_comments", force: :cascade do |t| create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace" t.string "namespace"
t.text "body" t.text "body"
t.string "resource_type" t.string "resource_type"
t.integer "resource_id" t.bigint "resource_id"
t.string "author_type" t.string "author_type"
t.integer "author_id" t.bigint "author_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author" t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
@ -66,8 +69,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
end end
create_table "ahoy_events", force: :cascade do |t| create_table "ahoy_events", force: :cascade do |t|
t.integer "visit_id" t.bigint "visit_id"
t.integer "user_id" t.bigint "user_id"
t.string "name" t.string "name"
t.text "properties" t.text "properties"
t.datetime "time" t.datetime "time"
@ -79,7 +82,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
create_table "ahoy_visits", force: :cascade do |t| create_table "ahoy_visits", force: :cascade do |t|
t.string "visit_token" t.string "visit_token"
t.string "visitor_token" t.string "visitor_token"
t.integer "user_id" t.bigint "user_id"
t.string "ip" t.string "ip"
t.text "user_agent" t.text "user_agent"
t.text "referrer" t.text "referrer"
@ -117,12 +120,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "slug" t.string "slug"
t.integer "country_id", null: false t.bigint "country_id", null: false
t.string "state_code" t.string "state_code"
t.string "country_code" t.string "country_code"
t.boolean "flag", default: true t.boolean "flag", default: true
t.string "wiki_data_id" t.string "wiki_data_id"
t.integer "state_id" t.bigint "state_id"
t.index ["country_id"], name: "index_cities_on_country_id" t.index ["country_id"], name: "index_cities_on_country_id"
t.index ["slug"], name: "index_cities_on_slug", unique: true t.index ["slug"], name: "index_cities_on_slug", unique: true
t.index ["state_id"], name: "index_cities_on_state_id" t.index ["state_id"], name: "index_cities_on_state_id"
@ -132,7 +135,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
t.string "name" t.string "name"
t.string "code" t.string "code"
t.string "slug" t.string "slug"
t.integer "region_id" t.bigint "region_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "iso3" t.string "iso3"
@ -155,7 +158,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
t.string "emoji_u" t.string "emoji_u"
t.boolean "flag", default: true t.boolean "flag", default: true
t.string "wiki_data_id" t.string "wiki_data_id"
t.integer "subregion_id" t.bigint "subregion_id"
t.index ["code"], name: "index_countries_on_code", unique: true t.index ["code"], name: "index_countries_on_code", unique: true
t.index ["region_id"], name: "index_countries_on_region_id" t.index ["region_id"], name: "index_countries_on_region_id"
t.index ["slug"], name: "index_countries_on_slug", unique: true t.index ["slug"], name: "index_countries_on_slug", unique: true
@ -189,7 +192,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
create_table "states", force: :cascade do |t| create_table "states", force: :cascade do |t|
t.string "name" t.string "name"
t.string "code" t.string "code"
t.integer "country_id" t.bigint "country_id"
t.string "country_code" t.string "country_code"
t.string "fips_code" t.string "fips_code"
t.string "iso2" t.string "iso2"
@ -208,7 +211,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
create_table "subregions", force: :cascade do |t| create_table "subregions", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.text "translations" t.text "translations"
t.integer "region_id", null: false t.bigint "region_id", null: false
t.boolean "flag", default: true t.boolean "flag", default: true
t.string "wiki_data_id" t.string "wiki_data_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
@ -217,7 +220,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_02_08_052634) do
end end
create_table "weather_arts", force: :cascade do |t| create_table "weather_arts", force: :cascade do |t|
t.integer "city_id", null: false t.bigint "city_id", null: false
t.date "weather_date" t.date "weather_date"
t.string "description" t.string "description"
t.decimal "temperature" t.decimal "temperature"

View File

@ -84,7 +84,8 @@ namespace :geo do
count += 1 count += 1
# 查找或初始化 Country # 查找或初始化 Country
country = Country.find_or_initialize_by(name: data["name"]) do |c| country = Country.find_or_create_by(code: data["iso2"]) do |c|
c.name = data["name"]
end end
# 更新 Country 属性 # 更新 Country 属性