Page MenuHomePhabricator
Paste P9249

(An Untitled Masterwork)
ActivePublic

Authored by Marostegui on Oct 7 2019, 2:52 PM.
Tags
None
Referenced Files
F30580913: raw.txt
Oct 7 2019, 2:54 PM
F30580906: raw.txt
Oct 7 2019, 2:52 PM
Subscribers
CREATE TABLE IF NOT EXISTS `qos_dscp_marking_rules` (
`id` varchar(36) NOT NULL,
`qos_policy_id` varchar(36) NOT NULL,
`dscp_mark` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `qos_policy_id` (`qos_policy_id`),
CONSTRAINT `qos_dscp_marking_rules_ibfk_1` FOREIGN KEY (`qos_policy_id`) REFERENCES `qos_policies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;

Event Timeline

root@db1133.eqiad.wmnet[neutron]> show create table qos_dscp_marking_rules\G
*************************** 1. row ***************************
       Table: qos_dscp_marking_rules
Create Table: CREATE TABLE `qos_dscp_marking_rules` (
  `id` varchar(36) NOT NULL,
  `qos_policy_id` varchar(36) NOT NULL,
  `dscp_mark` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `qos_policy_id` (`qos_policy_id`),
  CONSTRAINT `qos_dscp_marking_rules_ibfk_1` FOREIGN KEY (`qos_policy_id`) REFERENCES `qos_policies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
diff --git a/neutron/db/migration/__init__.py b/neutron/db/migration/__init__.py
index c5b1d773b8..ed55ff5f13 100644
--- a/neutron/db/migration/__init__.py
+++ b/neutron/db/migration/__init__.py
@@ -203,7 +203,7 @@ def create_table_if_not_exist_psql(table_name, values):
     op.execute("CREATE OR REPLACE FUNCTION table_exist(TEXT) RETURNS bool as "
                "$$ SELECT exists(select 1 from pg_class where relname=$1);"
                "$$ language sql STRICT;")
-    op.execute("SELECT execute($$CREATE TABLE %(name)s %(columns)s $$) "
+    op.execute("SELECT execute($$CREATE TABLE IF NOT EXISTS %(name)s %(columns)s $$) "
                "WHERE NOT table_exist(%(name)r);" %
                {'name': table_name,
                 'columns': values})