Commit 0672e8d1 by ivan Lan

Change table_name of ShanghaiTen

parent 10471a07
class CreateForecasts < ActiveRecord::Migration[5.0]
class CreateCityForecasts < ActiveRecord::Migration[5.0]
def up
create_table :forecasts do |t|
t.datetime :datetime
create_table :city_forecasts do |t|
t.date :date
t.integer :temp_low
t.integer :temp_high
t.string :weather_text
......@@ -14,11 +14,11 @@ class CreateForecasts < ActiveRecord::Migration[5.0]
end
# 两个index 一起查询会不会导致其中一个作用几乎消失
# 需不需要按城市来分表
add_index :forecasts, :cityname
add_index :forecasts, :datetime
add_index :city_forecasts, :cityname
add_index :city_forecasts, :datetime
end
def down
drop_table :forecasts
drop_table :city_forecasts
end
end
......@@ -5,11 +5,11 @@ module WeatherModel
['Forecast']
end
ShanghaiTen = {
CityForecast = {
sort: 'Forecast',
table_name: :forecasts,
table_name: :city_forecasts,
schema: {
datetime: :datetime,
date: :date,
cityname: :string,
temp_high: :string,
temp_low: :string,
......@@ -19,7 +19,7 @@ module WeatherModel
win_speed: :string,
},
options: {
index: [:cityname],
index: [:cityname, :date],
expire: 1,
unique: :mysql_id,
father: nil,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment