"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/common/sql/contract_repo/versions/072_contract_drop_domain_id_fk.py" (13 May 2020, 1744 Bytes) of package /linux/misc/openstack/keystone-17.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "072_contract_drop_domain_id_fk.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2019 SUSE LLC
    2 #
    3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 #    not use this file except in compliance with the License. You may obtain
    5 #    a copy of the License at
    6 #
    7 #         http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 #    Unless required by applicable law or agreed to in writing, software
   10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 #    License for the specific language governing permissions and limitations
   13 #    under the License.
   14 
   15 # This is a placeholder for Train backports. Do not use this number for new
   16 # Ussuri work. New Ussuri work starts after all the placeholders.
   17 
   18 import migrate
   19 import sqlalchemy as sql
   20 
   21 
   22 def upgrade(migrate_engine):
   23     meta = sql.MetaData()
   24     meta.bind = migrate_engine
   25     user = sql.Table('user', meta, autoload=True)
   26     project = sql.Table('project', meta, autoload=True)
   27 
   28     fk_name = [
   29         c for c in user.constraints
   30         if isinstance(c, sql.ForeignKeyConstraint)
   31         and c.column_keys == ['domain_id']
   32     ][0].name
   33     fk_constraint = migrate.ForeignKeyConstraint(
   34         columns=[user.c.domain_id], refcolumns=[project.c.id])
   35     fk_constraint.name = fk_name
   36     fk_constraint.drop()
   37 
   38     identity_provider = sql.Table('identity_provider', meta, autoload=True)
   39     fk_name = [
   40         c for c in identity_provider.constraints
   41         if isinstance(c, sql.ForeignKeyConstraint)
   42         and c.column_keys == ['domain_id']
   43     ][0].name
   44     fk_constraint = migrate.ForeignKeyConstraint(
   45         columns=[identity_provider.c.domain_id], refcolumns=[project.c.id])
   46     fk_constraint.name = fk_name
   47     fk_constraint.drop()