text: #!/usr/bin/python2.7
  # -*- coding: utf8 -*-
  # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
  # File originally autogenerated by SQLAutoCode, then modified.
  # see http://code.google.com/p/sqlautocode/
  
  """
  Basic set of tables useful for web applications, test automation, and lab
  management.
  
  typical database:
    create DATABASE pycopia ENCODING 'utf-8' OWNER pycopia;
  
  """
  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import division
  
  from pytz import timezone
  from datetime import datetime
  
  from sqlalchemy import *
  from pycopia.db.types import *
  
  # default value constructors
  
  UTC = timezone('UTC')
  
  def time_now():
      return datetime.now(UTC)
  
  def default_active():
      return True
  
  def default_inactive():
      return False
  
  def default_obj(x): # call this one in default attribute
      return lambda: x
  
  
  metadata = MetaData()
  
  
  auth_message =  Table('auth_message', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('user_id', INTEGER(), primary_key=False, nullable=False),
              Column('message', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=False),
      ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='auth_message_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_auth_message_user_id', auth_message.c.user_id, unique=False)
  
  
  client_session =  Table('client_session', metadata,
      Column('session_key', VARCHAR(length=40, convert_unicode=False), primary_key=True, nullable=False),
              Column('data', PickleText(), primary_key=False, nullable=False, default=default_obj({})),
              Column('expire_date', TIMESTAMP(timezone=True), primary_key=False, nullable=False),
      schema='public')
  Index('index_client_session_pkey', client_session.c.session_key, unique=True)
  
  
  project_category =  Table('project_category', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_project_category_name_key', project_category.c.name, unique=True)
  
  
  config =  Table('config', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=True, default=default_obj(None)),
              Column('comment', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('parent_id', INTEGER(), primary_key=False),
              Column('user_id', INTEGER(), primary_key=False),
              Column('testcase_id', INTEGER(), primary_key=False),
              Column('testsuite_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'], name='config_testcase_id_fkey'),
              ForeignKeyConstraint(['testsuite_id'], ['public.test_suites.id'], name='config_testsuite_id_fkey'),
              ForeignKeyConstraint(['parent_id'], ['public.config.id'], name='parent_id_refs_config_id'),
              ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='config_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      UniqueConstraint("name", "parent_id"),
      schema='public')
  Index('index_config_testcase_id', config.c.testcase_id, unique=False)
  Index('index_config_name_key', config.c.name, config.c.parent_id, unique=True)
  Index('index_config_parent_id', config.c.parent_id, unique=False)
  Index('index_config_user_id', config.c.user_id, unique=False)
  Index('index_config_testsuite_id', config.c.testsuite_id, unique=False)
  
  
  contacts =  Table('contacts', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('prefix', VARCHAR(length=15, convert_unicode=False), primary_key=False),
              Column('firstname', VARCHAR(length=50, convert_unicode=False), primary_key=False, nullable=False),
              Column('middlename', VARCHAR(length=50, convert_unicode=False), primary_key=False),
              Column('lastname', VARCHAR(length=50, convert_unicode=False), primary_key=False, nullable=False),
              Column('title', VARCHAR(length=50, convert_unicode=False), primary_key=False),
              Column('position', VARCHAR(length=100, convert_unicode=False), primary_key=False),
              Column('phonehome', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('phoneoffice', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('phoneother', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('phonework', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('phonemobile', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('pager', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('fax', VARCHAR(length=25, convert_unicode=False), primary_key=False),
              Column('email', VARCHAR(length=80, convert_unicode=False), primary_key=False),
              Column('note', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('address_id', INTEGER(), primary_key=False),
              Column('user_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['address_id'], ['public.addresses.id'], name='contacts_address_id_fkey'),
              ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='contacts_user_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_contacts_address_id', contacts.c.address_id, unique=False)
  Index('index_contacts_lastname', contacts.c.lastname, unique=False)
  Index('index_contacts_user_id', contacts.c.user_id, unique=False)
  
  
  corp_attribute_type =  Table('corp_attribute_type', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('value_type', ValueType(), primary_key=False, nullable=False, default=ValueType.get_default),
      schema='public')
  Index('index_corp_attribute_type_name_key', corp_attribute_type.c.name, unique=True)
  
  
  corp_attributes =  Table('corp_attributes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('corporation_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['corporation_id'], ['public.corporations.id'], name='corp_attributes_corporation_id_fkey'),
              ForeignKeyConstraint(['type_id'], ['public.corp_attribute_type.id'], name='corp_attributes_type_id_fkey'),
      UniqueConstraint("type_id", "corporation_id"),
      schema='public')
  Index('index_corp_attributes_type_id', corp_attributes.c.type_id, unique=False)
  Index('index_corp_attributes_corporation_id', corp_attributes.c.corporation_id, unique=False)
  
  
  account_ids =  Table('account_ids', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('identifier', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('login', VARCHAR(length=80, convert_unicode=False), primary_key=False),
              Column('password', VARCHAR(length=80, convert_unicode=False), primary_key=False),
              Column('note', TEXT(length=None, convert_unicode=False), primary_key=False),
      schema='public')
  Index('index_account_ids_identifier', account_ids.c.identifier, unique=False)
  
  
  addresses =  Table('addresses', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('address', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=False),
              Column('address2', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=True),
              Column('city', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=True),
              Column('stateprov', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=True),
              Column('postalcode', VARCHAR(length=15, convert_unicode=False), primary_key=False, nullable=True),
              Column('country_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['country_id'], ['public.country_codes.id'], name='addresses_country_id_fkey'),
      schema='public')
  Index('index_addresses_country_id', addresses.c.country_id, unique=False)
  
  
  capability_group =  Table('capability_group', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_capability_group_name_key', capability_group.c.name, unique=True)
  
  
  capability_type =  Table('capability_type', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('group_id', INTEGER(), primary_key=False),
              Column('value_type', ValueType(), primary_key=False, nullable=False, default=ValueType.get_default),
      ForeignKeyConstraint(['group_id'], ['public.capability_group.id'], name='capability_type_group_id_fkey'),
      schema='public')
  Index('index_capability_type_name_key', capability_type.c.name, unique=True)
  Index('index_capability_type_group_id', capability_type.c.group_id, unique=False)
  
  
  capability =  Table('capability', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('equipment_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['equipment_id'], ['public.equipment.id'], name='capability_equipment_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
              ForeignKeyConstraint(['type_id'], ['public.capability_type.id'], name='capability_type_id_fkey'),
      schema='public')
  Index('index_capability_equipment_id', capability.c.equipment_id, unique=False)
  Index('index_capability_type_id', capability.c.type_id, unique=False)
  
  
  location =  Table('location', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('locationcode', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('address_id', INTEGER(), primary_key=False),
              Column('contact_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['address_id'], ['public.addresses.id'], name='location_address_id_fkey'),
              ForeignKeyConstraint(['contact_id'], ['public.contacts.id'], name='location_contact_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_location_address_id', location.c.address_id, unique=False)
  Index('index_location_contact_id', location.c.contact_id, unique=False)
  
  
  attribute_type =  Table('attribute_type', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('value_type', ValueType(), primary_key=False, nullable=False, default=ValueType.get_default),
      schema='public')
  Index('index_attribute_type_name_key', attribute_type.c.name, unique=True)
  
  
  software_attributes =  Table('software_attributes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('software_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['software_id'], ['public.software.id'], name='software_attributes_software_id_fkey'),
              ForeignKeyConstraint(['type_id'], ['public.attribute_type.id'], name='software_attributes_type_id_fkey'),
      UniqueConstraint("type_id", "software_id"),
      schema='public')
  Index('index_software_attributes_software_id', software_attributes.c.software_id, unique=False)
  Index('index_software_attributes_type_id', software_attributes.c.type_id, unique=False)
  
  
  environmentattribute_type =  Table('environmentattribute_type', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('value_type', ValueType(), primary_key=False, nullable=False, default=ValueType.get_default),
      schema='public')
  Index('index_environmentattribute_type_name_key', environmentattribute_type.c.name, unique=True)
  
  
  environment_attributes =  Table('environment_attributes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('environment_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['environment_id'], ['public.environments.id'], name='environment_attributes_environment_id_fkey'),
              ForeignKeyConstraint(['type_id'], ['public.environmentattribute_type.id'], name='environment_attributes_type_id_fkey'),
      UniqueConstraint("type_id", "environment_id"),
      schema='public')
  Index('index_environment_attributes_environment_id', environment_attributes.c.environment_id, unique=False)
  Index('index_environment_attributes_type_id', environment_attributes.c.type_id, unique=False)
  
  
  test_jobs =  Table('test_jobs', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('user_id', INTEGER(), primary_key=False, nullable=False),
              Column('environment_id', INTEGER(), primary_key=False, nullable=False),
              Column('testsuite_id', INTEGER(), primary_key=False, nullable=False),
              Column('reportname', VARCHAR(length=80, convert_unicode=False), primary_key=False,
                      nullable=False, default=default_obj("email")),
              Column('parameters', TEXT(), primary_key=False),
              Column('isscheduled', BOOLEAN(), primary_key=False, nullable=False, default=default_inactive),
              Column('schedule_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['environment_id'], ['public.environments.id'], name='test_jobs_environment_id_fkey'),
              ForeignKeyConstraint(['schedule_id'], ['public.schedule.id'], name='test_jobs_schedule_id_fkey'),
              ForeignKeyConstraint(['testsuite_id'], ['public.test_suites.id'], name='test_jobs_testsuite_id_fkey'),
              ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='test_jobs_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_test_jobs_user_id', test_jobs.c.user_id, unique=False)
  Index('index_test_jobs_testsuite_id', test_jobs.c.testsuite_id, unique=False)
  Index('index_test_jobs_name', test_jobs.c.name, unique=False)
  Index('index_test_jobs_schedule_id', test_jobs.c.schedule_id, unique=False)
  Index('index_test_jobs_environment_id', test_jobs.c.environment_id, unique=False)
  Index('index_test_jobs_name_key', test_jobs.c.name, test_jobs.c.user_id, unique=True)
  
  
  schedule =  Table('schedule', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('user_id', INTEGER(), primary_key=False),
              Column('minute', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('hour', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('day_of_month', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('month', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('day_of_week', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='schedule_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_schedule_user_id', schedule.c.user_id, unique=False)
  
  
  test_results_data =  Table('test_results_data', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('data', JsonText(), primary_key=False, nullable=False),
              Column('note', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('test_results_id', INTEGER(), primary_key=False),
          ForeignKeyConstraint(['test_results_id'], ['public.test_results.id'], name='test_results_data_test_results_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_test_results_data_pkey', test_results_data.c.id, unique=True)
  Index('fki_test_results_data_test_results_fkey', test_results_data.c.test_results_id, unique=True)
  
  
  test_results =  Table('test_results', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('testcase_id', INTEGER(), primary_key=False),
              Column('testimplementation', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('testversion', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('tester_id', INTEGER(), primary_key=False),
              Column('environment_id', INTEGER(), primary_key=False),
              Column('build_id', INTEGER(), primary_key=False),
              Column('parent_id', INTEGER(), primary_key=False),
              Column('objecttype', TestObjectType(), primary_key=False, nullable=False),
              Column('starttime', TIMESTAMP(timezone=True), primary_key=False),
              Column('endtime', TIMESTAMP(timezone=True), primary_key=False),
              Column('arguments', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('result', TestResultType(), primary_key=False, nullable=False),
              Column('diagnostic', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('resultslocation', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('reportfilename', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('note', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('valid', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
              Column('testsuite_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['tester_id'], ['public.auth_user.id'], name='test_results_tester_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['parent_id'], ['public.test_results.id'], name='parent_id_refs_test_results_id'),
              ForeignKeyConstraint(['build_id'], ['public.project_versions.id'], name='test_results_build_id_fkey'),
              ForeignKeyConstraint(['environment_id'], ['public.environments.id'], name='test_results_environment_id_fkey'),
              ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'], name='test_results_testcase_id_fkey'),
              ForeignKeyConstraint(['testsuite_id'], ['public.test_suites.id'], name='test_results_testsuite_id_fkey'),
      schema='public')
  Index('index_test_results_testcase_id', test_results.c.testcase_id, unique=False)
  Index('index_test_results_build_id', test_results.c.build_id, unique=False)
  Index('index_test_results_parent_id', test_results.c.parent_id, unique=False)
  Index('index_test_results_tester_id', test_results.c.tester_id, unique=False)
  Index('index_test_results_testimplementation', test_results.c.testimplementation, unique=False)
  Index('index_test_results_environment_id', test_results.c.environment_id, unique=False)
  Index('index_test_results_testsuite_id', test_results.c.testsuite_id, unique=False)
  
  
  traps =  Table('traps', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('timestamp', TIMESTAMP(timezone=True), primary_key=False, nullable=False,
                      default=time_now),
              Column('trap', PickleText(), primary_key=False, nullable=False),
      schema='public')
  Index('index_traps_pkey', traps.c.id, unique=True)
  
  
  cookies =  Table('cookies', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('value', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=False),
              Column('comment', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('domain', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('max_age', INTEGER(), primary_key=False),
              Column('path', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('version', INTEGER(), primary_key=False, nullable=False),
              Column('secure', BOOLEAN(), primary_key=False),
              Column('expires', TIMESTAMP(timezone=True), primary_key=False),
              Column('discard', BOOLEAN(), primary_key=False),
              Column('comment_url', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('port', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('user_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='cookies_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_cookies_user_id', cookies.c.user_id, unique=False)
  
  
  auth_group_permissions =  Table('auth_group_permissions', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('group_id', INTEGER(), primary_key=False, nullable=False),
              Column('permission_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['group_id'], ['public.auth_group.id'], name='auth_group_permissions_group_id_fkey'),
              ForeignKeyConstraint(['permission_id'], ['public.auth_permission.id'], name='auth_group_permissions_permission_id_fkey'),
      schema='public')
  Index('index_auth_group_permissions_group_id_key', auth_group_permissions.c.group_id, auth_group_permissions.c.permission_id, unique=True)
  
  
  auth_user_groups =  Table('auth_user_groups', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('user_id', INTEGER(), primary_key=False, nullable=False),
              Column('group_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['group_id'], ['public.auth_group.id'], name='auth_user_groups_group_id_fkey'),
              ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='auth_user_groups_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_auth_user_groups_user_id_key', auth_user_groups.c.user_id, auth_user_groups.c.group_id, unique=True)
  
  
  auth_group =  Table('auth_group', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_auth_group_name_key', auth_group.c.name, unique=True)
  
  
  auth_permission =  Table('auth_permission', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=50, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  
  
  auth_user_user_permissions =  Table('auth_user_user_permissions', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('user_id', INTEGER(), primary_key=False, nullable=False),
              Column('permission_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['permission_id'], ['public.auth_permission.id'], name='auth_user_user_permissions_permission_id_fkey'),
              ForeignKeyConstraint(['user_id'], ['public.auth_user.id'], name='auth_user_user_permissions_user_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  Index('index_auth_user_user_permissions_user_id_key', auth_user_user_permissions.c.user_id, auth_user_user_permissions.c.permission_id, unique=True)
  
  
  auth_user =  Table('auth_user', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('username', VARCHAR(length=30, convert_unicode=False), primary_key=False, nullable=False),
              Column('first_name', VARCHAR(length=30, convert_unicode=False), primary_key=False, nullable=False),
              Column('middle_name', VARCHAR(length=30, convert_unicode=False), primary_key=False),
              Column('last_name', VARCHAR(length=30, convert_unicode=False), primary_key=False, nullable=False),
              Column('email', VARCHAR(length=75, convert_unicode=False), primary_key=False),
              Column('is_staff', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
              Column('is_active', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
              Column('is_superuser', BOOLEAN(), primary_key=False, nullable=False, default=default_inactive),
              Column('last_login', TIMESTAMP(timezone=True), primary_key=False, nullable=False,
                      onupdate=time_now, default=time_now),
              Column('date_joined', TIMESTAMP(timezone=True), primary_key=False, nullable=False, default=time_now),
              Column('password', VARCHAR(length=40, convert_unicode=False), primary_key=False),
              Column('authservice', VARCHAR(length=20, convert_unicode=False), primary_key=False, nullable=False),
              Column('address_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['address_id'], ['public.addresses.id'], name='auth_user_address_id_fkey'),
      schema='public')
  Index('index_auth_user_username_key', auth_user.c.username, unique=True)
  
  
  components_suites =  Table('components_suites', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('component_id', INTEGER(), primary_key=False, nullable=False),
              Column('testsuite_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['component_id'], ['public.components.id'], name='components_suites_component_id_fkey'),
              ForeignKeyConstraint(['testsuite_id'], ['public.test_suites.id'], name='components_suites_testsuite_id_fkey'),
      schema='public')
  Index('index_components_suites_component_id_key', components_suites.c.component_id, components_suites.c.testsuite_id, unique=True)
  
  
  projects =  Table('projects', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('category_id', INTEGER(), primary_key=False),
              Column('leader_id', INTEGER(), primary_key=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=False),
              Column('created', TIMESTAMP(timezone=True), primary_key=False, nullable=False, default=time_now),
      ForeignKeyConstraint(['category_id'], ['public.project_category.id'], name='projects_category_id_fkey'),
              ForeignKeyConstraint(['leader_id'], ['public.contacts.id'], name='projects_leader_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_projects_name_key', projects.c.name, unique=True)
  Index('index_projects_leader_id', projects.c.leader_id, unique=False)
  Index('index_projects_category_id', projects.c.category_id, unique=False)
  
  
  projects_components =  Table('projects_components', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('project_id', INTEGER(), primary_key=False, nullable=False),
              Column('component_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['component_id'], ['public.components.id'], name='projects_components_component_id_fkey'),
              ForeignKeyConstraint(['project_id'], ['public.projects.id'], name='projects_components_project_id_fkey'),
      schema='public')
  Index('index_projects_components_project_id_key', projects_components.c.project_id, projects_components.c.component_id, unique=True)
  
  
  components =  Table('components', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False, nullable=False),
              Column('created', TIMESTAMP(timezone=True), primary_key=False, nullable=False, default=time_now),
      schema='public')
  Index('index_components_name_key', components.c.name, unique=True)
  
  
  test_cases_areas =  Table('test_cases_areas', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('testcase_id', INTEGER(), primary_key=False, nullable=False),
              Column('functionalarea_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['functionalarea_id'], ['public.functional_area.id'], name='test_cases_areas_functionalarea_id_fkey'),
              ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'], name='test_cases_areas_testcase_id_fkey'),
      schema='public')
  Index('index_test_cases_areas_testcase_id_key', test_cases_areas.c.testcase_id, test_cases_areas.c.functionalarea_id, unique=True)
  
  
  test_cases =  Table('test_cases', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('lastchange', TIMESTAMP(timezone=True), primary_key=False, nullable=False,
                      onupdate=time_now, default=time_now),
              Column('lastchangeauthor_id', INTEGER(), primary_key=False),
              Column('author_id', INTEGER(), primary_key=False),
              Column('reviewer_id', INTEGER(), primary_key=False),
              Column('tester_id', INTEGER(), primary_key=False),
              Column('purpose', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('passcriteria', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('startcondition', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('endcondition', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('procedure', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('comments', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('priority', PriorityType(), primary_key=False, nullable=False, default=PriorityType.get_default),
              Column('cycle', TestCaseType(), primary_key=False, nullable=False, default=TestCaseType.get_default),
              Column('status', TestCaseStatus(), primary_key=False, nullable=False, default=TestCaseStatus.get_default),
              Column('automated', BOOLEAN(), primary_key=False, nullable=False, default=default_inactive),
              Column('interactive', BOOLEAN(), primary_key=False, nullable=False, default=default_inactive),
              Column('valid', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
              Column('testimplementation', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('bugid', VARCHAR(length=80, convert_unicode=False), primary_key=False),
              Column('reference_id', INTEGER(), primary_key=False),
              Column('time_estimate', INTERVAL(), primary_key=False), # for manual tests
      ForeignKeyConstraint(['author_id'], ['public.auth_user.id'], name='test_cases_author_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['reviewer_id'], ['public.auth_user.id'], name='test_cases_reviewer_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['tester_id'], ['public.auth_user.id'], name='test_cases_tester_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['lastchangeauthor_id'], ['public.auth_user.id'], name='test_cases_lastchangeauthor_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['reference_id'], ['public.requirement_ref.id'], name='test_cases_requirement_ref_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_test_cases_lastchangeauthor_id', test_cases.c.lastchangeauthor_id, unique=False)
  Index('index_test_cases_reviewer_id', test_cases.c.reviewer_id, unique=False)
  Index('index_test_cases_testimplementation', test_cases.c.testimplementation, unique=False)
  Index('index_test_cases_author_id', test_cases.c.author_id, unique=False)
  Index('index_test_cases_name_key', test_cases.c.name, unique=True)
  Index('index_test_cases_tester_id', test_cases.c.tester_id, unique=False)
  Index('index_test_cases_requirement_ref_id', test_cases.c.reference_id, unique=False)
  
  test_cases_prerequisites = Table('test_cases_prerequisites', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('testcase_id', INTEGER(), primary_key=False, nullable=False),
              Column('prerequisite_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'], name='test_cases_testcase_id_fkey'),
              ForeignKeyConstraint(['prerequisite_id'], ['public.test_cases.id'],
                      name='test_cases_relation_prerequisite_id_fkey'),
      schema='public')
  Index('index_test_cases_test_cases_id_key',
          test_cases_prerequisites.c.testcase_id, test_cases_prerequisites.c.prerequisite_id, unique=True)
  
  
  test_suites =  Table('test_suites', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('valid', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
              Column('lastchange', TIMESTAMP(timezone=True), primary_key=False, nullable=False,
                      onupdate=time_now, default=time_now),
              Column('lastchangeauthor_id', INTEGER(), primary_key=False),
              Column('suiteimplementation', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('project_id', INTEGER(), primary_key=False),
              Column('purpose', TEXT(length=None, convert_unicode=False), primary_key=False),
      ForeignKeyConstraint(['lastchangeauthor_id'], ['public.auth_user.id'], name='test_suites_lastchangeauthor_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['project_id'], ['public.projects.id'], name='test_suites_projects_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_test_suites_lastchangeauthor_id', test_suites.c.lastchangeauthor_id, unique=False)
  Index('index_test_suites_name_key', test_suites.c.name, unique=True)
  Index('index_test_suites_project_id', test_suites.c.project_id, unique=False)
  Index('index_test_suites_suiteimplementation', test_suites.c.suiteimplementation, unique=False)
  
  
  test_suites_testcases =  Table('test_suites_testcases', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('testsuite_id', INTEGER(), primary_key=False, nullable=False),
              Column('testcase_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'], name='test_suites_testcases_testcase_id_fkey'),
              ForeignKeyConstraint(['testsuite_id'], ['public.test_suites.id'], name='test_suites_testcases_testsuite_id_fkey'),
      schema='public')
  Index('index_test_suites_testcases_testsuite_id_key', test_suites_testcases.c.testsuite_id, test_suites_testcases.c.testcase_id, unique=True)
  
  
  use_cases =  Table('use_cases', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False), # full path
              Column('purpose', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('notes', TEXT(length=None, convert_unicode=False), primary_key=False),
      schema='public')
  Index('index_use_case_name', use_cases.c.name, unique=True)
  
  # risk managmnet schema
  risk_factors =  Table('risk_factors', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('description', TEXT(convert_unicode=False), primary_key=False),
              Column('priority', PriorityType(), primary_key=False, nullable=False, default=PriorityType.get_default),
              Column('likelihood', LikelihoodType(), primary_key=False, nullable=False, default=LikelihoodType.get_default),
              Column('severity', SeverityType(), primary_key=False, nullable=False, default=SeverityType.get_default),
              Column('testcase_id', INTEGER(), primary_key=False),
              Column('requirement_id', INTEGER(), primary_key=False),
              Column('risk_category_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['testcase_id'], ['public.test_cases.id'],
              name='risk_factors_testcase_id_fkey', ondelete="SET NULL"),
      ForeignKeyConstraint(['requirement_id'], ['public.requirement_ref.id'],
              name='risk_factors_requirement_id_fkey', ondelete="SET NULL"),
      ForeignKeyConstraint(['risk_category_id'], ['public.risk_category.id'],
              name='risk_factors_risk_category_id_fkey'),
      schema='public')
  Index('index_risk_factors_testcase_id', risk_factors.c.testcase_id, unique=False)
  Index('index_risk_factors_requirement_ref_id', risk_factors.c.requirement_id, unique=False)
  Index('index_risk_factors_risk_category_id', risk_factors.c.risk_category_id, unique=False)
  
  risk_category =  Table('risk_category', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
      Column('name', VARCHAR(length=80, convert_unicode=False), nullable=False),
              Column('description', TEXT(convert_unicode=False), primary_key=False),
      schema='public')
  Index('index_risk_category_name_key', risk_category.c.name, unique=True)
  
  requirement_ref =  Table('requirement_ref', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('uri', VARCHAR(length=255), primary_key=False),
              Column('description', TEXT(convert_unicode=False), primary_key=False),
      schema='public')
  
  country_codes =  Table('country_codes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('isocode', VARCHAR(length=4, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_country_codes_isocode_key', country_codes.c.isocode, unique=True)
  
  
  test_suites_suites =  Table('test_suites_suites', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('from_testsuite_id', INTEGER(), primary_key=False, nullable=False),
              Column('to_testsuite_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['from_testsuite_id'], ['public.test_suites.id'], name='test_suites_suites_from_testsuite_id_fkey'),
              ForeignKeyConstraint(['to_testsuite_id'], ['public.test_suites.id'], name='test_suites_suites_to_testsuite_id_fkey'),
      schema='public')
  Index('index_test_suites_suites_from_testsuite_id_key', test_suites_suites.c.from_testsuite_id, test_suites_suites.c.to_testsuite_id, unique=True)
  
  
  country_sets =  Table('country_sets', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_country_sets_name_key', country_sets.c.name, unique=True)
  
  
  country_sets_countries =  Table('country_sets_countries', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('countryset_id', INTEGER(), primary_key=False, nullable=False),
              Column('country_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['country_id'], ['public.country_codes.id'], name='country_sets_countries_country_id_fkey'),
              ForeignKeyConstraint(['countryset_id'], ['public.country_sets.id'], name='country_sets_countries_countryset_id_fkey'),
      schema='public')
  Index('index_country_sets_countries_countryset_id_key', country_sets_countries.c.countryset_id, country_sets_countries.c.country_id, unique=True)
  
  
  language_sets =  Table('language_sets', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_language_sets_name_key', language_sets.c.name, unique=True)
  
  
  language_sets_languages =  Table('language_sets_languages', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('languageset_id', INTEGER(), primary_key=False, nullable=False),
              Column('language_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['language_id'], ['public.language_codes.id'], name='language_sets_languages_language_id_fkey'),
              ForeignKeyConstraint(['languageset_id'], ['public.language_sets.id'], name='language_sets_languages_languageset_id_fkey'),
      schema='public')
  Index('index_language_sets_languages_languageset_id_key', language_sets_languages.c.languageset_id, language_sets_languages.c.language_id, unique=True)
  
  
  corporations_services =  Table('corporations_services', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('corporation_id', INTEGER(), primary_key=False, nullable=False),
              Column('functionalarea_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['corporation_id'], ['public.corporations.id'], name='corporations_services_corporation_id_fkey'),
              ForeignKeyConstraint(['functionalarea_id'], ['public.functional_area.id'], name='corporations_services_functionalarea_id_fkey'),
      schema='public')
  Index('index_corporations_services_corporation_id_key', corporations_services.c.corporation_id, corporations_services.c.functionalarea_id, unique=True)
  
  
  functional_area =  Table('functional_area', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', VARCHAR(length=255, convert_unicode=False), primary_key=False),
      schema='public')
  Index('index_functional_area_name_key', functional_area.c.name, unique=True)
  
  
  software_variants =  Table('software_variants', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('software_id', INTEGER(), primary_key=False, nullable=False),
              Column('softwarevariant_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['software_id'], ['public.software.id'], name='software_variants_software_id_fkey'),
              ForeignKeyConstraint(['softwarevariant_id'], ['public.software_variant.id'], name='software_variants_softwarevariant_id_fkey'),
      schema='public')
  Index('index_software_variants_software_id_key', software_variants.c.software_id, software_variants.c.softwarevariant_id, unique=True)
  
  
  software_variant =  Table('software_variant', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('language_id', INTEGER(), primary_key=False),
              Column('country_id', INTEGER(), primary_key=False),
              Column('encoding', VARCHAR(length=80, convert_unicode=False), primary_key=False),
      ForeignKeyConstraint(['country_id'], ['public.country_codes.id'], name='software_variant_country_id_fkey'),
              ForeignKeyConstraint(['language_id'], ['public.language_codes.id'], name='software_variant_language_id_fkey'),
      schema='public')
  Index('index_software_variant_name_key', software_variant.c.name, unique=True)
  Index('index_software_variant_language_id', software_variant.c.language_id, unique=False)
  Index('index_software_variant_country_id', software_variant.c.country_id, unique=False)
  
  
  language_codes =  Table('language_codes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('isocode', VARCHAR(length=6, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_language_codes_isocode_key', language_codes.c.isocode, unique=True)
  Index('index_language_codes_name_key', language_codes.c.name, unique=True)
  
  
  networks = Table('networks', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=64, convert_unicode=False), primary_key=False, nullable=False),
              Column('layer', INTEGER(), primary_key=False, nullable=False, server_default="1"),
              Column('vlanid', INTEGER(), primary_key=False),
              Column('ipnetwork', Cidr(), primary_key=False),
              Column('lower_id', INTEGER(), primary_key=False),
              Column('notes', TEXT(length=None, convert_unicode=False), primary_key=False),
      ForeignKeyConstraint(['lower_id'], ['public.networks.id'], name='lower_id_refs_networks_id',
                      ondelete="SET NULL"),
      CheckConstraint('layer > 0 AND  layer < 8', name='osilayers'),
              CheckConstraint('vlanid > 0 AND  vlanid < 4094', name='vlanrange'),
      schema='public')
  
  
  equipment = Table('equipment', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('model_id', INTEGER(), primary_key=False, nullable=False),
              Column('serno', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('location_id', INTEGER(), primary_key=False),
              Column('sublocation', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('addeddate', TIMESTAMP(timezone=True), primary_key=False, default=time_now),
              Column('comments', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('language_id', INTEGER(), primary_key=False),
              Column('owner_id', INTEGER(), primary_key=False),
              Column('vendor_id', INTEGER(), primary_key=False),
              Column('account_id', INTEGER(), primary_key=False),
              Column('parent_id', INTEGER(), primary_key=False),
              Column('active', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
      ForeignKeyConstraint(['language_id'], ['public.language_codes.id'], name='equipment_language_id_fkey'),
              ForeignKeyConstraint(['model_id'], ['public.equipment_model.id'], name='equipment_model_id_fkey'),
              ForeignKeyConstraint(['vendor_id'], ['public.corporations.id'], name='equipment_vendor_id_fkey'),
              ForeignKeyConstraint(['owner_id'], ['public.auth_user.id'], name='equipment_owner_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
              ForeignKeyConstraint(['location_id'], ['public.location.id'], name='equipment_location_id_fkey'),
              ForeignKeyConstraint(['account_id'], ['public.account_ids.id'], name='equipment_account_id_fkey'),
              ForeignKeyConstraint(['parent_id'], ['public.equipment.id'], name='parent_id_refs_equipment_id'),
      schema='public')
  
  Index('index_equipment_model_id', equipment.c.model_id, unique=False)
  Index('index_equipment_language_id', equipment.c.language_id, unique=False)
  Index('index_equipment_owner_id', equipment.c.owner_id, unique=False)
  Index('index_equipment_vendor_id', equipment.c.vendor_id, unique=False)
  Index('index_equipment_location_id', equipment.c.location_id, unique=False)
  Index('index_equipment_account_id', equipment.c.account_id, unique=False)
  Index('index_equipment_parent_id', equipment.c.parent_id, unique=False)
  
  # IANAifType
  interface_type =  Table('interface_type', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=40, convert_unicode=False), primary_key=False, nullable=False),
              Column('enumeration', INTEGER(), primary_key=False),
      schema='public')
  
  interfaces =  Table('interfaces', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=64, convert_unicode=False), primary_key=False, nullable=False),
              Column('alias', VARCHAR(length=64, convert_unicode=False)),
              Column('ifindex', INTEGER(), primary_key=False),
              Column('description', TEXT(convert_unicode=False), primary_key=False),
              Column('macaddr', MACADDR(), primary_key=False),
              Column('vlan', INTEGER(), primary_key=False),
              Column('ipaddr', Inet(), primary_key=False),
              Column('mtu', INTEGER(), primary_key=False),
              Column('speed', INTEGER(), primary_key=False),
              Column('status', INTEGER(), primary_key=False),
              Column('interface_type_id', INTEGER(), primary_key=False),
              Column('parent_id', INTEGER(), primary_key=False),
              Column('equipment_id', INTEGER(), primary_key=False),
              Column('network_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['equipment_id'], ['public.equipment.id'], name='interfaces_equipment_id_fkey'),
              ForeignKeyConstraint(['parent_id'], ['public.interfaces.id'], name='parent_id_refs_interfaces_id'),
              ForeignKeyConstraint(['interface_type_id'], ['public.interface_type.id'], name='interface_type_id_refs_interfaces_id'),
              ForeignKeyConstraint(['network_id'], ['public.networks.id'], name='network_id_refs_networks_id'),
      schema='public')
  Index('index_interfaces_parent_id', interfaces.c.parent_id, unique=False)
  Index('index_interfaces_equipment_id', interfaces.c.equipment_id, unique=False)
  Index('index_interfaces_interface_type_id', interfaces.c.interface_type_id, unique=False)
  Index('index_interfaces_network_id', interfaces.c.network_id, unique=False)
  
  equipment_attributes =  Table('equipment_attributes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('equipment_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['equipment_id'], ['public.equipment.id'], name='equipment_attributes_equipment_id_fkey'),
              ForeignKeyConstraint(['type_id'], ['public.attribute_type.id'], name='equipment_attributes_type_id_fkey'),
      UniqueConstraint("type_id", "equipment_id"),
      schema='public')
  Index('index_equipment_attributes_type_id', equipment_attributes.c.type_id, unique=False)
  Index('index_equipment_attributes_equipment_id', equipment_attributes.c.equipment_id, unique=False)
  
  
  equipment_model_attributes =  Table('equipment_model_attributes', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('type_id', INTEGER(), primary_key=False, nullable=False),
              Column('value', PickleText(), primary_key=False, nullable=False),
              Column('equipmentmodel_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['equipmentmodel_id'], ['public.equipment_model.id'], name='equipment_model_attributes_equipmentmodel_id_fkey'),
              ForeignKeyConstraint(['type_id'], ['public.attribute_type.id'], name='equipment_model_attributes_type_id_fkey'),
      UniqueConstraint("type_id", "equipmentmodel_id"),
      schema='public')
  Index('index_equipment_model_attributes_type_id', equipment_model_attributes.c.type_id, unique=False)
  Index('index_equipment_model_attributes_equipmentmodel_id', equipment_model_attributes.c.equipmentmodel_id, unique=False)
  
  
  equipment_subcomponents =  Table('equipment_subcomponents', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('from_equipment_id', INTEGER(), primary_key=False, nullable=False),
              Column('to_equipment_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['from_equipment_id'], ['public.equipment.id'], name='equipment_subcomponents_from_equipment_id_fkey'),
              ForeignKeyConstraint(['to_equipment_id'], ['public.equipment.id'], name='equipment_subcomponents_to_equipment_id_fkey'),
      schema='public')
  Index('index_equipment_subcomponents_from_equipment_id_key', equipment_subcomponents.c.from_equipment_id, equipment_subcomponents.c.to_equipment_id, unique=True)
  
  
  equipment_software =  Table('equipment_software', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('equipment_id', INTEGER(), primary_key=False, nullable=False),
              Column('software_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['equipment_id'], ['public.equipment.id'], name='equipment_software_equipment_id_fkey'),
              ForeignKeyConstraint(['software_id'], ['public.software.id'], name='equipment_software_software_id_fkey'),
      schema='public')
  Index('index_equipment_software_equipment_id_key', equipment_software.c.equipment_id, equipment_software.c.software_id, unique=True)
  
  
  equipment_category =  Table('equipment_category', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
      schema='public')
  Index('index_equipment_category_name_key', equipment_category.c.name, unique=True)
  
  
  equipment_model =  Table('equipment_model', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('manufacturer_id', INTEGER(), primary_key=False, nullable=False),
              Column('category_id', INTEGER(), primary_key=False, nullable=False),
              Column('specs', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('picture', VARCHAR(length=255, convert_unicode=False), primary_key=False),
              Column('note', TEXT(length=None, convert_unicode=False), primary_key=False),
      ForeignKeyConstraint(['category_id'], ['public.equipment_category.id'], name='equipment_model_category_id_fkey'),
              ForeignKeyConstraint(['manufacturer_id'], ['public.corporations.id'], name='equipment_model_manufacturer_id_fkey'),
      schema='public')
  Index('index_equipment_model_category_id', equipment_model.c.category_id, unique=False)
  Index('index_equipment_model_manufacturer_id', equipment_model.c.manufacturer_id, unique=False)
  Index('index_equipment_model_manufacturer_id_key', equipment_model.c.manufacturer_id, equipment_model.c.name, unique=True)
  
  
  equipment_model_embeddedsoftware =  Table('equipment_model_embeddedsoftware', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('equipmentmodel_id', INTEGER(), primary_key=False, nullable=False),
              Column('software_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['equipmentmodel_id'], ['public.equipment_model.id'], name='equipment_model_embeddedsoftware_equipmentmodel_id_fkey'),
              ForeignKeyConstraint(['software_id'], ['public.software.id'], name='equipment_model_embeddedsoftware_software_id_fkey'),
      schema='public')
  Index('index_equipment_model_embeddedsoftware_equipmentmodel_id_key', equipment_model_embeddedsoftware.c.equipmentmodel_id, equipment_model_embeddedsoftware.c.software_id, unique=True)
  
  
  software =  Table('software', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('manufacturer_id', INTEGER(), primary_key=False),
              Column('vendor_id', INTEGER(), primary_key=False),
              Column('category_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['category_id'], ['public.software_category.id'], name='software_category_id_fkey'),
              ForeignKeyConstraint(['vendor_id'], ['public.corporations.id'], name='software_vendor_id_fkey'),
              ForeignKeyConstraint(['manufacturer_id'], ['public.corporations.id'], name='software_manufacturer_id_fkey'),
      schema='public')
  Index('index_software_manufacturer_id', software.c.manufacturer_id, unique=False)
  Index('index_software_name_key', software.c.name, unique=True)
  Index('index_software_vendor_id', software.c.vendor_id, unique=False)
  Index('index_software_category_id', software.c.category_id, unique=False)
  
  
  project_versions =  Table('project_versions', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('project_id', INTEGER(), primary_key=False, nullable=False),
              Column('major', INTEGER(), primary_key=False, nullable=False, default=default_obj(1)),
              Column('minor', INTEGER(), primary_key=False, nullable=False, default=default_obj(0)),
              Column('subminor', INTEGER(), primary_key=False, nullable=False, default=default_obj(0)),
              Column('build', INTEGER(), primary_key=False),
              Column('valid', BOOLEAN(), primary_key=False, nullable=False, default=default_active),
      ForeignKeyConstraint(['project_id'], ['public.projects.id'],
              name='project_versions_project_id_fkey'),
      UniqueConstraint("project_id", "major", "minor", "subminor", "build",
              name="project_versions_unique"),
      schema='public')
  Index('index_project_versions_project_id', project_versions.c.project_id, unique=False)
  
  
  corporations =  Table('corporations', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('parent_id', INTEGER(), primary_key=False),
              Column('notes', TEXT(length=None, convert_unicode=False), primary_key=False),
              Column('address_id', INTEGER(), primary_key=False),
              Column('contact_id', INTEGER(), primary_key=False),
              Column('country_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['contact_id'], ['public.contacts.id'], name='contact_id_refs_contacts_id'),
              ForeignKeyConstraint(['parent_id'], ['public.corporations.id'], name='parent_id_refs_corporations_id'),
              ForeignKeyConstraint(['country_id'], ['public.country_codes.id'], name='corporations_country_id_fkey'),
              ForeignKeyConstraint(['address_id'], ['public.addresses.id'], name='corporations_address_id_fkey'),
      schema='public')
  Index('index_corporations_parent_id', corporations.c.parent_id, unique=False)
  Index('index_corporations_name', corporations.c.name, unique=False)
  Index('index_corporations_country_id', corporations.c.country_id, unique=False)
  Index('index_corporations_contact_id', corporations.c.contact_id, unique=False)
  Index('index_corporations_address_id', corporations.c.address_id, unique=False)
  Index('index_corporations_name_key', corporations.c.name, corporations.c.country_id, unique=True)
  
  
  environments =  Table('environments', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=255, convert_unicode=False), primary_key=False, nullable=False),
              Column('owner_id', INTEGER(), primary_key=False),
      ForeignKeyConstraint(['owner_id'], ['public.auth_user.id'], name='environments_owner_id_fkey',
                      onupdate="CASCADE", ondelete="SET NULL"),
      schema='public')
  Index('index_environments_name_key', environments.c.name, unique=True)
  Index('index_environments_owner_id', environments.c.owner_id, unique=False)
  
  
  testequipment =  Table('testequipment', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('equipment_id', INTEGER(), primary_key=False, nullable=False),
              Column('environment_id', INTEGER(), primary_key=False, nullable=False),
              Column('UUT', BOOLEAN(), primary_key=False, nullable=False, default=default_inactive),
      ForeignKeyConstraint(['environment_id'], ['public.environments.id'], name='testequipment_environment_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
              ForeignKeyConstraint(['equipment_id'], ['public.equipment.id'], name='testequipment_equipment_id_fkey',
                      onupdate="CASCADE", ondelete="CASCADE"),
      schema='public')
  
  Index('index_testequipment_equipment_id', testequipment.c.equipment_id, unique=False)
  Index('index_testequipment_environment_id', testequipment.c.environment_id, unique=False)
  
  
  testequipment_roles =  Table('testequipment_roles', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('testequipment_id', INTEGER(), primary_key=False, nullable=False),
              Column('softwarecategory_id', INTEGER(), primary_key=False, nullable=False),
      ForeignKeyConstraint(['softwarecategory_id'], ['public.software_category.id'], name='testequipment_roles_softwarecategory_id_fkey'),
              ForeignKeyConstraint(['testequipment_id'], ['public.testequipment.id'], name='testequipment_roles_testequipment_id_fkey'),
      schema='public')
  Index('index_testequipment_roles_testequipment_id_key', testequipment_roles.c.testequipment_id, testequipment_roles.c.softwarecategory_id, unique=True)
  
  
  software_category =  Table('software_category', metadata,
      Column('id', INTEGER(), primary_key=True, nullable=False),
              Column('name', VARCHAR(length=80, convert_unicode=False), primary_key=False, nullable=False),
              Column('description', TEXT(length=None, convert_unicode=False), primary_key=False),
      schema='public')
  Index('index_software_category_name_key', software_category.c.name, unique=True)
  
  
  # Run this module to create the tables. The user/role/database should
  # already be created.
  if __name__ == '__main__':
      import sys
      from pycopia import autodebug
      from pycopia import getopt
      from sqlalchemy import create_engine
  
      tname = None
      opts, longopts, args = getopt.getopt(sys.argv[1:], "")
      try:
          url = args[0]
      except IndexError:
          print ("Please supply a database URL.")
          print ("e.g: postgresql://pycopia@localhost/pycopia")
      else:
          db = create_engine(unicode(url))
          metadata.bind = db
          if len(args) > 1:
              for tname in args[1:]:
                  tbl = getattr(sys.modules[__name__], tname)
                  print (tbl)
                  tbl.drop(checkfirst=True)
                  tbl.create()
          else:
              print ("creating tables in", url)
              metadata.create_all()
  
  
  