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 def up
create_table :forecasts do |t| create_table :city_forecasts do |t|
t.datetime :datetime t.date :date
t.integer :temp_low t.integer :temp_low
t.integer :temp_high t.integer :temp_high
t.string :weather_text t.string :weather_text
...@@ -14,11 +14,11 @@ class CreateForecasts < ActiveRecord::Migration[5.0] ...@@ -14,11 +14,11 @@ class CreateForecasts < ActiveRecord::Migration[5.0]
end end
# 两个index 一起查询会不会导致其中一个作用几乎消失 # 两个index 一起查询会不会导致其中一个作用几乎消失
# 需不需要按城市来分表 # 需不需要按城市来分表
add_index :forecasts, :cityname add_index :city_forecasts, :cityname
add_index :forecasts, :datetime add_index :city_forecasts, :datetime
end end
def down def down
drop_table :forecasts drop_table :city_forecasts
end end
end end
...@@ -5,11 +5,11 @@ module WeatherModel ...@@ -5,11 +5,11 @@ module WeatherModel
['Forecast'] ['Forecast']
end end
ShanghaiTen = { CityForecast = {
sort: 'Forecast', sort: 'Forecast',
table_name: :forecasts, table_name: :city_forecasts,
schema: { schema: {
datetime: :datetime, date: :date,
cityname: :string, cityname: :string,
temp_high: :string, temp_high: :string,
temp_low: :string, temp_low: :string,
...@@ -19,7 +19,7 @@ module WeatherModel ...@@ -19,7 +19,7 @@ module WeatherModel
win_speed: :string, win_speed: :string,
}, },
options: { options: {
index: [:cityname], index: [:cityname, :date],
expire: 1, expire: 1,
unique: :mysql_id, unique: :mysql_id,
father: nil, 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