@@ -130,6 +130,9 @@ def upgrade(migrate_engine):
130
130
Column ('url' , String (length = 255 )),
131
131
Column ('md5hash' , String (length = 255 )),
132
132
Column ('deleted' , Integer ),
133
+ UniqueConstraint (
134
+ 'hypervisor' , 'os' , 'architecture' , 'deleted' ,
135
+ name = 'uniq_agent_builds0hypervisor0os0architecture0deleted' ),
133
136
mysql_engine = 'InnoDB' ,
134
137
mysql_charset = 'utf8'
135
138
)
@@ -140,9 +143,13 @@ def upgrade(migrate_engine):
140
143
Column ('deleted_at' , DateTime ),
141
144
Column ('id' , Integer , primary_key = True , nullable = False ),
142
145
Column ('host' , String (length = 255 )),
143
- Column ('aggregate_id' , Integer , ForeignKey ('aggregates.id' ),
144
- nullable = False ),
146
+ Column (
147
+ 'aggregate_id' , Integer , ForeignKey ('aggregates.id' ),
148
+ nullable = False ),
145
149
Column ('deleted' , Integer ),
150
+ UniqueConstraint (
151
+ 'host' , 'aggregate_id' , 'deleted' ,
152
+ name = 'uniq_aggregate_hosts0host0aggregate_id0deleted' ),
146
153
mysql_engine = 'InnoDB' ,
147
154
mysql_charset = 'utf8'
148
155
)
@@ -152,11 +159,15 @@ def upgrade(migrate_engine):
152
159
Column ('updated_at' , DateTime ),
153
160
Column ('deleted_at' , DateTime ),
154
161
Column ('id' , Integer , primary_key = True , nullable = False ),
155
- Column ('aggregate_id' , Integer , ForeignKey ('aggregates.id' ),
156
- nullable = False ),
162
+ Column (
163
+ 'aggregate_id' , Integer , ForeignKey ('aggregates.id' ),
164
+ nullable = False ),
157
165
Column ('key' , String (length = 255 ), nullable = False ),
158
166
Column ('value' , String (length = 255 ), nullable = False ),
159
167
Column ('deleted' , Integer ),
168
+ UniqueConstraint (
169
+ 'aggregate_id' , 'key' , 'deleted' ,
170
+ name = 'uniq_aggregate_metadata0aggregate_id0key0deleted' ),
160
171
mysql_engine = 'InnoDB' ,
161
172
mysql_charset = 'utf8'
162
173
)
@@ -227,6 +238,9 @@ def upgrade(migrate_engine):
227
238
Column ('is_parent' , Boolean ),
228
239
Column ('deleted' , Integer ),
229
240
Column ('transport_url' , String (length = 255 ), nullable = False ),
241
+ UniqueConstraint (
242
+ 'name' , 'deleted' ,
243
+ name = 'uniq_cells0name0deleted' ),
230
244
mysql_engine = 'InnoDB' ,
231
245
mysql_charset = 'utf8'
232
246
)
@@ -299,6 +313,9 @@ def upgrade(migrate_engine):
299
313
Column ('host' , String (length = 255 )),
300
314
Column ('compute_host' , String (length = 255 )),
301
315
Column ('deleted' , Integer ),
316
+ UniqueConstraint (
317
+ 'host' , 'console_type' , 'compute_host' , 'deleted' ,
318
+ name = 'uniq_console_pools0host0console_type0compute_host0deleted' ),
302
319
mysql_engine = 'InnoDB' ,
303
320
mysql_charset = 'utf8'
304
321
)
@@ -347,6 +364,9 @@ def upgrade(migrate_engine):
347
364
Column ('host' , String (length = 255 )),
348
365
Column ('instance_uuid' , String (length = 36 )),
349
366
Column ('deleted' , Integer ),
367
+ UniqueConstraint (
368
+ 'address' , 'deleted' ,
369
+ name = 'uniq_fixed_ips0address0deleted' ),
350
370
mysql_engine = 'InnoDB' ,
351
371
mysql_charset = 'utf8'
352
372
)
@@ -364,6 +384,9 @@ def upgrade(migrate_engine):
364
384
Column ('pool' , String (length = 255 )),
365
385
Column ('interface' , String (length = 255 )),
366
386
Column ('deleted' , Integer ),
387
+ UniqueConstraint (
388
+ 'address' , 'deleted' ,
389
+ name = 'uniq_floating_ips0address0deleted' ),
367
390
mysql_engine = 'InnoDB' ,
368
391
mysql_charset = 'utf8'
369
392
)
@@ -402,6 +425,9 @@ def upgrade(migrate_engine):
402
425
Column ('network_info' , MediumText ()),
403
426
Column ('instance_uuid' , String (length = 36 ), nullable = False ),
404
427
Column ('deleted' , Integer ),
428
+ UniqueConstraint (
429
+ 'instance_uuid' ,
430
+ name = 'uniq_instance_info_caches0instance_uuid' ),
405
431
mysql_engine = 'InnoDB' ,
406
432
mysql_charset = 'utf8'
407
433
)
@@ -498,6 +524,10 @@ def upgrade(migrate_engine):
498
524
Column ('key' , String (length = 255 )),
499
525
Column ('value' , String (length = 255 )),
500
526
Column ('deleted' , Integer ),
527
+ UniqueConstraint (
528
+ 'instance_type_id' , 'key' , 'deleted' ,
529
+ name = 'uniq_instance_type_extra_specs0instance_type_id0key0deleted'
530
+ ),
501
531
mysql_engine = 'InnoDB' ,
502
532
mysql_charset = 'utf8'
503
533
)
@@ -510,6 +540,10 @@ def upgrade(migrate_engine):
510
540
Column ('instance_type_id' , Integer , nullable = False ),
511
541
Column ('project_id' , String (length = 255 )),
512
542
Column ('deleted' , Integer ),
543
+ UniqueConstraint (
544
+ 'instance_type_id' , 'project_id' , 'deleted' ,
545
+ name = 'uniq_instance_type_projects0instance_type_id0project_id'
546
+ '0deleted' ),
513
547
mysql_engine = 'InnoDB' ,
514
548
mysql_charset = 'utf8'
515
549
)
@@ -531,6 +565,12 @@ def upgrade(migrate_engine):
531
565
Column ('disabled' , Boolean ),
532
566
Column ('is_public' , Boolean ),
533
567
Column ('deleted' , Integer ),
568
+ UniqueConstraint (
569
+ 'name' , 'deleted' ,
570
+ name = 'uniq_instance_types0name0deleted' ),
571
+ UniqueConstraint (
572
+ 'flavorid' , 'deleted' ,
573
+ name = 'uniq_instance_types0flavorid0deleted' ),
534
574
mysql_engine = 'InnoDB' ,
535
575
mysql_charset = 'utf8'
536
576
)
@@ -652,6 +692,9 @@ def upgrade(migrate_engine):
652
692
Column ('fingerprint' , String (length = 255 )),
653
693
Column ('public_key' , MediumText ()),
654
694
Column ('deleted' , Integer ),
695
+ UniqueConstraint (
696
+ 'user_id' , 'name' , 'deleted' ,
697
+ name = 'uniq_key_pairs0user_id0name0deleted' ),
655
698
mysql_engine = 'InnoDB' ,
656
699
mysql_charset = 'utf8'
657
700
)
@@ -705,6 +748,7 @@ def upgrade(migrate_engine):
705
748
Column ('priority' , Integer ),
706
749
Column ('rxtx_base' , Integer ),
707
750
Column ('deleted' , Integer ),
751
+ UniqueConstraint ('vlan' , 'deleted' , name = 'uniq_networks0vlan0deleted' ),
708
752
mysql_engine = 'InnoDB' ,
709
753
mysql_charset = 'utf8'
710
754
)
@@ -787,6 +831,9 @@ def upgrade(migrate_engine):
787
831
Column ('resource' , String (length = 255 ), nullable = False ),
788
832
Column ('hard_limit' , Integer ),
789
833
Column ('deleted' , Integer ),
834
+ UniqueConstraint (
835
+ 'project_id' , 'resource' , 'deleted' ,
836
+ name = 'uniq_quotas0project_id0resource0deleted' ),
790
837
mysql_engine = 'InnoDB' ,
791
838
mysql_charset = 'utf8'
792
839
)
@@ -876,6 +923,9 @@ def upgrade(migrate_engine):
876
923
Column ('user_id' , String (length = 255 )),
877
924
Column ('project_id' , String (length = 255 )),
878
925
Column ('deleted' , Integer ),
926
+ UniqueConstraint (
927
+ 'project_id' , 'name' , 'deleted' ,
928
+ name = 'uniq_security_groups0project_id0name0deleted' ),
879
929
mysql_engine = 'InnoDB' ,
880
930
mysql_charset = 'utf8'
881
931
)
@@ -906,6 +956,12 @@ def upgrade(migrate_engine):
906
956
Column ('disabled' , Boolean ),
907
957
Column ('deleted' , Integer ),
908
958
Column ('disabled_reason' , String (length = 255 )),
959
+ UniqueConstraint (
960
+ 'host' , 'topic' , 'deleted' ,
961
+ name = 'uniq_services0host0topic0deleted' ),
962
+ UniqueConstraint (
963
+ 'host' , 'binary' , 'deleted' ,
964
+ name = 'uniq_services0host0binary0deleted' ),
909
965
mysql_engine = 'InnoDB' ,
910
966
mysql_charset = 'utf8'
911
967
)
@@ -954,6 +1010,10 @@ def upgrade(migrate_engine):
954
1010
Column ('task_items' , Integer ),
955
1011
Column ('errors' , Integer ),
956
1012
Column ('deleted' , Integer ),
1013
+ UniqueConstraint (
1014
+ 'task_name' , 'host' , 'period_beginning' , 'period_ending' ,
1015
+ name = 'uniq_task_log0task_name0host0period_beginning0period_ending' ,
1016
+ ),
957
1017
mysql_engine = 'InnoDB' ,
958
1018
mysql_charset = 'utf8'
959
1019
)
@@ -968,6 +1028,9 @@ def upgrade(migrate_engine):
968
1028
Column ('uuid' , String (length = 36 )),
969
1029
Column ('instance_uuid' , String (length = 36 ), nullable = True ),
970
1030
Column ('deleted' , Integer ),
1031
+ UniqueConstraint (
1032
+ 'address' , 'deleted' ,
1033
+ name = 'uniq_virtual_interfaces0address0deleted' ),
971
1034
mysql_engine = 'InnoDB' ,
972
1035
mysql_charset = 'utf8'
973
1036
)
@@ -1069,104 +1132,6 @@ def upgrade(migrate_engine):
1069
1132
LOG .exception ('Exception while creating table.' )
1070
1133
raise
1071
1134
1072
- # task log unique constraint
1073
- task_log_uc = "uniq_task_log0task_name0host0period_beginning0period_ending"
1074
- task_log_cols = ('task_name' , 'host' , 'period_beginning' , 'period_ending' )
1075
- uc = UniqueConstraint (* task_log_cols , table = task_log , name = task_log_uc )
1076
- uc .create ()
1077
-
1078
- # networks unique constraint
1079
- UniqueConstraint ('vlan' , 'deleted' , table = networks ,
1080
- name = 'uniq_networks0vlan0deleted' ).create ()
1081
-
1082
- # instance_type_name constraint
1083
- UniqueConstraint ('name' , 'deleted' , table = instance_types ,
1084
- name = 'uniq_instance_types0name0deleted' ).create ()
1085
-
1086
- # flavorid unique constraint
1087
- UniqueConstraint ('flavorid' , 'deleted' , table = instance_types ,
1088
- name = 'uniq_instance_types0flavorid0deleted' ).create ()
1089
-
1090
- # keypair constraint
1091
- UniqueConstraint ('user_id' , 'name' , 'deleted' , table = key_pairs ,
1092
- name = 'uniq_key_pairs0user_id0name0deleted' ).create ()
1093
-
1094
- # instance_type_projects constraint
1095
- inst_type_uc_name = 'uniq_instance_type_projects0instance_type_id0' + \
1096
- 'project_id0deleted'
1097
- UniqueConstraint ('instance_type_id' , 'project_id' , 'deleted' ,
1098
- table = instance_type_projects ,
1099
- name = inst_type_uc_name ).create ()
1100
-
1101
- # floating_ips unique constraint
1102
- UniqueConstraint ('address' , 'deleted' ,
1103
- table = floating_ips ,
1104
- name = 'uniq_floating_ips0address0deleted' ).create ()
1105
-
1106
- # instance_info_caches
1107
- UniqueConstraint ('instance_uuid' ,
1108
- table = instance_info_caches ,
1109
- name = 'uniq_instance_info_caches0instance_uuid' ).create ()
1110
-
1111
- UniqueConstraint ('address' , 'deleted' ,
1112
- table = virtual_interfaces ,
1113
- name = 'uniq_virtual_interfaces0address0deleted' ).create ()
1114
-
1115
- # cells
1116
- UniqueConstraint ('name' , 'deleted' ,
1117
- table = cells ,
1118
- name = 'uniq_cells0name0deleted' ).create ()
1119
-
1120
- # security_groups
1121
- uc = UniqueConstraint ('project_id' , 'name' , 'deleted' ,
1122
- table = security_groups ,
1123
- name = 'uniq_security_groups0project_id0name0deleted' )
1124
- uc .create ()
1125
-
1126
- # quotas
1127
- UniqueConstraint ('project_id' , 'resource' , 'deleted' ,
1128
- table = quotas ,
1129
- name = 'uniq_quotas0project_id0resource0deleted' ).create ()
1130
-
1131
- # fixed_ips
1132
- UniqueConstraint ('address' , 'deleted' ,
1133
- table = fixed_ips ,
1134
- name = 'uniq_fixed_ips0address0deleted' ).create ()
1135
-
1136
- # services
1137
- UniqueConstraint ('host' , 'topic' , 'deleted' ,
1138
- table = services ,
1139
- name = 'uniq_services0host0topic0deleted' ).create ()
1140
- UniqueConstraint ('host' , 'binary' , 'deleted' ,
1141
- table = services ,
1142
- name = 'uniq_services0host0binary0deleted' ).create ()
1143
-
1144
- # agent_builds
1145
- uc_name = 'uniq_agent_builds0hypervisor0os0architecture0deleted'
1146
- UniqueConstraint ('hypervisor' , 'os' , 'architecture' , 'deleted' ,
1147
- table = agent_builds ,
1148
- name = uc_name ).create ()
1149
-
1150
- uc_name = 'uniq_console_pools0host0console_type0compute_host0deleted'
1151
- UniqueConstraint ('host' , 'console_type' , 'compute_host' , 'deleted' ,
1152
- table = console_pools ,
1153
- name = uc_name ).create ()
1154
-
1155
- uc_name = 'uniq_aggregate_hosts0host0aggregate_id0deleted'
1156
- UniqueConstraint ('host' , 'aggregate_id' , 'deleted' ,
1157
- table = aggregate_hosts ,
1158
- name = uc_name ).create ()
1159
-
1160
- uc_name = 'uniq_aggregate_metadata0aggregate_id0key0deleted'
1161
- UniqueConstraint ('aggregate_id' , 'key' , 'deleted' ,
1162
- table = aggregate_metadata ,
1163
- name = uc_name ).create ()
1164
-
1165
- uc_name = 'uniq_instance_type_extra_specs0instance_type_id0key0deleted'
1166
- UniqueConstraint ('instance_type_id' , 'key' , 'deleted' ,
1167
- table = instance_type_extra_specs ,
1168
- name = uc_name ).create ()
1169
-
1170
1135
# created first (to preserve ordering for schema diffs)
1171
1136
mysql_pre_indexes = [
1172
1137
Index ('instance_type_id' , instance_type_projects .c .instance_type_id ),
0 commit comments