today_ai_weather/db/schema.rb
songtianlun ca3691004f feat: Convert country timezones to JSONB format
- Changed `timezones` attribute from text to JSONB in `Country`.
- Updated related model methods to handle JSONB data.
- Added a migration to convert existing timezone data.
- Used safe navigation operators to prevent errors.

This change improves the storage and management of timezone
information by using the JSONB data type.  It includes data
migration to handle existing timezone data.
2025-02-15 16:51:36 +08:00

281 lines
10 KiB
Ruby
Generated

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_02_15_084540) 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|
t.string "namespace"
t.text "body"
t.string "resource_type"
t.integer "resource_id"
t.string "author_type"
t.integer "author_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource"
end
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.bigint "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admin_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
create_table "ahoy_events", force: :cascade do |t|
t.integer "visit_id"
t.integer "user_id"
t.string "name"
t.text "properties"
t.datetime "time"
t.index ["name", "time"], name: "index_ahoy_events_on_name_and_time"
t.index ["user_id"], name: "index_ahoy_events_on_user_id"
t.index ["visit_id"], name: "index_ahoy_events_on_visit_id"
end
create_table "ahoy_visits", force: :cascade do |t|
t.string "visit_token"
t.string "visitor_token"
t.integer "user_id"
t.string "ip"
t.text "user_agent"
t.text "referrer"
t.string "referring_domain"
t.text "landing_page"
t.string "browser"
t.string "os"
t.string "device_type"
t.string "country"
t.string "region"
t.string "city"
t.float "latitude"
t.float "longitude"
t.string "utm_source"
t.string "utm_medium"
t.string "utm_term"
t.string "utm_content"
t.string "utm_campaign"
t.string "app_version"
t.string "os_version"
t.string "platform"
t.datetime "started_at"
t.index ["user_id"], name: "index_ahoy_visits_on_user_id"
t.index ["visit_token"], name: "index_ahoy_visits_on_visit_token", unique: true
t.index ["visitor_token", "started_at"], name: "index_ahoy_visits_on_visitor_token_and_started_at"
end
create_table "cities", force: :cascade do |t|
t.string "name"
t.float "latitude"
t.float "longitude"
t.boolean "active", default: false
t.integer "priority"
t.string "timezone"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.integer "country_id"
t.string "state_code"
t.string "country_code"
t.boolean "flag", default: true
t.string "wiki_data_id"
t.bigint "state_id"
t.index ["country_id"], name: "index_cities_on_country_id"
t.index ["slug"], name: "index_cities_on_slug", unique: true
t.index ["state_id"], name: "index_cities_on_state_id"
end
create_table "countries", force: :cascade do |t|
t.string "name"
t.string "code"
t.string "slug"
t.integer "region_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "iso3"
t.string "numeric_code"
t.string "iso2"
t.string "phonecode"
t.string "capital"
t.string "currency"
t.string "currency_name"
t.string "currency_symbol"
t.string "tld"
t.string "native"
t.string "subregion"
t.string "nationality"
t.text "translations"
t.decimal "latitude", precision: 10, scale: 8
t.decimal "longitude", precision: 11, scale: 8
t.string "emoji"
t.string "emoji_u"
t.boolean "flag", default: true
t.string "wiki_data_id"
t.bigint "subregion_id"
t.jsonb "timezones"
t.index ["code"], name: "index_countries_on_code", unique: true
t.index ["region_id"], name: "index_countries_on_region_id"
t.index ["slug"], name: "index_countries_on_slug", unique: true
t.index ["subregion_id"], name: "index_countries_on_subregion_id"
end
create_table "friendly_id_slugs", force: :cascade do |t|
t.string "slug", null: false
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
t.datetime "created_at"
t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
end
create_table "regions", force: :cascade do |t|
t.string "name"
t.string "code"
t.string "slug"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "translations"
t.boolean "flag", default: true
t.string "wiki_data_id"
t.index ["code"], name: "index_regions_on_code", unique: true
t.index ["slug"], name: "index_regions_on_slug", unique: true
end
create_table "states", force: :cascade do |t|
t.string "name"
t.string "code"
t.bigint "country_id"
t.string "country_code"
t.string "fips_code"
t.string "iso2"
t.string "state_type"
t.integer "level"
t.integer "parent_id"
t.decimal "latitude", precision: 10, scale: 8
t.decimal "longitude", precision: 11, scale: 8
t.boolean "flag"
t.string "wiki_data_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["country_id"], name: "index_states_on_country_id"
end
create_table "subregions", force: :cascade do |t|
t.string "name", null: false
t.text "translations"
t.bigint "region_id", null: false
t.boolean "flag", default: true
t.string "wiki_data_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["region_id"], name: "index_subregions_on_region_id"
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at"
t.boolean "admin", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end
create_table "weather_arts", force: :cascade do |t|
t.integer "city_id", null: false
t.date "weather_date"
t.string "description"
t.decimal "temperature"
t.decimal "feeling_temp"
t.decimal "humidity"
t.string "wind_scale"
t.decimal "wind_speed"
t.decimal "precipitation"
t.decimal "pressure"
t.decimal "visibility"
t.decimal "cloud"
t.text "prompt"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.index ["city_id", "weather_date"], name: "index_weather_arts_on_city_id_and_weather_date"
t.index ["city_id"], name: "index_weather_arts_on_city_id"
t.index ["slug"], name: "index_weather_arts_on_slug", unique: true
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "cities", "countries"
add_foreign_key "cities", "states"
add_foreign_key "countries", "regions"
add_foreign_key "countries", "subregions"
add_foreign_key "states", "countries"
add_foreign_key "subregions", "regions"
add_foreign_key "weather_arts", "cities"
end