Page MenuHomePhabricator
Paste P9249

(An Untitled Masterwork)
ActivePublic

Authored by Marostegui on Mon, Oct 7, 2:52 PM.
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

Marostegui created this paste.Mon, Oct 7, 2:52 PM
Marostegui edited the content of this paste. (Show Details)Mon, Oct 7, 2:54 PM
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})