<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0);">
<div style="font-family: Calibri, sans-serif; font-size: 14px;">Hi,</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">I am trying to add two new columns to backups table in cinder. I created the new version file as follows:</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: #d53bd3">from</span> sqlalchemy
<span style="color: #d53bd3">import</span> Column, MetaData, String, Table, Boolean</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: #afad24">def</span>
<span style="color: #34bbc7">upgrade</span>(migrate_engine):</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> meta = MetaData()</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> meta.bind = migrate_engine</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups = Table(<span style="color: #c33720">'backups'</span>, meta, autoload=<span style="color: #34bbc7">True</span>)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> snapshot = Column(<span style="color: #c33720">'snapshot'</span>, Boolean(create_constraint=<span style="color: #34bbc7">False</span>, name=<span style="color: #34bbc7">None</span>))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> parent_id = Column(<span style="color: #c33720">'parent_id'</span>, String(length=<span style="color: #c33720">255</span>))</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.create_column(snapshot)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.create_column(parent_id)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.update().values(snapshot=<span style="color: #34bbc7">False</span>).execute()</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.update().values(parent_id=<span style="color: #34bbc7">None</span>).execute()</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: #afad24">def</span>
<span style="color: #34bbc7">downgrade</span>(migrate_engine):</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> meta = MetaData()</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> meta.bind = migrate_engine</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups = Table(<span style="color: #c33720">'backups'</span>, meta, autoload=<span style="color: #34bbc7">True</span>)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> snapshot = backups.columns.snapshot</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> parent_id = backups.columns.parent_id</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br>
</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.drop_column(snapshot)</p>
<p style="margin: 0px; font-size: 11px; font-family: Menlo;"> backups.drop_column(parent_id)</p>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">I can successfully add string column parent_id without any problem. However adding a boolean column is vexing. Adding a boolean column adds a check constraint on the table but when I remove the
column in the downgrade, the check constraint for snapshot still remains on the table which resulting in the following exception. Has anyone run into this problem?</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Calibri, sans-serif; font-size: 14px;">
<p style="margin: 0px; font-size: 11px; font-family: Menlo;">OperationalError: (OperationalError) no such column: snapshot u'\nCREATE TABLE backups (\n\tcreated_at DATETIME, \n\tupdated_at DATETIME, \n\tdeleted_at DATETIME, \n\tdeleted BOOLEAN, \n\tid VARCHAR(36)
NOT NULL, \n\tvolume_id VARCHAR(36) NOT NULL, \n\tuser_id VARCHAR(255), \n\tproject_id VARCHAR(255), \n\thost VARCHAR(255), \n\tavailability_zone VARCHAR(255), \n\tdisplay_name VARCHAR(255), \n\tdisplay_description VARCHAR(255), \n\tcontainer VARCHAR(255),
\n\tstatus VARCHAR(255), \n\tfail_reason VARCHAR(255), \n\tservice_metadata VARCHAR(255), \n\tservice VARCHAR(255), \n\tsize INTEGER, \n\tobject_count INTEGER, \n\tparent_id VARCHAR(255), \n\tPRIMARY KEY (id), \n\tCHECK (deleted IN (0, 1)), \n\tCHECK (snapshot
IN (0, 1))\n)\n\n' ()</p>
</div>
<br>
<div><font face="Menlo" size="2">Thanks,</font></div>
<div><font face="Menlo" size="2">Murali Balcha</font></div>
</body>
</html>