)]}'
{"keystone/common/sql/migrate_repo/versions/037_add_region_table.py":[{"author":{"_account_id":6486,"name":"Brant Knudson","email":"blk@acm.org","username":"blk-u"},"change_message_id":"2fc6f97fa2cc63b3dedde0b88caf05c1a8dbd37e","unresolved":false,"context_lines":[{"line_number":23,"context_line":"        \u0027region\u0027,"},{"line_number":24,"context_line":"        meta,"},{"line_number":25,"context_line":"        sql.Column(\u0027id\u0027, sql.String(64), primary_key\u003dTrue),"},{"line_number":26,"context_line":"        sql.Column(\u0027description\u0027, sql.String(255), nullable\u003dFalse),"},{"line_number":27,"context_line":"        sql.Column(\u0027parent_region_id\u0027, sql.String(64), nullable\u003dTrue),"},{"line_number":28,"context_line":"        sql.Column(\u0027extra\u0027, sql.Text()))"},{"line_number":29,"context_line":"    region_table.create(migrate_engine, checkfirst\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":6,"id":"AAAAWH%2F%2F%2ByI%3D","line":26,"updated":"2014-03-12 15:15:15.000000000","message":"revert this change. We don\u0027t want a weird situation where somebody\u0027s got one version of migration 37 and somebody else has a different version.","commit_id":"f4f25f64c622dbe6eb8f1e386430091a87b26fb2"}],"keystone/common/sql/migrate_repo/versions/043_fixup_region_description.py":[{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"1b151821e42c946913843396a5045472c2c84840","unresolved":false,"context_lines":[{"line_number":39,"context_line":"    meta.bind \u003d migrate_engine"},{"line_number":40,"context_line":"    session \u003d sessionmaker(bind\u003dmigrate_engine)()"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"    session.execute(\u0027ALTER TABLE region DROP INDEX description;\u0027)"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"def downgrade(migrate_engine):"},{"line_number":45,"context_line":"    meta \u003d sql.MetaData()"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAVn%2F%2FINM%3D","line":42,"updated":"2014-03-08 17:37:31.000000000","message":"I\u0027ve tried taking this type of approach to alter the region table: \n\nhttps://github.com/openstack/keystone/blob/master/keystone/common/sql/migrate_repo/versions/032_username_length.py\n\nonly with \n\n    region_table.c.description.alter(unique\u003dFalse) \n\nBut that doesn\u0027t seem to change the db schema at all.","commit_id":"a53b888bd2b83c8d2a879592fd4cd9d539d33adb"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"d277df26ca1a89c00ad3e72483aa43d5a284a7d0","unresolved":false,"context_lines":[{"line_number":39,"context_line":"    meta.bind \u003d migrate_engine"},{"line_number":40,"context_line":"    session \u003d sessionmaker(bind\u003dmigrate_engine)()"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"    session.execute(\u0027ALTER TABLE region DROP INDEX description;\u0027)"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"def downgrade(migrate_engine):"},{"line_number":45,"context_line":"    meta \u003d sql.MetaData()"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAVn%2F%2FAsQ%3D","line":42,"in_reply_to":"AAAAVn%2F%2FDdI%3D","updated":"2014-03-10 18:10:33.000000000","message":"per discussion with Jay and Morgan on IRC (#openstack-keystone) we\u0027re having issues with this implementation. I am going to be pushing a new patch consisting of: \n\n    1.) create a tmp region table with \u0027unique\u003dFalse\u0027 \n    2.) migrate all data over from \u0027region\u0027 table to \u0027tmp_region\u0027\n    3.) rename \u0027tmp_region\u0027 table to \u0027region\u0027\n\nfor the upgrade case.","commit_id":"a53b888bd2b83c8d2a879592fd4cd9d539d33adb"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"51fd466e0dffb9c097a18978a54d1a0fc10220fa","unresolved":false,"context_lines":[{"line_number":39,"context_line":"    meta.bind \u003d migrate_engine"},{"line_number":40,"context_line":"    session \u003d sessionmaker(bind\u003dmigrate_engine)()"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"    session.execute(\u0027ALTER TABLE region DROP INDEX description;\u0027)"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"def downgrade(migrate_engine):"},{"line_number":45,"context_line":"    meta \u003d sql.MetaData()"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAVn%2F%2FHjs%3D","line":42,"in_reply_to":"AAAAVn%2F%2FH3k%3D","updated":"2014-03-09 05:19:24.000000000","message":"++ Drop the constraint with SQL-A Migrate, raw ALTER (or sql) will cause nothing but heartache in the future.\n\nJay has hit it dead on, drop the constraint  and create a new one.","commit_id":"a53b888bd2b83c8d2a879592fd4cd9d539d33adb"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"02c04aa6c96948039fb99c725f4da571fe79a8b3","unresolved":false,"context_lines":[{"line_number":39,"context_line":"    meta.bind \u003d migrate_engine"},{"line_number":40,"context_line":"    session \u003d sessionmaker(bind\u003dmigrate_engine)()"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"    session.execute(\u0027ALTER TABLE region DROP INDEX description;\u0027)"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"def downgrade(migrate_engine):"},{"line_number":45,"context_line":"    meta \u003d sql.MetaData()"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAVn%2F%2FDdI%3D","line":42,"in_reply_to":"AAAAVn%2F%2FHjs%3D","updated":"2014-03-10 11:32:31.000000000","message":"Thanks guys, I appreciate the help. I\u0027ll give that a shot and post another patch soon.","commit_id":"a53b888bd2b83c8d2a879592fd4cd9d539d33adb"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"2cee8bb2344ee172faa3388d9109bd1f9189d4c2","unresolved":false,"context_lines":[{"line_number":39,"context_line":"    meta.bind \u003d migrate_engine"},{"line_number":40,"context_line":"    session \u003d sessionmaker(bind\u003dmigrate_engine)()"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"    session.execute(\u0027ALTER TABLE region DROP INDEX description;\u0027)"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"def downgrade(migrate_engine):"},{"line_number":45,"context_line":"    meta \u003d sql.MetaData()"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAAVn%2F%2FH3k%3D","line":42,"in_reply_to":"AAAAVn%2F%2FINM%3D","updated":"2014-03-08 21:25:27.000000000","message":"Right, that is because the column definition is not actually where the uniqueness constraint is applied in the database (the uniqueness constraint is applied in the index definition in MySQL and in a UNIQUE CONSTRAINT definition in PostgreSQL). So, technically, the solution above will only work for MySQL properly. PostgreSQL does not have an `ALTER TABLE \u003ctable\u003e DROP INDEX \u003cindex\u003e` construct. It has a `DROP INDEX \u003cfq_index\u003e` custom extension in its SQL, but you will want to drop the constraint like so:\n\n ALTER TABLE \u003ctable\u003e DROP CONSTRAINT \u003cconstraint_name\u003e\n\nI think a more workable solution might be to use SA-migrate functionality to drop the constraint or index, like so:\n\n from migrate.changeset.constraint import UniqueConstraint\n from sqlalchemy import Table\n ...\n\n region_table \u003d Table(\u0027region\u0027, meta\u003dmeta, autoload\u003dTrue)\n duc \u003d UniqueConstraint(\u0027description\u0027, table\u003dregion_table)\n duc.drop()","commit_id":"a53b888bd2b83c8d2a879592fd4cd9d539d33adb"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"a42990e41e6ece915aa14f54a5286fb4179544cf","unresolved":false,"context_lines":[{"line_number":60,"context_line":"                        {\u0027id\u0027: region.id,"},{"line_number":61,"context_line":"                         \u0027description\u0027: region.description,"},{"line_number":62,"context_line":"                         \u0027parent_region_id\u0027: region.parent_region_id,"},{"line_number":63,"context_line":"                         \u0027extra\u0027: region.extra})"},{"line_number":64,"context_line":""},{"line_number":65,"context_line":"    # Drop the old region table"},{"line_number":66,"context_line":"    session.execute(\u0027drop table region;\u0027)"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0vI%3D","line":63,"updated":"2014-03-11 22:50:52.000000000","message":"Is there a reason to use raw sql instead of using the SQL-Alchemy query structures to migrate data? I\u0027m concerned that the raw SQL is going to be fragile to maintain especially across multiple engines and the peculiarities of those engines.","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"a42990e41e6ece915aa14f54a5286fb4179544cf","unresolved":false,"context_lines":[{"line_number":63,"context_line":"                         \u0027extra\u0027: region.extra})"},{"line_number":64,"context_line":""},{"line_number":65,"context_line":"    # Drop the old region table"},{"line_number":66,"context_line":"    session.execute(\u0027drop table region;\u0027)"},{"line_number":67,"context_line":""},{"line_number":68,"context_line":"    # Create new region table without unique constraint on description column."},{"line_number":69,"context_line":"    # We also need to create a new metadata stream since we are going to load"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0vs%3D","line":66,"updated":"2014-03-11 22:50:52.000000000","message":"is there a reason not to use region_table.drop() ?\n\nI am not a fan of raw SQL.","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"a42990e41e6ece915aa14f54a5286fb4179544cf","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"    # Create new region table without unique constraint on description column."},{"line_number":69,"context_line":"    # We also need to create a new metadata stream since we are going to load"},{"line_number":70,"context_line":"    # a different version of the region table."},{"line_number":71,"context_line":"    meta2 \u003d sql.MetaData()"},{"line_number":72,"context_line":"    meta2.bind \u003d migrate_engine"},{"line_number":73,"context_line":"    new_region_table \u003d sql.Table("}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0v4%3D","line":70,"updated":"2014-03-11 22:50:52.000000000","message":"Is there a functional reason to not use table.rename() on the \"temp_table\"?","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"62e256c75f275018399204100823a124b82b1335","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"    # Create new region table without unique constraint on description column."},{"line_number":69,"context_line":"    # We also need to create a new metadata stream since we are going to load"},{"line_number":70,"context_line":"    # a different version of the region table."},{"line_number":71,"context_line":"    meta2 \u003d sql.MetaData()"},{"line_number":72,"context_line":"    meta2.bind \u003d migrate_engine"},{"line_number":73,"context_line":"    new_region_table \u003d sql.Table("}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0no%3D","line":70,"in_reply_to":"AAAAVn%2F%2B0rc%3D","updated":"2014-03-11 23:14:13.000000000","message":"I looked into this too, but through doing some quick research it looks like we would have to carry specific (raw) SQL for the different cases. This is by no means official documentation, but it\u0027s something I stumbled across: \nhttps://groups.google.com/forum/#!topic/sqlalchemy/f1D1LBkaWCE","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"1c391798ebcb2a1a9a5912f9e87fb04962754cea","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"    # Create new region table without unique constraint on description column."},{"line_number":69,"context_line":"    # We also need to create a new metadata stream since we are going to load"},{"line_number":70,"context_line":"    # a different version of the region table."},{"line_number":71,"context_line":"    meta2 \u003d sql.MetaData()"},{"line_number":72,"context_line":"    meta2.bind \u003d migrate_engine"},{"line_number":73,"context_line":"    new_region_table \u003d sql.Table("}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0rc%3D","line":70,"in_reply_to":"AAAAVn%2F%2B0v4%3D","updated":"2014-03-11 23:00:19.000000000","message":"Hm, looks like table.rename doesn\u0027t exist, but I\u0027m looking into what the alternative is.","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"},{"author":{"_account_id":2903,"name":"Morgan Fainberg","email":"morgan.fainberg@gmail.com","username":"mdrnstm"},"change_message_id":"a42990e41e6ece915aa14f54a5286fb4179544cf","unresolved":false,"context_lines":[{"line_number":82,"context_line":"    # Migrate data from temp_region table to region table"},{"line_number":83,"context_line":"    for region in session.query(temp_region_table):"},{"line_number":84,"context_line":"        session.execute(\u0027insert into region (id, description, \u0027"},{"line_number":85,"context_line":"                        \u0027parent_region_id, extra) values \u0027"},{"line_number":86,"context_line":"                        \u0027( :id, :description, :parent_region_id, :extra);\u0027,"},{"line_number":87,"context_line":"                        {\u0027id\u0027: region.id,"},{"line_number":88,"context_line":"                         \u0027description\u0027: region.description,"}],"source_content_type":"text/x-python","patch_set":4,"id":"AAAAVn%2F%2B0u8%3D","line":85,"updated":"2014-03-11 22:50:52.000000000","message":"Same comment as on line 63","commit_id":"87dde510a4f60818e4b57a6144f15a4174d27d5e"}]}
