1- """Support multiple climatological normals
1+ """Support multiple climo normals
22
33Revision ID: 758be4f4ce0f
44Revises: 7ab87f8fbcf4
4242def upgrade ():
4343
4444 op .create_table (
45- "climatological_period " ,
46- Column ("climatological_period_id " , Integer , primary_key = True ),
45+ "climo_period " ,
46+ Column ("climo_period_id " , Integer , primary_key = True ),
4747 Column ("start_date" , DateTime , nullable = False ),
4848 Column ("end_date" , DateTime , nullable = False ),
49- Column ("mod_time" , DateTime , nullable = False ),
50- Column ("mod_user" , String , nullable = False ),
5149 schema = schema_name ,
52- )
50+ )
5351
54- Enum ("long-record" , "composite" , "prism" , name = "climatological_station_type_enum " ).create (op .get_bind ())
52+ Enum ("long-record" , "composite" , "prism" , name = "climo_station_type_enum " ).create (op .get_bind ())
5553
5654 op .create_table (
5755 # TODO: Columns in this table parallel those in meta_station and meta_history.
@@ -62,35 +60,33 @@ def upgrade():
6260 # prevent entry of erroneous values that just happen to be very long?)
6361 #
6462 # - None are nullable. In contrast, most in the model tables are.
65- "climatological_station " , # TODO: Revise name?
66- Column ("climatological_station_id " , Integer , primary_key = True ),
63+ "climo_station " , # TODO: Revise name?
64+ Column ("climo_station_id " , Integer , primary_key = True ),
6765 Column (
68- "type" , PG_ENUM ("long-record" , "composite" , "prism" , name = "climatological_station_type_enum " , create_type = False ), nullable = False
66+ "type" , PG_ENUM ("long-record" , "composite" , "prism" , name = "climo_station_type_enum " , create_type = False ), nullable = False
6967 ),
7068 Column ("basin_id" , Integer , nullable = True ),
7169 Column ("comments" , String , nullable = False ),
7270 Column (
73- "climatological_period_id " ,
71+ "climo_period_id " ,
7472 Integer ,
7573 ForeignKey (
76- f"{ schema_name } .climatological_period.climatological_period_id "
74+ f"{ schema_name } .climo_period.climo_period_id "
7775 ),
7876 nullable = False ,
7977 ),
80- Column ("mod_time" , DateTime , nullable = False ),
81- Column ("mod_user" , String , nullable = False ),
8278 schema = schema_name ,
8379 )
8480
85- Enum ("base" , "joint" , name = "climatological_station_role_enum " ).create (op .get_bind ())
81+ Enum ("base" , "joint" , name = "climo_station_role_enum " ).create (op .get_bind ())
8682
8783 op .create_table (
88- "climatological_station_x_meta_history " ,
84+ "climo_stn_x_hist " ,
8985 Column (
90- "climatological_station_id " ,
86+ "climo_station_id " ,
9187 Integer ,
9288 ForeignKey (
93- f"{ schema_name } .climatological_station.climatological_station_id "
89+ f"{ schema_name } .climo_station.climo_station_id "
9490 ),
9591 primary_key = True ,
9692 ),
@@ -100,13 +96,11 @@ def upgrade():
10096 ForeignKey (f"{ schema_name } .meta_history.history_id" ),
10197 primary_key = True ,
10298 ),
103- Column ("role" , PG_ENUM ("base" , "joint" , name = "climatological_station_role_enum" , create_type = False ), nullable = False ),
104- Column ("mod_time" , DateTime , nullable = False ),
105- Column ("mod_user" , String , nullable = False ),
99+ Column ("role" , PG_ENUM ("base" , "joint" , name = "climo_station_role_enum" , create_type = False ), nullable = False ),
106100 schema = schema_name ,
107101 )
108102
109- Enum ("annual" , "seasonal" , "monthly" , name = "climatology_duration_enum " ).create (op .get_bind ())
103+ Enum ("annual" , "seasonal" , "monthly" , name = "climo_duration_enum " ).create (op .get_bind ())
110104
111105 op .create_table (
112106 # TODO: Columns in this table parallel those in meta_vars.
@@ -117,54 +111,50 @@ def upgrade():
117111 # prevent entry of erroneous values that just happen to be very long?)
118112 #
119113 # - None are nullable. In contrast, most in the model tables are.
120- "climatological_variable " ,
121- Column ("climatological_variable_id " , Integer , primary_key = True ),
114+ "climo_variable " ,
115+ Column ("climo_variable_id " , Integer , primary_key = True ),
122116 Column (
123- "duration" , PG_ENUM ("annual" , "seasonal" , "monthly" , name = "climatology_duration_enum " , create_type = False ), nullable = False
117+ "duration" , PG_ENUM ("annual" , "seasonal" , "monthly" , name = "climo_duration_enum " , create_type = False ), nullable = False
124118 ),
125119 Column ("unit" , String , nullable = False ),
126120 Column ("standard_name" , String , nullable = False ),
127121 Column ("display_name" , String , nullable = False ),
128122 Column ("short_name" , String , nullable = False ),
129123 Column ("cell_methods" , String , nullable = False ),
130124 Column ("net_var_name" , CITEXT (), nullable = False ),
131- Column ("mod_time" , DateTime , nullable = False ),
132- Column ("mod_user" , String , nullable = False ),
133125 schema = schema_name ,
134126 )
135127
136128 op .create_table (
137- "climatological_value " ,
138- Column ("climatological_value_id " , Integer , primary_key = True ),
129+ "climo_value " ,
130+ Column ("climo_value_id " , Integer , primary_key = True ),
139131 Column ("value_time" , DateTime , nullable = False ),
140132 Column ("value" , Float , nullable = False ),
141133 Column ("num_contributing_years" , Integer , nullable = False ),
142134 Column (
143- "climatological_variable_id " ,
135+ "climo_variable_id " ,
144136 Integer ,
145137 ForeignKey (
146- f"{ schema_name } .climatological_variable.climatological_variable_id "
138+ f"{ schema_name } .climo_variable.climo_variable_id "
147139 ),
148140 ),
149141 Column (
150- "climatological_station_id " ,
142+ "climo_station_id " ,
151143 Integer ,
152144 ForeignKey (
153- f"{ schema_name } .climatological_station.climatological_station_id "
145+ f"{ schema_name } .climo_station.climo_station_id "
154146 ),
155147 ),
156- Column ("mod_time" , DateTime , nullable = False ),
157- Column ("mod_user" , String , nullable = False ),
158148 schema = schema_name ,
159149 )
160150
161151
162152def downgrade ():
163- op .drop_table ("climatological_value " , schema = schema_name )
164- op .drop_table ("climatological_variable " , schema = schema_name )
165- Enum ("annual" , "seasonal" , "monthly" , name = "climatology_duration_enum " ).drop (op .get_bind ())
166- op .drop_table ("climatological_station_x_meta_history " , schema = schema_name )
167- Enum ("base" , "joint" , name = "climatological_station_role_enum " ).drop (op .get_bind ())
168- op .drop_table ("climatological_station " , schema = schema_name )
169- Enum ("long-record" , "composite" , "prism" , name = "climatological_station_type_enum " ).drop (op .get_bind ())
170- op .drop_table ("climatological_period " , schema = schema_name )
153+ op .drop_table ("climo_value " , schema = schema_name )
154+ op .drop_table ("climo_variable " , schema = schema_name )
155+ Enum ("annual" , "seasonal" , "monthly" , name = "climo_duration_enum " ).drop (op .get_bind ())
156+ op .drop_table ("climo_stn_x_hist " , schema = schema_name )
157+ Enum ("base" , "joint" , name = "climo_station_role_enum " ).drop (op .get_bind ())
158+ op .drop_table ("climo_station " , schema = schema_name )
159+ Enum ("long-record" , "composite" , "prism" , name = "climo_station_type_enum " ).drop (op .get_bind ())
160+ op .drop_table ("climo_period " , schema = schema_name )
0 commit comments