OpenStack Image Management (Glance)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mitaka01_add_image_created_updated_idx.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright 2016 Rackspace
  2. # Copyright 2013 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. """add index on created_at and updated_at columns of 'images' table
  16. Revision ID: mitaka01
  17. Revises: liberty
  18. Create Date: 2016-08-03 17:19:35.306161
  19. """
  20. from alembic import op
  21. from sqlalchemy import MetaData, Table, Index
  22. # revision identifiers, used by Alembic.
  23. revision = 'mitaka01'
  24. down_revision = 'liberty'
  25. branch_labels = None
  26. depends_on = None
  27. CREATED_AT_INDEX = 'created_at_image_idx'
  28. UPDATED_AT_INDEX = 'updated_at_image_idx'
  29. def upgrade():
  30. migrate_engine = op.get_bind()
  31. meta = MetaData(bind=migrate_engine)
  32. images = Table('images', meta, autoload=True)
  33. created_index = Index(CREATED_AT_INDEX, images.c.created_at)
  34. created_index.create(migrate_engine)
  35. updated_index = Index(UPDATED_AT_INDEX, images.c.updated_at)
  36. updated_index.create(migrate_engine)