From c3cffbeaa7b5a156f820d382d4513c88e5242b51 Mon Sep 17 00:00:00 2001 From: fedjo Date: Fri, 22 May 2020 18:43:01 +0200 Subject: [PATCH] Add callable to get inventory from command line --- README.rst | 56 +- ereuse_devicehub/devicehub.py | 6 - ereuse_devicehub/migrations/script.py.mako | 6 + .../versions/fbb7e2a0cde0_initial.py | 587 +++++++++--------- 4 files changed, 338 insertions(+), 317 deletions(-) diff --git a/README.rst b/README.rst index 7ad71f97..44c82b66 100644 --- a/README.rst +++ b/README.rst @@ -89,57 +89,59 @@ Testing Migrations ********** -At this stage, migration files are created manually. To apply the migrations we follow -a hybrid approach. - -* When a schema is to be created in the db we create a revision file holding **all** the -necessary table definitions. For example have a look on the migration file holding the initial -declarations. There you see a full list of tables to be created. You just need to specify -the env variable **dhi**. To create a revision file execute: +At this stage, migration files are created manually. +Set up the database: .. code:: bash - $ alembic revision -m "My initial base revision" + $ sudo su - postgres + $ bash $PATH_TO_DEVIHUBTEAL/examples/create-db.sh devicehub dhub -Then run +Initialize the database: .. code:: bash $ export dhi=dbtest; dh inv add --common --name dbtest -This command will create the schemas, tables in the specified database and will stamp the -migration file you have created as the base schema for future migrations. For more info -in migration stamping please see https://alembic.sqlalchemy.org/en/latest/cookbook.html - -Whenever you want to create a new schema just create a new revision with: +This command will create the schemas, tables in the specified database. +Then we need to stamp the initial migration. .. code:: bash - $ alembic revision -m "My new base revision" - -and add there **all** the tables that the new database will have. Next, you can add the -new inventory and stamp the revision as the new base. - -.. code:: bash - - $ export dhi=dbtest2; dh inv add --name dbtest2 + $ alembic stamp head -* When you want to alter a table, column or perform another operation on tables, create - a revision file +This command will set the revision **fbb7e2a0cde0_initial** as our initial migration. +For more info in migration stamping please see https://alembic.sqlalchemy.org/en/latest/cookbook.html + + +Whenever a change needed eg to create a new schema, alter an existing table, column or perform any +operation on tables, create a new revision file: .. code:: bash $ alembic revision -m "A table change" -Then edit the generated file with the necessary operations to perform the migration. +This command will create a new revision file with name `_a_table_change`. +Edit the generated file with the necessary operations to perform the migration: + +.. code:: bash + + $ alembic edit + Apply migrations using: .. code:: bash - $ alembic upgrade head + $ alembic -x inventory=dbtest upgrade head -* Whenever you to see a full list of migrations use +Then to go back to previous db version: + +.. code:: bash + + $ alembic -x inventory=dbtest downgrade + +To see a full list of migrations use .. code:: bash diff --git a/ereuse_devicehub/devicehub.py b/ereuse_devicehub/devicehub.py index d6ac4fca..4316f3ef 100644 --- a/ereuse_devicehub/devicehub.py +++ b/ereuse_devicehub/devicehub.py @@ -124,12 +124,6 @@ class Devicehub(Teal): else: self.db.create_all() - from alembic.config import Config - from alembic import command - - alembic_cfg = Config('alembic.ini') - command.stamp(alembic_cfg, "head") - return True @click.confirmation_option(prompt='Are you sure you want to delete the inventory {}?' diff --git a/ereuse_devicehub/migrations/script.py.mako b/ereuse_devicehub/migrations/script.py.mako index a1aa6cda..3fbbfa7f 100644 --- a/ereuse_devicehub/migrations/script.py.mako +++ b/ereuse_devicehub/migrations/script.py.mako @@ -19,6 +19,12 @@ branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + def upgrade(): ${upgrades if upgrades else "pass"} diff --git a/ereuse_devicehub/migrations/versions/fbb7e2a0cde0_initial.py b/ereuse_devicehub/migrations/versions/fbb7e2a0cde0_initial.py index b5fba5bd..334fb1b6 100644 --- a/ereuse_devicehub/migrations/versions/fbb7e2a0cde0_initial.py +++ b/ereuse_devicehub/migrations/versions/fbb7e2a0cde0_initial.py @@ -7,6 +7,7 @@ Create Date: 2020-05-07 10:04:40.269511 """ import os from alembic import op +from alembic import context import sqlalchemy as sa from sqlalchemy.dialects import postgresql import sqlalchemy_utils @@ -21,13 +22,17 @@ down_revision = None branch_labels = None depends_on = None -INV = os.environ.get('dhi', 'dbtest') +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### # Create Common schema op.execute("create schema common") - op.execute(f"create schema {INV}") + op.execute(f"create schema {get_inv()}") # Inventory table op.create_table('inventory', @@ -113,12 +118,12 @@ def upgrade(): sa.Column('wheel_size', sa.SmallInteger(), nullable=True), sa.Column('gears', sa.SmallInteger(), nullable=True), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('device_id', 'device', ['id'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index(op.f('ix_device_created'), 'device', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_device_updated'), 'device', ['updated'], unique=False, schema=f'{INV}') - op.create_index('type_index', 'device', ['type'], unique=False, postgresql_using='hash', schema=f'{INV}') + op.create_index('device_id', 'device', ['id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index(op.f('ix_device_created'), 'device', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_device_updated'), 'device', ['updated'], unique=False, schema=f'{get_inv()}') + op.create_index('type_index', 'device', ['type'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') op.create_table('agent', sa.Column('updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='The last time Devicehub recorded a change for \n this thing.\n '), sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False, comment='When Devicehub created this.'), @@ -133,11 +138,11 @@ def upgrade(): sa.UniqueConstraint('email'), sa.UniqueConstraint('tax_id', 'country', name='Registration Number per country.'), sa.UniqueConstraint('tax_id', 'name', name='One tax ID with one name.'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('agent_type', 'agent', ['type'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index(op.f('ix_agent_created'), 'agent', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_agent_updated'), 'agent', ['updated'], unique=False, schema=f'{INV}') + op.create_index('agent_type', 'agent', ['type'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index(op.f('ix_agent_created'), 'agent', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_agent_updated'), 'agent', ['updated'], unique=False, schema=f'{get_inv()}') # Computer table op.create_table('computer', @@ -150,21 +155,21 @@ def upgrade(): sa.Column('receiver_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('deliverynote_address', citext.CIText(), nullable=True), sa.Column('layout', sa.Enum('US', 'AF', 'ARA', 'AL', 'AM', 'AT', 'AU', 'AZ', 'BY', 'BE', 'BD', 'BA', 'BR', 'BG', 'DZ', 'MA', 'CM', 'MM', 'CA', 'CD', 'CN', 'HR', 'CZ', 'DK', 'NL', 'BT', 'EE', 'IR', 'IQ', 'FO', 'FI', 'FR', 'GH', 'GN', 'GE', 'DE', 'GR', 'HU', 'IL', 'IT', 'JP', 'KG', 'KH', 'KZ', 'LA', 'LATAM', 'LT', 'LV', 'MAO', 'ME', 'MK', 'MT', 'MN', 'NO', 'PL', 'PT', 'RO', 'RU', 'RS', 'SI', 'SK', 'ES', 'SE', 'CH', 'SY', 'TJ', 'LK', 'TH', 'TR', 'TW', 'UA', 'GB', 'UZ', 'VN', 'KR', 'IE', 'PK', 'MV', 'ZA', 'EPO', 'NP', 'NG', 'ET', 'SN', 'BRAI', 'TM', 'ML', 'TZ', 'TG', 'KE', 'BW', 'PH', 'MD', 'ID', 'MY', 'BN', 'IN', 'IS', 'NEC_VNDR_JP', name='layouts'), nullable=True, comment='Layout of a built-in keyboard of the computer,\n if any.\n '), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.ForeignKeyConstraint(['owner_id'], ['common.user.id'], ), sa.ForeignKeyConstraint(['receiver_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('ethereum_address'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Computer accessory op.create_table('computer_accessory', sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('layout', sa.Enum('US', 'AF', 'ARA', 'AL', 'AM', 'AT', 'AU', 'AZ', 'BY', 'BE', 'BD', 'BA', 'BR', 'BG', 'DZ', 'MA', 'CM', 'MM', 'CA', 'CD', 'CN', 'HR', 'CZ', 'DK', 'NL', 'BT', 'EE', 'IR', 'IQ', 'FO', 'FI', 'FR', 'GH', 'GN', 'GE', 'DE', 'GR', 'HU', 'IL', 'IT', 'JP', 'KG', 'KH', 'KZ', 'LA', 'LATAM', 'LT', 'LV', 'MAO', 'ME', 'MK', 'MT', 'MN', 'NO', 'PL', 'PT', 'RO', 'RU', 'RS', 'SI', 'SK', 'ES', 'SE', 'CH', 'SY', 'TJ', 'LK', 'TH', 'TR', 'TW', 'UA', 'GB', 'UZ', 'VN', 'KR', 'IE', 'PK', 'MV', 'ZA', 'EPO', 'NP', 'NG', 'ET', 'SN', 'BRAI', 'TM', 'ML', 'TZ', 'TG', 'KE', 'BW', 'PH', 'MD', 'ID', 'MY', 'BN', 'IN', 'IS', 'NEC_VNDR_JP', name='layouts'), nullable=True), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Device search table @@ -172,12 +177,12 @@ def upgrade(): sa.Column('device_id', sa.BigInteger(), nullable=False), sa.Column('properties', postgresql.TSVECTOR(), nullable=False), sa.Column('tags', postgresql.TSVECTOR(), nullable=True), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('device_id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('properties gist', 'device_search', ['properties'], unique=False, postgresql_using='gist', schema=f'{INV}') - op.create_index('tags gist', 'device_search', ['tags'], unique=False, postgresql_using='gist', schema=f'{INV}') + op.create_index('properties gist', 'device_search', ['properties'], unique=False, postgresql_using='gist', schema=f'{get_inv()}') + op.create_index('tags gist', 'device_search', ['tags'], unique=False, postgresql_using='gist', schema=f'{get_inv()}') # Lot table op.create_table('lot', @@ -195,10 +200,10 @@ def upgrade(): sa.ForeignKeyConstraint(['owner_id'], ['common.user.id'], ), sa.ForeignKeyConstraint(['receiver_address'], ['common.user.ethereum_address'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index(op.f('ix_lot_created'), 'lot', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_lot_updated'), 'lot', ['updated'], unique=False, schema=f'{INV}') + op.create_index(op.f('ix_lot_created'), 'lot', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_lot_updated'), 'lot', ['updated'], unique=False, schema=f'{get_inv()}') # Mobile table op.create_table('mobile', @@ -208,9 +213,9 @@ def upgrade(): sa.Column('ram_size', sa.Integer(), nullable=True, comment='The total of RAM of the device in MB.'), sa.Column('data_storage_size', sa.Integer(), nullable=True, comment='The total of data storage of the device in MB'), sa.Column('display_size', sa.Float(decimal_return_scale=1), nullable=True, comment='The total size of the device screen'), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Monitor table @@ -223,9 +228,9 @@ def upgrade(): sa.Column('contrast_ratio', sa.SmallInteger(), nullable=True), sa.Column('touchable', sa.Boolean(), nullable=True, comment='Whether it is a touchscreen.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Networtking table @@ -233,17 +238,17 @@ def upgrade(): sa.Column('speed', sa.SmallInteger(), nullable=True, comment='The maximum speed this network adapter can handle,\n in mbps.\n '), sa.Column('wireless', sa.Boolean(), nullable=False, comment='Whether it is a wireless interface.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Organization table op.create_table('organization', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.agent.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.agent.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Printer table @@ -253,9 +258,9 @@ def upgrade(): sa.Column('scanning', sa.Boolean(), nullable=False, comment='Whether the printer has scanning capabilities.'), sa.Column('technology', sa.Enum('Toner', 'Inkjet', 'SolidInk', 'Dye', 'Thermal', name='printertechnology'), nullable=True, comment='Technology used to print.'), sa.Column('monochrome', sa.Boolean(), nullable=False, comment='Whether the printer is only monochrome.'), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Proof table @@ -266,12 +271,12 @@ def upgrade(): sa.Column('type', sa.Unicode(), nullable=False), sa.Column('ethereum_hash', citext.CIText(), nullable=False), sa.Column('device_id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index(op.f('ix_proof_created'), 'proof', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_proof_updated'), 'proof', ['updated'], unique=False, schema=f'{INV}') + op.create_index(op.f('ix_proof_created'), 'proof', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_proof_updated'), 'proof', ['updated'], unique=False, schema=f'{get_inv()}') # Action table op.create_table('action', @@ -289,18 +294,18 @@ def upgrade(): sa.Column('author_id', postgresql.UUID(as_uuid=True), nullable=False, comment='The user that recorded this action in the system.\n \n This does not necessarily has to be the person that produced\n the action in the real world. For that purpose see\n ``agent``.\n '), sa.Column('agent_id', postgresql.UUID(as_uuid=True), nullable=False, comment='The direct performer or driver of the action. \n e.g. John wrote a book.\n \n It can differ with the user that registered the action in the\n system, which can be in their behalf.\n '), sa.Column('parent_id', sa.BigInteger(), nullable=True, comment='For actions that are performed to components, \n the device parent at that time.\n \n For example: for a ``EraseBasic`` performed on a data storage, this\n would point to the computer that contained this data storage, if any.\n '), - sa.ForeignKeyConstraint(['agent_id'], [f'{INV}.agent.id'], ), + sa.ForeignKeyConstraint(['agent_id'], [f'{get_inv()}.agent.id'], ), sa.ForeignKeyConstraint(['author_id'], ['common.user.id'], ), - sa.ForeignKeyConstraint(['parent_id'], [f'{INV}.computer.id'], ), - sa.ForeignKeyConstraint(['snapshot_id'], [f'{INV}.snapshot.id'], name='snapshot_actions', use_alter=True), + sa.ForeignKeyConstraint(['parent_id'], [f'{get_inv()}.computer.id'], ), + sa.ForeignKeyConstraint(['snapshot_id'], [f'{get_inv()}.snapshot.id'], name='snapshot_actions', use_alter=True), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index(op.f('ix_action_created'), 'action', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_action_updated'), 'action', ['updated'], unique=False, schema=f'{INV}') - op.create_index('ix_id', 'action', ['id'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index('ix_parent_id', 'action', ['parent_id'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index('ix_type', 'action', ['type'], unique=False, postgresql_using='hash', schema=f'{INV}') + op.create_index(op.f('ix_action_created'), 'action', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_action_updated'), 'action', ['updated'], unique=False, schema=f'{get_inv()}') + op.create_index('ix_id', 'action', ['id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index('ix_parent_id', 'action', ['parent_id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index('ix_type', 'action', ['type'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') # Component table op.create_table('component', @@ -314,12 +319,12 @@ def upgrade(): sa.Column('vertical_view_angle', sa.SmallInteger(), nullable=True), sa.Column('video_stabilization', sa.Boolean(), nullable=True), sa.Column('flash', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['id'], [f'{INV}.device.id'], ), - sa.ForeignKeyConstraint(['parent_id'], [f'{INV}.computer.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.device.id'], ), + sa.ForeignKeyConstraint(['parent_id'], [f'{get_inv()}.computer.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('parent_index', 'component', ['parent_id'], unique=False, postgresql_using='hash', schema=f'{INV}') + op.create_index('parent_index', 'component', ['parent_id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') # Deliverynote table op.create_table('deliverynote', @@ -338,27 +343,27 @@ def upgrade(): sa.Column('ethereum_address', citext.CIText(), nullable=True), sa.Column('lot_id', postgresql.UUID(as_uuid=True), nullable=False), sa.ForeignKeyConstraint(['creator_id'], ['common.user.id'], ), - sa.ForeignKeyConstraint(['lot_id'], [f'{INV}.lot.id'], ), + sa.ForeignKeyConstraint(['lot_id'], [f'{get_inv()}.lot.id'], ), sa.ForeignKeyConstraint(['receiver_address'], ['common.user.email'], ), sa.ForeignKeyConstraint(['supplier_email'], ['common.user.email'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('ethereum_address'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index(op.f('ix_deliverynote_created'), 'deliverynote', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_deliverynote_updated'), 'deliverynote', ['updated'], unique=False, schema=f'{INV}') + op.create_index(op.f('ix_deliverynote_created'), 'deliverynote', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_deliverynote_updated'), 'deliverynote', ['updated'], unique=False, schema=f'{get_inv()}') # Individual table op.create_table('individual', sa.Column('active_org_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['active_org_id'], [f'{INV}.organization.id'], ), - sa.ForeignKeyConstraint(['id'], [f'{INV}.agent.id'], ), + sa.ForeignKeyConstraint(['active_org_id'], [f'{get_inv()}.organization.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.agent.id'], ), sa.ForeignKeyConstraint(['user_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Lot device table @@ -368,10 +373,10 @@ def upgrade(): sa.Column('created', sa.DateTime(), nullable=False), sa.Column('author_id', postgresql.UUID(as_uuid=True), nullable=False, comment='The user that put the device in the lot.'), sa.ForeignKeyConstraint(['author_id'], ['common.user.id'], ), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ), - sa.ForeignKeyConstraint(['lot_id'], [f'{INV}.lot.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ), + sa.ForeignKeyConstraint(['lot_id'], [f'{get_inv()}.lot.id'], ), sa.PrimaryKeyConstraint('device_id', 'lot_id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Path table @@ -380,14 +385,14 @@ def upgrade(): sa.Column('lot_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('path', sqlalchemy_utils.types.ltree.LtreeType(), nullable=False), sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True, comment='When Devicehub created this.'), - sa.ForeignKeyConstraint(['lot_id'], [f'{INV}.lot.id'], ), + sa.ForeignKeyConstraint(['lot_id'], [f'{get_inv()}.lot.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('path', deferrable='True', initially='immediate', name='path_unique'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('lot_id_index', 'path', ['lot_id'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index('path_btree', 'path', ['path'], unique=False, postgresql_using='btree', schema=f'{INV}') - op.create_index('path_gist', 'path', ['path'], unique=False, postgresql_using='gist', schema=f'{INV}') + op.create_index('lot_id_index', 'path', ['lot_id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index('path_btree', 'path', ['path'], unique=False, postgresql_using='btree', schema=f'{get_inv()}') + op.create_index('path_gist', 'path', ['path'], unique=False, postgresql_using='gist', schema=f'{get_inv()}') # Proof recycling table op.create_table('proof_recycling', @@ -398,9 +403,9 @@ def upgrade(): sa.Column('gps_location', citext.CIText(), nullable=False), sa.Column('recycler_code', citext.CIText(), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.proof.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.proof.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Proof reuse table @@ -411,11 +416,11 @@ def upgrade(): sa.Column('receiver_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('price', sa.Integer(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.proof.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.proof.id'], ), sa.ForeignKeyConstraint(['receiver_id'], ['common.user.id'], ), sa.ForeignKeyConstraint(['supplier_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Proof transfer table @@ -424,11 +429,11 @@ def upgrade(): sa.Column('receiver_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('deposit', sa.Integer(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.proof.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.proof.id'], ), sa.ForeignKeyConstraint(['receiver_id'], ['common.user.id'], ), sa.ForeignKeyConstraint(['supplier_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Tag table @@ -440,58 +445,58 @@ def upgrade(): sa.Column('provider', teal.db.URL(), nullable=True, comment='The tag provider URL. If None, the provider is\n this Devicehub.\n '), sa.Column('device_id', sa.BigInteger(), nullable=True), sa.Column('secondary', citext.CIText(), nullable=True, comment='A secondary identifier for this tag. \n It has the same constraints as the main one. Only needed in special cases.\n '), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ondelete='SET NULL'), - sa.ForeignKeyConstraint(['org_id'], [f'{INV}.organization.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['org_id'], [f'{get_inv()}.organization.id'], ), sa.PrimaryKeyConstraint('id', 'org_id'), sa.UniqueConstraint('id', 'org_id', name='one tag id per organization'), sa.UniqueConstraint('secondary', 'org_id', name='one secondary tag per organization'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('device_id_index', 'tag', ['device_id'], unique=False, postgresql_using='hash', schema=f'{INV}') - op.create_index(op.f('ix_tag_created'), 'tag', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_tag_secondary'), 'tag', ['secondary'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_tag_updated'), 'tag', ['updated'], unique=False, schema=f'{INV}') + op.create_index('device_id_index', 'tag', ['device_id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') + op.create_index(op.f('ix_tag_created'), 'tag', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_tag_secondary'), 'tag', ['secondary'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_tag_updated'), 'tag', ['updated'], unique=False, schema=f'{get_inv()}') # ActionComponent table op.create_table('action_component', sa.Column('device_id', sa.BigInteger(), nullable=False), sa.Column('action_id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['action_id'], [f'{INV}.action.id'], ), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['action_id'], [f'{get_inv()}.action.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('device_id', 'action_id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Action device table op.create_table('action_device', sa.Column('device_id', sa.BigInteger(), nullable=False), sa.Column('action_id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['action_id'], [f'{INV}.action.id'], ), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ), + sa.ForeignKeyConstraint(['action_id'], [f'{get_inv()}.action.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ), sa.PrimaryKeyConstraint('device_id', 'action_id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # ActionWithOneDevice table op.create_table('action_with_one_device', sa.Column('device_id', sa.BigInteger(), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['device_id'], [f'{INV}.device.id'], ), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['device_id'], [f'{get_inv()}.device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index('action_one_device_id_index', 'action_with_one_device', ['device_id'], unique=False, postgresql_using='hash', schema=f'{INV}') + op.create_index('action_one_device_id_index', 'action_with_one_device', ['device_id'], unique=False, postgresql_using='hash', schema=f'{get_inv()}') # Allocate table op.create_table('allocate', sa.Column('to_id', postgresql.UUID(), nullable=True), sa.Column('organization', citext.CIText(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.ForeignKeyConstraint(['to_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # BAtter table @@ -500,9 +505,9 @@ def upgrade(): sa.Column('technology', sa.Enum('LiIon', 'NiCd', 'NiMH', 'LiPoly', 'LiFe', 'LiMn', 'Al', name='batterytechnology'), nullable=True), sa.Column('size', sa.Integer(), nullable=False, comment='Maximum battery capacity by design, in mAh.\n\n Use BatteryTest\'s "size" to get the actual size of the battery.\n '), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # DataStorage table @@ -510,9 +515,9 @@ def upgrade(): sa.Column('size', sa.Integer(), nullable=True, comment='The size of the data-storage in MB.'), sa.Column('interface', sa.Enum('ATA', 'USB', 'PCI', name='datastorageinterface'), nullable=True), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Deallocate table @@ -521,9 +526,9 @@ def upgrade(): sa.Column('organization', citext.CIText(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.ForeignKeyConstraint(['from_id'], ['common.user.id'], ), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Display table @@ -536,18 +541,18 @@ def upgrade(): sa.Column('contrast_ratio', sa.SmallInteger(), nullable=True), sa.Column('touchable', sa.Boolean(), nullable=True, comment='Whether it is a touchscreen.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # GraphiCard table op.create_table('graphic_card', sa.Column('memory', sa.SmallInteger(), nullable=True, comment='The amount of memory of the Graphic Card in MB.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Membership table @@ -557,22 +562,22 @@ def upgrade(): sa.Column('id', sa.Unicode(), nullable=True), sa.Column('organization_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('individual_id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['individual_id'], [f'{INV}.individual.id'], ), - sa.ForeignKeyConstraint(['organization_id'], [f'{INV}.organization.id'], ), + sa.ForeignKeyConstraint(['individual_id'], [f'{get_inv()}.individual.id'], ), + sa.ForeignKeyConstraint(['organization_id'], [f'{get_inv()}.organization.id'], ), sa.PrimaryKeyConstraint('organization_id', 'individual_id'), sa.UniqueConstraint('id', 'organization_id', name='One member id per organization.'), - schema=f'{INV}' + schema=f'{get_inv()}' ) - op.create_index(op.f('ix_membership_created'), 'membership', ['created'], unique=False, schema=f'{INV}') - op.create_index(op.f('ix_membership_updated'), 'membership', ['updated'], unique=False, schema=f'{INV}') + op.create_index(op.f('ix_membership_created'), 'membership', ['created'], unique=False, schema=f'{get_inv()}') + op.create_index(op.f('ix_membership_updated'), 'membership', ['updated'], unique=False, schema=f'{get_inv()}') # Migrate table op.create_table('migrate', sa.Column('other', teal.db.URL(), nullable=False, comment='\n The URL of the Migrate in the other end.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Motherboard table @@ -586,9 +591,9 @@ def upgrade(): sa.Column('ram_slots', sa.SmallInteger(), nullable=True), sa.Column('ram_max_size', sa.Integer(), nullable=True), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Network adapter @@ -596,17 +601,17 @@ def upgrade(): sa.Column('speed', sa.SmallInteger(), nullable=True, comment='The maximum speed this network adapter can handle,\n in mbps.\n '), sa.Column('wireless', sa.Boolean(), nullable=False, comment='Whether it is a wireless interface.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Organize table op.create_table('organize', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Processor table @@ -617,9 +622,9 @@ def upgrade(): sa.Column('address', sa.SmallInteger(), nullable=True, comment='The address of the CPU: 8, 16, 32, 64, 128 or 256 bits.'), sa.Column('abi', sa.Unicode(), nullable=True, comment='The Application Binary Interface of the processor.'), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # RamModule table @@ -629,53 +634,53 @@ def upgrade(): sa.Column('interface', sa.Enum('SDRAM', 'DDR', 'DDR2', 'DDR3', 'DDR4', 'DDR5', 'DDR6', name='raminterface'), nullable=True), sa.Column('format', sa.Enum('DIMM', 'SODIMM', name='ramformat'), nullable=True), sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Receive table op.create_table('receive', sa.Column('role', sa.Enum('Intermediary', 'FinalUser', 'CollectionPoint', 'RecyclingPoint', 'Transporter', name='receiverrole'), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Sound card table op.create_table('sound_card', sa.Column('id', sa.BigInteger(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.component.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.component.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Benchmark table op.create_table('benchmark', sa.Column('elapsed', sa.Interval(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Erase basic table op.create_table('erase_basic', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('method', sa.Enum('Shred', 'Disintegration', name='physicalerasuremethod'), nullable=True), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('install', sa.Column('elapsed', sa.Interval(), nullable=False), sa.Column('address', sa.SmallInteger(), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Live table @@ -689,9 +694,9 @@ def upgrade(): sa.Column('organization', sa.Unicode(length=32), nullable=True), sa.Column('organization_type', sa.Unicode(length=32), nullable=True), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Rate table @@ -701,9 +706,9 @@ def upgrade(): sa.Column('appearance', sa.Float(decimal_return_scale=2), nullable=True, comment='Subjective value representing aesthetic aspects.'), sa.Column('functionality', sa.Float(decimal_return_scale=2), nullable=True, comment='Subjective value representing usage aspects.'), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Snapshot table @@ -713,18 +718,18 @@ def upgrade(): sa.Column('software', sa.Enum('Workbench', 'WorkbenchAndroid', 'AndroidApp', 'Web', 'DesktopApp', name='snapshotsoftware'), nullable=False), sa.Column('elapsed', sa.Interval(), nullable=True, comment='For Snapshots made with Workbench, the total amount \n of time it took to complete.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('uuid'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Test table op.create_table('test', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # BenchmarkDataStorage table @@ -732,18 +737,18 @@ def upgrade(): sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('read_speed', sa.Float(decimal_return_scale=2), nullable=False), sa.Column('write_speed', sa.Float(decimal_return_scale=2), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.benchmark.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.benchmark.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # BenchmarkWithRate table op.create_table('benchmark_with_rate', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('rate', sa.Float(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.benchmark.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.benchmark.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # MeasureBattery table @@ -753,9 +758,9 @@ def upgrade(): sa.Column('cycle_count', sa.Integer(), nullable=True, comment='The number of full charges – discharges \n cycles.\n '), sa.Column('health', sa.Enum('Cold', 'Dead', 'Good', 'Overheat', 'OverVoltage', 'UnspecifiedValue', name='batteryhealth'), nullable=True, comment='The health of the Battery. \n Only reported in Android.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Price table @@ -766,10 +771,10 @@ def upgrade(): sa.Column('version', teal.db.StrictVersionType(), nullable=True, comment='The version of the software, or None.'), sa.Column('rating_id', postgresql.UUID(as_uuid=True), nullable=True, comment='The Rate used to auto-compute\n this price, if it has not been set manually.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action_with_one_device.id'], ), - sa.ForeignKeyConstraint(['rating_id'], [f'{INV}.rate.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action_with_one_device.id'], ), + sa.ForeignKeyConstraint(['rating_id'], [f'{get_inv()}.rate.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # ProofDataWipe table @@ -779,11 +784,11 @@ def upgrade(): sa.Column('proof_author_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('erasure_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['erasure_id'], [f'{INV}.erase_basic.id'], ), - sa.ForeignKeyConstraint(['id'], [f'{INV}.proof.id'], ), + sa.ForeignKeyConstraint(['erasure_id'], [f'{get_inv()}.erase_basic.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.proof.id'], ), sa.ForeignKeyConstraint(['proof_author_id'], ['common.user.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # PRoofFuntion @@ -792,11 +797,11 @@ def upgrade(): sa.Column('proof_author_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('rate_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.proof.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.proof.id'], ), sa.ForeignKeyConstraint(['proof_author_id'], ['common.user.id'], ), - sa.ForeignKeyConstraint(['rate_id'], [f'{INV}.rate.id'], ), + sa.ForeignKeyConstraint(['rate_id'], [f'{get_inv()}.rate.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # RateComputer table @@ -806,18 +811,18 @@ def upgrade(): sa.Column('data_storage', sa.Float(decimal_return_scale=2), nullable=True, comment="'Data storage rate, like HHD, SSD.'"), sa.Column('graphic_card', sa.Float(decimal_return_scale=2), nullable=True, comment='Graphic card rate.'), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.rate.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.rate.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # SnapshotRequest table op.create_table('snapshot_request', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('request', sa.JSON(), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.snapshot.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.snapshot.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Step table @@ -828,49 +833,49 @@ def upgrade(): sa.Column('severity', teal.db.IntEnum(Severity), nullable=False), sa.Column('start_time', sa.TIMESTAMP(timezone=True), nullable=False, comment='When the action starts. For some actions like\n reservations the time when they are available, for others like renting\n when the renting starts.\n '), sa.Column('end_time', sa.TIMESTAMP(timezone=True), nullable=False, comment='When the action ends. For some actions like reservations\n the time when they expire, for others like renting\n the time the end rents. For punctual actions it is the time \n they are performed; it differs with ``created`` in which\n created is the where the system received the action.\n '), - sa.ForeignKeyConstraint(['erasure_id'], [f'{INV}.erase_basic.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['erasure_id'], [f'{get_inv()}.erase_basic.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('erasure_id', 'num'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('stress_test', sa.Column('elapsed', sa.Interval(), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('test_audio', sa.Column('speaker', sa.Boolean(), nullable=True, comment='Whether the speaker works as expected.'), sa.Column('microphone', sa.Boolean(), nullable=True, comment='Whether the microphone works as expected.'), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('test_bios', sa.Column('beeps_power_on', sa.Boolean(), nullable=True, comment='Whether there are no beeps or error\n codes when booting up.\n \n Reference: R2 provision 6 page 23.\n '), sa.Column('access_range', sa.Enum('A', 'B', 'C', 'D', 'E', name='biosaccessrange'), nullable=True, comment='Difficulty to modify the boot menu.\n \n This is used as an usability measure for accessing and modifying\n a bios, specially as something as important as modifying the boot\n menu.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('test_camera', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('test_connectivity', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) op.create_table('test_data_storage', @@ -887,41 +892,41 @@ def upgrade(): sa.Column('remaining_lifetime_percentage', sa.SmallInteger(), nullable=True), sa.Column('elapsed', sa.Interval(), nullable=False), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # TestDisplayHinge table op.create_table('test_display_hinge', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # TestKeyboard table op.create_table('test_keyboard', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # TestPowerAdapter table op.create_table('test_power_adapter', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # TestTrackpad table op.create_table('test_trackpad', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # VisualTest table @@ -930,9 +935,9 @@ def upgrade(): sa.Column('functionality_range', sa.Enum('A', 'B', 'C', 'D', name='functionalityrange'), nullable=True, comment='Grades the defects of a device that affect its usage.'), sa.Column('labelling', sa.Boolean(), nullable=True, comment='Whether there are tags to be removed.'), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['id'], [f'{INV}.test.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.test.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # Trade table @@ -943,186 +948,190 @@ def upgrade(): sa.Column('to_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('confirms_id', postgresql.UUID(as_uuid=True), nullable=True, comment='An organize action that this association confirms. \n \n For example, a ``Sell`` or ``Rent``\n can confirm a ``Reserve`` action.\n '), sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), - sa.ForeignKeyConstraint(['confirms_id'], [f'{INV}.organize.id'], ), - sa.ForeignKeyConstraint(['id'], [f'{INV}.action.id'], ), - sa.ForeignKeyConstraint(['price_id'], [f'{INV}.price.id'], ), - sa.ForeignKeyConstraint(['to_id'], [f'{INV}.agent.id'], ), + sa.ForeignKeyConstraint(['confirms_id'], [f'{get_inv()}.organize.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.action.id'], ), + sa.ForeignKeyConstraint(['price_id'], [f'{get_inv()}.price.id'], ), + sa.ForeignKeyConstraint(['to_id'], [f'{get_inv()}.agent.id'], ), sa.PrimaryKeyConstraint('id'), - schema=f'{INV}' + schema=f'{get_inv()}' ) # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### # Drop table, indexes in inventory schema - op.drop_table('trade', schema=f'{INV}') + op.drop_table('trade', schema=f'{get_inv()}') - op.drop_table('visual_test', schema=f'{INV}') + op.drop_table('visual_test', schema=f'{get_inv()}') - op.drop_table('test_trackpad', schema=f'{INV}') + op.drop_table('test_trackpad', schema=f'{get_inv()}') - op.drop_table('test_power_adapter', schema=f'{INV}') + op.drop_table('test_power_adapter', schema=f'{get_inv()}') - op.drop_table('test_keyboard', schema=f'{INV}') + op.drop_table('test_keyboard', schema=f'{get_inv()}') - op.drop_table('test_display_hinge', schema=f'{INV}') + op.drop_table('test_display_hinge', schema=f'{get_inv()}') - op.drop_table('test_data_storage', schema=f'{INV}') + op.drop_table('test_data_storage', schema=f'{get_inv()}') - op.drop_table('test_connectivity', schema=f'{INV}') + op.drop_table('test_connectivity', schema=f'{get_inv()}') - op.drop_table('test_camera', schema=f'{INV}') + op.drop_table('test_camera', schema=f'{get_inv()}') - op.drop_table('test_bios', schema=f'{INV}') + op.drop_table('test_bios', schema=f'{get_inv()}') - op.drop_table('test_audio', schema=f'{INV}') + op.drop_table('test_audio', schema=f'{get_inv()}') - op.drop_table('stress_test', schema=f'{INV}') + op.drop_table('stress_test', schema=f'{get_inv()}') - op.drop_table('step', schema=f'{INV}') + op.drop_table('step', schema=f'{get_inv()}') - op.drop_table('snapshot_request', schema=f'{INV}') + op.drop_table('snapshot_request', schema=f'{get_inv()}') - op.drop_table('rate_computer', schema=f'{INV}') + op.drop_table('rate_computer', schema=f'{get_inv()}') - op.drop_table('proof_function', schema=f'{INV}') + op.drop_table('proof_function', schema=f'{get_inv()}') - op.drop_table('proof_data_wipe', schema=f'{INV}') + op.drop_table('proof_data_wipe', schema=f'{get_inv()}') - op.drop_table('price', schema=f'{INV}') + op.drop_table('price', schema=f'{get_inv()}') - op.drop_table('measure_battery', schema=f'{INV}') + op.drop_table('measure_battery', schema=f'{get_inv()}') - op.drop_table('benchmark_with_rate', schema=f'{INV}') + op.drop_table('benchmark_with_rate', schema=f'{get_inv()}') - op.drop_table('benchmark_data_storage', schema=f'{INV}') + op.drop_table('benchmark_data_storage', schema=f'{get_inv()}') - op.drop_table('test', schema=f'{INV}') + op.drop_table('test', schema=f'{get_inv()}') - op.drop_table('snapshot', schema=f'{INV}') + op.drop_constraint("snapshot_actions", "action", type_="foreignkey", schema=f'{get_inv()}') + op.drop_table('snapshot', schema=f'{get_inv()}') - op.drop_table('rate', schema=f'{INV}') + op.drop_table('rate', schema=f'{get_inv()}') - op.drop_table('live', schema=f'{INV}') + op.drop_table('live', schema=f'{get_inv()}') - op.drop_table('install', schema=f'{INV}') + op.drop_table('install', schema=f'{get_inv()}') - op.drop_table('erase_basic', schema=f'{INV}') + op.drop_table('erase_basic', schema=f'{get_inv()}') - op.drop_table('benchmark', schema=f'{INV}') + op.drop_table('benchmark', schema=f'{get_inv()}') - op.drop_table('sound_card', schema=f'{INV}') + op.drop_table('sound_card', schema=f'{get_inv()}') - op.drop_table('receive', schema=f'{INV}') + op.drop_table('receive', schema=f'{get_inv()}') - op.drop_table('ram_module', schema=f'{INV}') + op.drop_table('ram_module', schema=f'{get_inv()}') - op.drop_table('processor', schema=f'{INV}') + op.drop_table('processor', schema=f'{get_inv()}') - op.drop_table('organize', schema=f'{INV}') + op.drop_table('organize', schema=f'{get_inv()}') - op.drop_table('network_adapter', schema=f'{INV}') + op.drop_table('network_adapter', schema=f'{get_inv()}') - op.drop_table('motherboard', schema=f'{INV}') + op.drop_table('motherboard', schema=f'{get_inv()}') - op.drop_table('migrate', schema=f'{INV}') + op.drop_table('migrate', schema=f'{get_inv()}') - op.drop_index(op.f('ix_membership_updated'), table_name='membership', schema=f'{INV}') - op.drop_index(op.f('ix_membership_created'), table_name='membership', schema=f'{INV}') - op.drop_table('membership', schema=f'{INV}') + op.drop_index(op.f('ix_membership_updated'), table_name='membership', schema=f'{get_inv()}') + op.drop_index(op.f('ix_membership_created'), table_name='membership', schema=f'{get_inv()}') + op.drop_table('membership', schema=f'{get_inv()}') - op.drop_table('graphic_card', schema=f'{INV}') + op.drop_table('graphic_card', schema=f'{get_inv()}') - op.drop_table('display', schema=f'{INV}') + op.drop_table('display', schema=f'{get_inv()}') - op.drop_table('deallocate', schema=f'{INV}') + op.drop_table('deallocate', schema=f'{get_inv()}') - op.drop_table('data_storage', schema=f'{INV}') + op.drop_table('data_storage', schema=f'{get_inv()}') - op.drop_table('battery', schema=f'{INV}') + op.drop_table('battery', schema=f'{get_inv()}') - op.drop_table('allocate', schema=f'{INV}') + op.drop_table('allocate', schema=f'{get_inv()}') - op.drop_index('action_one_device_id_index', table_name='action_with_one_device', schema=f'{INV}') - op.drop_table('action_with_one_device', schema=f'{INV}') + op.drop_index('action_one_device_id_index', table_name='action_with_one_device', schema=f'{get_inv()}') + op.drop_table('action_with_one_device', schema=f'{get_inv()}') - op.drop_table('action_device', schema=f'{INV}') + op.drop_table('action_device', schema=f'{get_inv()}') - op.drop_table('action_component', schema=f'{INV}') + op.drop_table('action_component', schema=f'{get_inv()}') - op.drop_index(op.f('ix_tag_updated'), table_name='tag', schema=f'{INV}') - op.drop_index(op.f('ix_tag_secondary'), table_name='tag', schema=f'{INV}') - op.drop_index(op.f('ix_tag_created'), table_name='tag', schema=f'{INV}') - op.drop_index('device_id_index', table_name='tag', schema=f'{INV}') - op.drop_table('tag', schema=f'{INV}') + op.drop_index(op.f('ix_tag_updated'), table_name='tag', schema=f'{get_inv()}') + op.drop_index(op.f('ix_tag_secondary'), table_name='tag', schema=f'{get_inv()}') + op.drop_index(op.f('ix_tag_created'), table_name='tag', schema=f'{get_inv()}') + op.drop_index('device_id_index', table_name='tag', schema=f'{get_inv()}') + op.drop_table('tag', schema=f'{get_inv()}') - op.drop_table('proof_transfer', schema=f'{INV}') + op.drop_table('proof_transfer', schema=f'{get_inv()}') - op.drop_table('proof_reuse', schema=f'{INV}') + op.drop_table('proof_reuse', schema=f'{get_inv()}') - op.drop_table('proof_recycling', schema=f'{INV}') + op.drop_table('proof_recycling', schema=f'{get_inv()}') - op.drop_index('path_gist', table_name='path', schema=f'{INV}') - op.drop_index('path_btree', table_name='path', schema=f'{INV}') - op.drop_index('lot_id_index', table_name='path', schema=f'{INV}') - op.drop_table('path', schema=f'{INV}') + op.drop_index('path_gist', table_name='path', schema=f'{get_inv()}') + op.drop_index('path_btree', table_name='path', schema=f'{get_inv()}') + op.drop_index('lot_id_index', table_name='path', schema=f'{get_inv()}') - op.drop_table('lot_device', schema=f'{INV}') + op.execute(f"DROP VIEW {get_inv()}.lot_device_descendants") + op.execute(f"DROP VIEW {get_inv()}.lot_parent") - op.drop_table('individual', schema=f'{INV}') + op.drop_table('path', schema=f'{get_inv()}') - op.drop_index(op.f('ix_deliverynote_updated'), table_name='deliverynote', schema=f'{INV}') - op.drop_index(op.f('ix_deliverynote_created'), table_name='deliverynote', schema=f'{INV}') - op.drop_table('deliverynote', schema=f'{INV}') + op.drop_table('lot_device', schema=f'{get_inv()}') - op.drop_index('parent_index', table_name='component', schema=f'{INV}') - op.drop_table('component', schema=f'{INV}') + op.drop_table('individual', schema=f'{get_inv()}') - op.drop_index('ix_type', table_name='action', schema=f'{INV}') - op.drop_index('ix_parent_id', table_name='action', schema=f'{INV}') - op.drop_index('ix_id', table_name='action', schema=f'{INV}') - op.drop_index(op.f('ix_action_updated'), table_name='action', schema=f'{INV}') - op.drop_index(op.f('ix_action_created'), table_name='action', schema=f'{INV}') - op.drop_table('action', schema=f'{INV}') + op.drop_index(op.f('ix_deliverynote_updated'), table_name='deliverynote', schema=f'{get_inv()}') + op.drop_index(op.f('ix_deliverynote_created'), table_name='deliverynote', schema=f'{get_inv()}') + op.drop_table('deliverynote', schema=f'{get_inv()}') - op.drop_index(op.f('ix_proof_updated'), table_name='proof', schema=f'{INV}') - op.drop_index(op.f('ix_proof_created'), table_name='proof', schema=f'{INV}') - op.drop_table('proof', schema=f'{INV}') + op.drop_index('parent_index', table_name='component', schema=f'{get_inv()}') + op.drop_table('component', schema=f'{get_inv()}') - op.drop_table('printer', schema=f'{INV}') + op.drop_index('ix_type', table_name='action', schema=f'{get_inv()}') + op.drop_index('ix_parent_id', table_name='action', schema=f'{get_inv()}') + op.drop_index('ix_id', table_name='action', schema=f'{get_inv()}') + op.drop_index(op.f('ix_action_updated'), table_name='action', schema=f'{get_inv()}') + op.drop_index(op.f('ix_action_created'), table_name='action', schema=f'{get_inv()}') + op.drop_table('action', schema=f'{get_inv()}') - op.drop_table('organization', schema=f'{INV}') + op.drop_index(op.f('ix_proof_updated'), table_name='proof', schema=f'{get_inv()}') + op.drop_index(op.f('ix_proof_created'), table_name='proof', schema=f'{get_inv()}') + op.drop_table('proof', schema=f'{get_inv()}') - op.drop_table('networking', schema=f'{INV}') + op.drop_table('printer', schema=f'{get_inv()}') - op.drop_table('monitor', schema=f'{INV}') + op.drop_table('organization', schema=f'{get_inv()}') - op.drop_table('mobile', schema=f'{INV}') + op.drop_table('networking', schema=f'{get_inv()}') - op.drop_index(op.f('ix_lot_updated'), table_name='lot', schema=f'{INV}') - op.drop_index(op.f('ix_lot_created'), table_name='lot', schema=f'{INV}') - op.drop_table('lot', schema=f'{INV}') + op.drop_table('monitor', schema=f'{get_inv()}') - op.drop_index('tags gist', table_name='device_search', schema=f'{INV}') - op.drop_index('properties gist', table_name='device_search', schema=f'{INV}') - op.drop_table('device_search', schema=f'{INV}') + op.drop_table('mobile', schema=f'{get_inv()}') - op.drop_table('computer_accessory', schema=f'{INV}') + op.drop_index(op.f('ix_lot_updated'), table_name='lot', schema=f'{get_inv()}') + op.drop_index(op.f('ix_lot_created'), table_name='lot', schema=f'{get_inv()}') + op.drop_table('lot', schema=f'{get_inv()}') - op.drop_table('computer', schema=f'{INV}') + op.drop_index('tags gist', table_name='device_search', schema=f'{get_inv()}') + op.drop_index('properties gist', table_name='device_search', schema=f'{get_inv()}') + op.drop_table('device_search', schema=f'{get_inv()}') - op.drop_index('type_index', table_name='device', schema=f'{INV}') - op.drop_index(op.f('ix_device_updated'), table_name='device', schema=f'{INV}') - op.drop_index(op.f('ix_device_created'), table_name='device', schema=f'{INV}') - op.drop_index('device_id', table_name='device', schema=f'{INV}') - op.drop_table('device', schema=f'{INV}') + op.drop_table('computer_accessory', schema=f'{get_inv()}') + op.drop_table('computer', schema=f'{get_inv()}') - op.drop_index(op.f('ix_agent_updated'), table_name='agent', schema=f'{INV}') - op.drop_index(op.f('ix_agent_created'), table_name='agent', schema=f'{INV}') - op.drop_index('agent_type', table_name='agent', schema=f'{INV}') - op.drop_table('agent', schema=f'{INV}') + op.drop_index('type_index', table_name='device', schema=f'{get_inv()}') + op.drop_index(op.f('ix_device_updated'), table_name='device', schema=f'{get_inv()}') + op.drop_index(op.f('ix_device_created'), table_name='device', schema=f'{get_inv()}') + op.drop_index('device_id', table_name='device', schema=f'{get_inv()}') + op.drop_table('device', schema=f'{get_inv()}') + + + op.drop_index(op.f('ix_agent_updated'), table_name='agent', schema=f'{get_inv()}') + op.drop_index(op.f('ix_agent_created'), table_name='agent', schema=f'{get_inv()}') + op.drop_index('agent_type', table_name='agent', schema=f'{get_inv()}') + op.drop_table('agent', schema=f'{get_inv()}') # Drop table, indexes in common schema op.drop_table('user_inventory', schema='common') @@ -1137,4 +1146,14 @@ def downgrade(): op.drop_index(op.f('ix_common_inventory_created'), table_name='inventory', schema='common') op.drop_index('id_hash', table_name='inventory', schema='common') op.drop_table('inventory', schema='common') - # ### end Alembic commands ### + + # Drop sequences + op.execute(f"DROP SEQUENCE {get_inv()}.device_seq;") + + # Drop functions + op.execute(f"DROP FUNCTION IF EXISTS {get_inv()}.add_edge") + op.execute(f"DROP FUNCTION IF EXISTS {get_inv()}.delete_edge") + + # Drop Create Common schema + op.execute("drop schema common") + op.execute(f"drop schema {get_inv()}")