"Fossies" - the Fresh Open Source Software Archive

Member "cloudkitty-13.0.0/cloudkitty/rating/hash/db/sqlalchemy/alembic/versions/3dd7e13527f3_initial_migration.py" (14 Oct 2020, 3805 Bytes) of package /linux/misc/openstack/cloudkitty-13.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 "3dd7e13527f3_initial_migration.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 12.1.0_vs_13.0.0.

    1 #
    2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    3 # not use this file except in compliance with the License. You may obtain
    4 # a copy of the License at
    5 #
    6 #      http://www.apache.org/licenses/LICENSE-2.0
    7 #
    8 # Unless required by applicable law or agreed to in writing, software
    9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   11 # License for the specific language governing permissions and limitations
   12 # under the License.
   13 
   14 """Initial migration
   15 
   16 Revision ID: 3dd7e13527f3
   17 Revises: None
   18 Create Date: 2015-03-10 13:06:41.067563
   19 
   20 """
   21 
   22 # revision identifiers, used by Alembic.
   23 revision = '3dd7e13527f3'
   24 down_revision = None
   25 
   26 from alembic import op  # noqa: E402
   27 import sqlalchemy as sa  # noqa: E402
   28 
   29 
   30 def upgrade():
   31     op.create_table(
   32         'hashmap_services',
   33         sa.Column('id', sa.Integer(), nullable=False),
   34         sa.Column('service_id', sa.String(length=36), nullable=False),
   35         sa.Column('name', sa.String(length=255), nullable=False),
   36         sa.PrimaryKeyConstraint('id'),
   37         sa.UniqueConstraint('name'),
   38         sa.UniqueConstraint('service_id'),
   39         mysql_charset='utf8',
   40         mysql_engine='InnoDB')
   41     op.create_table(
   42         'hashmap_fields',
   43         sa.Column('id', sa.Integer(), nullable=False),
   44         sa.Column('field_id', sa.String(length=36), nullable=False),
   45         sa.Column('name', sa.String(length=255), nullable=False),
   46         sa.Column('service_id', sa.Integer(), nullable=False),
   47         sa.ForeignKeyConstraint(
   48             ['service_id'],
   49             ['hashmap_services.id'],
   50             ondelete='CASCADE'),
   51         sa.PrimaryKeyConstraint('id'),
   52         sa.UniqueConstraint('field_id'),
   53         sa.UniqueConstraint('field_id', 'name', name='uniq_field'),
   54         sa.UniqueConstraint(
   55             'service_id',
   56             'name',
   57             name='uniq_map_service_field'),
   58         mysql_charset='utf8',
   59         mysql_engine='InnoDB')
   60     op.create_table(
   61         'hashmap_groups',
   62         sa.Column('id', sa.Integer(), nullable=False),
   63         sa.Column('group_id', sa.String(length=36), nullable=False),
   64         sa.Column('name', sa.String(length=255), nullable=False),
   65         sa.PrimaryKeyConstraint('id'),
   66         sa.UniqueConstraint('group_id'),
   67         sa.UniqueConstraint('name'),
   68         mysql_charset='utf8',
   69         mysql_engine='InnoDB')
   70     op.create_table(
   71         'hashmap_maps',
   72         sa.Column('id', sa.Integer(), nullable=False),
   73         sa.Column('mapping_id', sa.String(length=36), nullable=False),
   74         sa.Column('value', sa.String(length=255), nullable=True),
   75         sa.Column('cost', sa.Numeric(20, 8), nullable=False),
   76         sa.Column(
   77             'map_type',
   78             sa.Enum('flat', 'rate', name='enum_map_type'),
   79             nullable=False),
   80         sa.Column('service_id', sa.Integer(), nullable=True),
   81         sa.Column('field_id', sa.Integer(), nullable=True),
   82         sa.Column('group_id', sa.Integer(), nullable=True),
   83         sa.ForeignKeyConstraint(
   84             ['field_id'],
   85             ['hashmap_fields.id'],
   86             ondelete='CASCADE'),
   87         sa.ForeignKeyConstraint(
   88             ['group_id'],
   89             ['hashmap_groups.id'],
   90             ondelete='SET NULL'),
   91         sa.ForeignKeyConstraint(
   92             ['service_id'],
   93             ['hashmap_services.id'],
   94             ondelete='CASCADE'),
   95         sa.PrimaryKeyConstraint('id'),
   96         sa.UniqueConstraint('mapping_id'),
   97         sa.UniqueConstraint(
   98             'value',
   99             'field_id',
  100             name='uniq_field_mapping'),
  101         sa.UniqueConstraint(
  102             'value',
  103             'service_id',
  104             name='uniq_service_mapping'),
  105         mysql_charset='utf8',
  106         mysql_engine='InnoDB')